def test_assign_scope_to_user(self, client, token_generator):
    CLIENT = {}
    USER = {'username': 'test_user_scope', 'password': 'secret', 'person_id': 'c0ffee-c0ffee-c0ffee-99', 'role_id': ''}
    ROLE = {'role': 'Administrator', 'description': 'An administrative user role.'}
    SCOPE = {'scope': 'action:do-all-the-things', 'description': 'A scope that grants the holder superpowers'}
    headers = {'content-type': 'application/json', 'authorization': f'bearer {token_generator.get_token(client)}'}
    response = client.post('/roles', data=json.dumps(ROLE), headers=headers)
    expect(response.status_code).to(be(201))
    role_id = response.json['response'][0]['id']
    response = client.post('/scopes', data=json.dumps(SCOPE), headers=headers)
    expect(response.status_code).to(be(201))
    scope_id = response.json['response'][0]['id']
    response = client.post(f'/roles/{role_id}/scopes', data=json.dumps({'scope_id': scope_id}), headers=headers)
    expect(response.status_code).to(be(201))
    USER['role_id'] = role_id
    response = client.post('/users', data=json.dumps(USER), headers=headers)
    expect(response.status_code).to(be(201))
    user_id = response.json['response'][0]['id']
    response = client.delete(f'/users/{user_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/roles/{role_id}/scopes/{scope_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/roles/{role_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/scopes/{scope_id}', headers=headers)
    expect(response.status_code).to(be(200))
def test_assign_scope_to_user(self, client, token_generator):
    CLIENT = {}
    USER = {'username': 'test_user_scope', 'password': 'secret', 'person_id': 'c0ffee-c0ffee-c0ffee-99', 'role_id': }
    ROLE = {'role': 'Administrator', 'description': 'An administrative user role.'}
    SCOPE = {'scope': 'action:do-all-the-things', 'description': 'A scope that grants the holder superpowers'}
    headers = {'content-type': 'application/json', 'authorization': f'bearer {token_generator.get_token(client)}'}
    response = client.post('/roles', data=json.dumps(ROLE), headers=headers)
    expect(response.status_code).to(be(201))
    role_id = response.json['response'][0]['id']
    response = client.post('/scopes', data=json.dumps(SCOPE), headers=headers)
    expect(response.status_code).to(be(201))
    scope_id = response.json['response'][0]['id']
    response = client.post(f'/roles/{role_id}/scopes', data=json.dumps({'scope_id': scope_id}), headers=headers)
    expect(response.status_code).to(be(201))
    USER['role_id'] = role_id
    response = client.post('/users', data=json.dumps(USER), headers=headers)
    expect(response.status_code).to(be(201))
    user_id = response.json['response'][0]['id']
    response = client.delete(f'/users/{user_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/roles/{role_id}/scopes/{scope_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/roles/{role_id}', headers=headers)
    expect(response.status_code).to(be(200))
    response = client.delete(f'/scopes/{scope_id}', headers=headers)
    expect(response.status_code).to(be(200))