def test_resource_set_registration(): adb = ADB(KEYJAR, 3600, issuer, RESSRV, RSR_PATH) rsd = ResourceSetDescription(name='foo', scopes=[READ, WRITE]) code, msg, kwargs = adb.resource_set_registration('POST', 'alice', rsd.to_json()) assert code == 201 http_response = factory(code, msg, **kwargs) assert isinstance(http_response, Created) jm = json.loads(msg) rsid = jm['_id'] # List all rsid code, msg, kwargs = adb.resource_set_registration('GET', 'alice') assert code == 200 rsid_list = json.loads(msg) assert rsid in rsid_list # get a specific resource set code, msg, kwargs = adb.resource_set_registration('GET', 'alice', rsid=rsid) assert code == 200 rs = json.loads(msg) assert rs['name'] == rsd['name'] assert rs['scopes'] == rsd['scopes'] assert rs['_id'] == rsid # upload a new version of a resource set rsd = ResourceSetDescription(name='foo', scopes=[READ, WRITE], type='document') code, msg, kwargs = adb.resource_set_registration('PUT', 'alice', body=rsd.to_json(), rsid=rsid) assert code == 200 rs = json.loads(msg) assert rs['_id'] == rsid # make sure the change came through code, msg, kwargs = adb.resource_set_registration('GET', 'alice', rsid=rsid) assert code == 200 rs = json.loads(msg) assert _eq(list(rs.keys()),['name', 'scopes', '_id', 'type']) for key in ['name', 'scopes', 'type']: assert rs[key] == rsd[key] assert rs['_id'] == rsid # delete resource set code, msg, kwargs = adb.resource_set_registration('DELETE', 'alice', rsid=rsid) assert code == 204 # List all rsid code, msg, kwargs = adb.resource_set_registration('GET', 'alice') assert code == 200 rsid_list = json.loads(msg) assert rsid_list == []
def test_resource_set_registration(): adb = ADB(KEYJAR, 3600, issuer, RESSRV, RSR_PATH) rsd = ResourceSetDescription(name='foo', scopes=[READ, WRITE]) code, msg, kwargs = adb.resource_set_registration('POST', 'alice', rsd.to_json()) assert code == 201 http_response = factory(code, msg, **kwargs) assert isinstance(http_response, Created) jm = json.loads(msg) rsid = jm['_id'] # List all rsid code, msg, kwargs = adb.resource_set_registration('GET', 'alice') assert code == 200 rsid_list = json.loads(msg) assert rsid in rsid_list # get a specific resource set code, msg, kwargs = adb.resource_set_registration('GET', 'alice', rsid=rsid) assert code == 200 rs = json.loads(msg) assert rs['name'] == rsd['name'] assert rs['scopes'] == rsd['scopes'] assert rs['_id'] == rsid # upload a new version of a resource set rsd = ResourceSetDescription(name='foo', scopes=[READ, WRITE], type='document') code, msg, kwargs = adb.resource_set_registration('PUT', 'alice', body=rsd.to_json(), rsid=rsid) assert code == 200 rs = json.loads(msg) assert rs['_id'] == rsid # make sure the change came through code, msg, kwargs = adb.resource_set_registration('GET', 'alice', rsid=rsid) assert code == 200 rs = json.loads(msg) assert _eq(list(rs.keys()), ['name', 'scopes', '_id', 'type']) for key in ['name', 'scopes', 'type']: assert rs[key] == rsd[key] assert rs['_id'] == rsid # delete resource set code, msg, kwargs = adb.resource_set_registration('DELETE', 'alice', rsid=rsid) assert code == 204 # List all rsid code, msg, kwargs = adb.resource_set_registration('GET', 'alice') assert code == 200 rsid_list = json.loads(msg) assert rsid_list == []