Skip to content

Commit

Permalink
Merge pull request #46 from uc-cdis/fix/authz
Browse files Browse the repository at this point in the history
fix(authz): use `authz` instead of `rbac`
  • Loading branch information
rudyardrichter authored May 22, 2019
2 parents 0fe2d59 + b6a4ed5 commit f2348bb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
9 changes: 5 additions & 4 deletions indexclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

UPDATABLE_ATTRS = [
'file_name', 'urls', 'version',
'metadata', 'acl', 'rbac', 'urls_metadata'
'metadata', 'acl', 'authz', 'urls_metadata'
]


Expand Down Expand Up @@ -52,6 +52,7 @@ def retry_logic_with_timeout(*args, **kwargs):

return retry_logic_with_timeout


class IndexClient(object):

def __init__(self, baseurl, version="v0", auth=None):
Expand Down Expand Up @@ -223,7 +224,7 @@ def list_with_params(self, limit=float("inf"), start=None, page_size=100, params
def create(
self, hashes, size, did=None, urls=None, file_name=None,
metadata=None, baseid=None, acl=None, urls_metadata=None, version=None,
rbac=None):
authz=None):
"""Create a new entry in indexd
Args:
Expand All @@ -233,7 +234,7 @@ def create(
did (str): provide a UUID for the new indexd to be made
urls (list): list of URLs where you can download the UUID
acl (list): access control list
rbac (str): RBAC string
authz (str): RBAC string
file_name (str): name of the file associated with a given UUID
metadata (dict): additional key value metadata for this entry
urls_metadata (dict): metadata attached to each url
Expand All @@ -255,7 +256,7 @@ def create(
"urls_metadata": urls_metadata,
"baseid": baseid,
"acl": acl,
"rbac": rbac,
"authz": authz,
"version": version
}
if did:
Expand Down
9 changes: 7 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
pytest==3.0.6
mock
-e git+https://github.com/uc-cdis/cdisutils-test.git@f1eaf101c2ab6dd2d2ad7dc9bb3f98487238a4ad#egg=cdisutilstest

# these are for indexd
authutils==3.1.0
gen3rbac==0.1.2

-e git+https://github.com/uc-cdis/cdisutils-test.git@fdc53fb3d5333d53f625f0f0712eaa2fa19c803f#egg=cdisutilstest
-e git+https://github.com/uc-cdis/cdis-python-utils.git@0.1.7#egg=cdispyutils
-e git+https://github.com/uc-cdis/indexd.git@ddc6bfd1e0cd4bbf27bc4ab7a7e00078b4d5c98c#egg=indexd
-e git+https://github.com/uc-cdis/indexd.git@28fa621a924952be902628cfc5c1186bda38e922#egg=indexd
-e git+https://github.com/uc-cdis/doiclient.git@1.0.0#egg=doiclient
-e git+https://github.com/uc-cdis/dosclient.git@1.0.0#egg=dosclient
-e git+https://github.com/uc-cdis/cdislogging.git@0.0.2#egg=cdislogging
16 changes: 8 additions & 8 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def test_instantiate(index_client):
urls_metadata={url: {'state': 'doing ok'} for url in urls}
size = 5
acl = ['a', 'b']
rbac = '/gen3/programs/a/projects/b'
authz = ['/gen3/programs/a/projects/b']
hashes = {'md5': 'ab167e49d25b488939b1ede42752458b'}
doc = index_client.create(
hashes=hashes,
size=size,
urls=urls,
acl=acl,
rbac=rbac,
authz=authz,
baseid=baseid,
urls_metadata=urls_metadata,
)
Expand All @@ -30,23 +30,23 @@ def test_instantiate(index_client):
assert doc.baseid == baseid
assert doc.urls_metadata == urls_metadata
assert doc.acl == acl
assert doc.rbac == rbac
assert doc.authz == authz


def test_create_with_metadata(index_client):
urls = ['s3://bucket/key']
urls_metadata = {'s3://bucket/key': {'k': 'v'}}
size = 5
acl = ['a', 'b']
rbac = '/gen3/programs/a/projects/b'
authz = ['/gen3/programs/a/projects/b']
hashes = {'md5': 'ab167e49d25b488939b1ede42752458b'}
metadata = {'test': 'value'}
doc = index_client.create(
hashes=hashes,
size=size,
urls=urls,
acl=acl,
rbac=rbac,
authz=authz,
metadata=metadata,
urls_metadata=urls_metadata,
)
Expand Down Expand Up @@ -187,18 +187,18 @@ def test_updating_acl(index_client):
assert same_doc.acl == ['a']


def test_updating_rbac(index_client):
def test_updating_authz(index_client):
"""
Args:
index_client (indexclient.client.IndexClient): IndexClient Pytest Fixture
"""
doc = create_random_index(index_client)

doc.rbac = '/gen3/programs/a'
doc.authz = ['/gen3/programs/a']
doc.patch()

same_doc = index_client.get(doc.did)
assert same_doc.rbac == '/gen3/programs/a'
assert same_doc.authz == ['/gen3/programs/a']


def test_bulk_request(index_client):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def create_document(
did=None, hashes=None, size=None, file_name=None, acl=None, rbac=None,
did=None, hashes=None, size=None, file_name=None, acl=None, authz=None,
urls=None, urls_metadata=None):

return Document(None, did, json={
Expand All @@ -13,7 +13,7 @@ def create_document(
'file_name': file_name or 'file.txt',
'urls': urls or ['one', 'two', 'three'],
'acl': acl or ['1', '2', '3'],
'rbac': rbac or '/gen3/programs/1/projects/2/3',
'authz': authz or '/gen3/programs/1/projects/2/3',
'urls_metadata': urls_metadata or {
'one': {'1': 'one'},
'two': {'2': 'two'},
Expand Down

0 comments on commit f2348bb

Please sign in to comment.