def test_project_creation_checks_network_exists(self): self.fake_client_set.compute.networks.get(self.net_id)\ .AndRaise(osc_exc.NotFound('network')) self.mox.ReplayAll() data = self.interact(expected_status_code=400) self.assertEquals(data.get('element-name'), 'network')
def test_create_user_with_bad_projects(self): client = self.fake_client_set (name, email, passw) = ('user-a', '*****@*****.**', 'bananas') client.identity_admin.users.list().AndReturn([self.user]) client.identity_admin.users.create(name=name, password=passw, email=email, enabled=True).AndReturn('new-user') users.member_role_id().AndReturn('member-role') client.identity_admin.roles.add_user_role( user='******', role='member-role', tenant='PID1') \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() data = self._interact(expected_status_code=400, data={ "name": name, "email": email, "password": passw, "projects": ['PID1', 'PID2'], "admin": False, }) self.assertEquals('projects', data.get('element-name')) self.assertEquals('PID1', data.get('element-value'))
def test_stats_not_found(self): self.fake_client_set.identity_admin.tenants.get(u'pid') \ .AndRaise(osc_exc.NotFound("test message")) self.mox.ReplayAll() rv = self.client.get('/v1/stats/by-project/pid') self.check_and_parse_response(rv, 404)
def test_not_found(self): uid = 'UID42' self.fake_client_set.identity_admin.users.get(uid)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.assertEquals(None, me._find_user({'id': uid}))
def test_remove_no_server(self): compute = self.fake_client_set.compute compute.servers.get(self.server.id)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact(expected_status_code=404)
def test_get_image_data_late_404(self): images._fetch_image('IMG', to_modify=False).AndReturn(self.image) self.image.data().AndRaise(osc_exc.NotFound('gone')) self.mox.ReplayAll() rv = self.client.get('/v1/images/IMG/data') self.check_and_parse_response(rv, status_code=404)
def test_delete_user_not_found(self): self.fake_client_set.compute_ext.user_keypairs.list('user-a') \ .AndReturn([]) self.fake_client_set.identity_admin.users.delete('user-a')\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.delete('/v1/users/user-a') self.assertEquals(rv.status_code, 404)
def test_list_no_project(self): project_id = u'PID' self.fake_client_set.identity_admin.tenants.list_users(u'PID') \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get(u'/v1/projects/%s/users/' % project_id) self.check_and_parse_response(rv, status_code=404)
def test_get_not_found(self): self.fake_client_set.compute.keypairs.find(name='kp')\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get('/v1/me/ssh-keys/kp') self.check_and_parse_response(rv, status_code=404)
def test_vnc_not_found(self): s = self.server instances.fetch_instance(s.id)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact('/v1/instances/%s/vnc' % s.id, {}, expected_status_code=404)
def test_delete_not_found(self): arg = u'42' self.fake_client_set.compute.security_groups.get(arg)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.delete('/v1/fw-rule-sets/%s' % arg) self.check_and_parse_response(rv, 404)
def test_rename_not_found(self): params = {'name': u'new name'} instances.fetch_instance(self.instance_id).AndReturn(self.server) self.server.update(name=u'new name') \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact(params, expected_status_code=404)
def test_get_node_not_found(self): hostname = 'TEST_HOST' self.fake_client_set.compute.hosts.get(hostname)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get('/v1/nodes/%s' % hostname) self.check_and_parse_response(rv, status_code=404)
def test_list_not_found(self): sgid = u'42' self.fake_client_set.compute.security_groups.get(sgid) \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get('/v1/fw-rule-sets/%s/rules/' % sgid) self.check_and_parse_response(rv, 404)
def test_remove_image_not_found(self): client = self.fake_client_set image_id = u'IID' client.image.images.get(image_id).AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.delete(u'/v1/images/%s' % image_id) self.check_and_parse_response(rv, status_code=404)
def test_remove_instance_not_found(self): s = self.server instances.fetch_instance(s.id).AndReturn(s) s.delete().AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact('/v1/instances/%s/remove' % s.id, {}, expected_status_code=404)
def test_vnc_late_not_found(self): s = self.server instances.fetch_instance(s.id).AndReturn(s) s.get_vnc_console(console_type='novnc')\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact('/v1/instances/%s/vnc' % s.id, {}, expected_status_code=404)
def test_fetch_not_found(self): users.auth.admin_client_set().AndReturn(self.admin_cs) self.admin_cs.identity_admin.users.get('UID') \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() with self.app.test_request_context(): self.install_fake_auth() self.assertAborts(404, users.fetch_user, 'UID', False)
def test_get_user_not_found(self): # prepare self.fake_client_set.identity_admin.users.get('user-a') \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() # test rv = self.client.get('/v1/users/user-a') # verify self.check_and_parse_response(rv, status_code=404)
def test_delete_network_not_found(self): # prepare self.fake_client_set.compute.networks.delete('net-a')\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() # test rv = self.client.delete('/v1/networks/net-a') # verify self.check_and_parse_response(rv, status_code=404)
def test_project_not_found(self): record = AuditRecord(project_id='PID', user_id=None) self.iadm.tenants.get('PID').AndRaise(osc_exc.NotFound('failure')) audit_log._record_to_dict(record, None, None)\ .AndReturn('REPLY') self.mox.ReplayAll() reply = audit_log.record_to_view(record) self.assertEquals('REPLY', reply)
def test_add_user_suddenly_removed(self): ia = self.fake_client_set.identity_admin ia.tenants.get(self.project_id).AndReturn(self.tenant) ia.users.get(self.user_id).AndReturn(self.user) ia.roles.list().AndReturn([ doubles.make(self.mox, doubles.Role, id=u'AR', name=u'admin'), doubles.make(self.mox, doubles.Role, id=u'MR', name=u'member') ]) self.tenant.add_user(self.user_id, u'MR') \ .AndRaise(osc_exc.NotFound('failure')) ia.users.get(self.user_id).AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() params = {'id': self.user_id} rv = self.client.post('/v1/projects/%s/users/' % self.project_id, content_type='application/json', data=json.dumps(params)) self.check_and_parse_response(rv, status_code=400)
def test_list_not_found(self): self.fake_client_set.compute.security_groups._list( '/servers/%s/os-security-groups' % self.server.id, 'security_groups') \ .AndRaise(osc_exc.HttpException('something happened')) self.fake_client_set.compute.servers.get(self.server.id) \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get('/v1/instances/%s/fw-rule-sets/' % self.server.id) self.check_and_parse_response(rv, status_code=404)
def test_remove_no_tenant(self): ia = self.fake_client_set.identity_admin ia.tenants.get(self.project_id) \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.delete('/v1/projects/%s/users/%s' % (self.project_id, self.user_id)) self.check_and_parse_response(rv, status_code=404)
def test_user_not_found(self): invites.InvitesDAO.get(self.code).AndReturn(self.token) invites.auth.admin_client_set() \ .AndReturn(self.fake_client_set) self.fake_client_set.identity_admin.users.get('UID')\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() rv = self.client.get('/v1/invites/%s' % self.code) self.check_and_parse_response(rv, status_code=404, authenticated=False)
def test_console_output_late_not_found(self): s = self.server instances.fetch_instance(s.id).AndReturn(s) s.get_console_output(length=None) \ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() self.interact('/v1/instances/%s/console-output' % s.id, {}, expected_status_code=404)
def test_drop_invite_late_not_found(self): invites.auth.admin_client_set() \ .AndReturn(self.fake_client_set) invites.InvitesDAO.get(self.code).AndReturn(self.token) user_mgr = self.fake_client_set.identity_admin.users user_mgr.get(self.user.id).AndReturn(self.user) self.user.delete()\ .AndRaise(osc_exc.NotFound('gone')) self.mox.ReplayAll() rv = self.client.delete('/v1/invites/%s' % self.code) self.check_and_parse_response(rv, status_code=404, authenticated=False)
def test_project_deletion_late_not_found(self): self.fake_client_set.identity_admin \ .tenants.get(self.tenant_id).AndReturn(self.tenant) projects._project_has_servers(self.tenant_id).AndReturn(False) projects._project_has_images(self.tenant_id).AndReturn(False) self.fake_client_set.compute.networks.list().AndReturn([]) self.tenant.delete().AndRaise(osc_exc.NotFound('deleted')) self.mox.ReplayAll() self.interact(expected_status_code=204)
def test_add_no_sg(self): compute = self.fake_client_set.compute compute.servers.get(self.server.id).AndReturn(self.server) compute.security_groups.get(self.sg_id)\ .AndRaise(osc_exc.NotFound('failure')) self.mox.ReplayAll() data = self.interact(expected_status_code=400) self.assertEquals('id', data.get('element-name')) self.assertEquals(self.sg_id, data.get('element-value'))
def test_fetch_user_error(self): users.auth.admin_client_set().AndReturn(self.admin_cs) self.admin_cs.identity_admin.users.get('UID').AndReturn(self.user) users.auth.current_user_id().AndReturn('ME') self.user.list_roles() \ .AndRaise(osc_exc.NotFound('gone')) self.mox.ReplayAll() with self.app.test_request_context(): self.install_fake_auth() self.assertAborts(404, users.fetch_user, 'UID', False)