def setUp(self):
     super(TenantTestCase, self).setUp()
     self.useFixture(database.Database())
     self.load_backends()
     self.load_fixtures(default_fixtures)
     self.tenant_controller = controllers.Tenant()
     self.role_controller = controllers.Role()
Esempio n. 2
0
    def test_get_project_users_no_user(self):
        """get_project_users when user doesn't exist, raises UserNotFound.

        When a user that's not known to `identity` has a role on a project,
        then `get_project_users` raises
        :class:`keystone.exception.UserNotFound`.

        """

        self.load_backends()
        self.load_fixtures(default_fixtures)
        tenant_controller = controllers.Tenant()
        role_controller = controllers.Role()

        # Assign a role to a user that doesn't exist to the `bar` project.

        project_id = self.tenant_bar['id']

        user_id = uuid.uuid4().hex
        role_controller.add_role_to_user(_ADMIN_CONTEXT, user_id,
                                         self.role_other['id'], project_id)

        self.assertRaisesRegexp(exception.UserNotFound,
                                'Could not find user, %s' % user_id,
                                tenant_controller.get_project_users,
                                _ADMIN_CONTEXT, project_id)
Esempio n. 3
0
    def add_routes(self, mapper):
        # Tenant Operations
        tenant_controller = controllers.Tenant()
        mapper.connect('/tenants',
                       controller=tenant_controller,
                       action='get_all_projects',
                       conditions=dict(method=['GET']))
        mapper.connect('/tenants/{tenant_id}',
                       controller=tenant_controller,
                       action='get_project',
                       conditions=dict(method=['GET']))

        # Role Operations
        roles_controller = controllers.Role()
        mapper.connect('/tenants/{tenant_id}/users/{user_id}/roles',
                       controller=roles_controller,
                       action='get_user_roles',
                       conditions=dict(method=['GET']))
        mapper.connect('/users/{user_id}/roles',
                       controller=roles_controller,
                       action='get_user_roles',
                       conditions=dict(method=['GET']))
Esempio n. 4
0
 def add_routes(self, mapper):
     tenant_controller = controllers.Tenant()
     mapper.connect('/tenants',
                    controller=tenant_controller,
                    action='get_projects_for_token',
                    conditions=dict(method=['GET']))