def setUp(self): super(NovaClientCompatMasterTestCase, self).setUp() revdir = test.checkout_vendor(NOVACLIENT_REPO, 'master') self.add_path(revdir) from novaclient.keystone import client as ks_client from novaclient import client as base_client reload(ks_client) reload(base_client) self.app = self.loadapp('keystoneclient_compat_master') self.options = self.appconfig('keystoneclient_compat_master') self.identity_backend = utils.import_object( self.options['identity_driver'], options=self.options) self.token_backend = utils.import_object(self.options['token_driver'], options=self.options) self.catalog_backend = utils.import_object( self.options['catalog_driver'], options=self.options) self.server = self.serveapp('keystoneclient_compat_master') self.tenant_bar = self.identity_backend.create_tenant( 'bar', models.Tenant(id='bar', name='BAR')) self.user_foo = self.identity_backend.create_user( 'foo', models.User(id='foo', name='FOO', tenants=[self.tenant_bar['id']], password='******')) self.extras_bar_foo = self.identity_backend.create_extras( self.user_foo['id'], self.tenant_bar['id'], dict(roles=[], roles_links=[]))
def test_crud_user(self): token_id = self.options['admin_token'] c = client.TestClient(self.app, token=token_id) user_ref = models.User(name='FOO') resp = c.create_user(**user_ref) data = json.loads(resp.body) self.assert_(data['id']) get_resp = c.get_user(user_id=data['id']) get_data = json.loads(get_resp.body) self.assertDictEquals(data, get_data) update_resp = c.update_user(user_id=data['id'], name='FOO', id=data['id'], password='******') update_data = json.loads(update_resp.body) self.assertEquals(data['id'], update_data['id']) self.assertEquals('foo', update_data['password']) del_resp = c.delete_user(user_id=data['id']) self.assertEquals(del_resp.body, '') delget_resp = c.get_user(user_id=data['id']) self.assertEquals(delget_resp.body, '')
def _load_fixtures(self): self.tenant_bar = self.identity_api.create_tenant( 'bar', models.Tenant(id='bar', name='BAR')) self.user_foo = self.identity_api.create_user( 'foo', models.User(id='foo', name='FOO', password='******', tenants=[self.tenant_bar['id']])) self.extras_foobar = self.identity_api.create_extras( 'foo', 'bar', {'extra': 'extra'})