def non_space_developer_users(cls, request, test_org, test_space, class_context): cls.step("Create space auditor") space_auditor = User.api_create_by_adding_to_space( class_context, test_org.guid, test_space.guid, roles=User.SPACE_ROLES["auditor"]) cls.space_auditor_client = space_auditor.login() cls.step("Create space manager client") space_manager = User.api_create_by_adding_to_space( class_context, test_org.guid, test_space.guid, roles=User.SPACE_ROLES["manager"]) cls.space_manager_client = space_manager.login()
def space_developer_user(cls, test_org, test_space, class_context): cls.step("Create space developer client") space_developer_user = User.api_create_by_adding_to_space( class_context, test_org.guid, test_space.guid, roles=User.SPACE_ROLES["developer"]) cls.space_developer_client = space_developer_user.login()
def _get_test_user(self, org_guid, space_guid, space_role=User.ORG_ROLES["manager"]): user = User.api_create_by_adding_to_space(self.context, org_guid, space_guid, roles=space_role) return user
def test_cannot_create_user_with_existing_username(self): test_user = User.api_create_by_adding_to_space(self.context, self.test_org.guid, self.test_space.guid) self.assertRaisesUnexpectedResponse(HttpStatus.CODE_FORBIDDEN, HttpStatus.MSG_EMPTY, User.api_create_by_adding_to_space, self.context, self.test_org.guid, self.test_space.guid, username=test_user.username)
def test_send_space_role_update_request_with_empty_body(self): self.step("Create new platform user by adding to the space") test_user = User.api_create_by_adding_to_space( self.context, org_guid=test_data.TestData.test_org.guid, space_guid=self.test_space.guid) self.step("Send request with empty body") self.assertRaisesUnexpectedResponse( HttpStatus.CODE_CONFLICT, HttpStatus.MSG_MUST_HAVE_AT_LEAST_ONE_ROLE, user_management.api_update_space_user_roles, self.test_space.guid, test_user.guid) self._assert_user_in_space_with_roles(test_user, self.test_space.guid)
def test_get_user_list(self, client, is_authorized): test_user = User.api_create_by_adding_to_space( self.context, TestData.test_org.guid, TestData.test_space.guid) step("Try to get user list from space by using every client type.") if is_authorized: user_list = User.api_get_list_via_space( TestData.test_space.guid, client=self.user_clients[client]) assert test_user in user_list, "User {} was not found in list".format( test_user) else: assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN, HttpStatus.MSG_FORBIDDEN, User.api_get_list_via_space, TestData.test_space.guid, client=self.user_clients[client])
def space_users_clients(request, test_org, test_space, admin_client): context = Context() log_fixture("clients: Create clients") clients = {} for role, value in User.SPACE_ROLES.items(): clients[role] = User.api_create_by_adding_to_space( context, org_guid=test_org.guid, space_guid=test_space.guid, roles=value).login() clients["admin"] = admin_client def fin(): log_finalizer("clients: Delete test users") context.cleanup() request.addfinalizer(fin) return clients
def user_clients(cls, request, test_org, test_space, class_context): cls.context = class_context # TODO move to methods when dependency on unittest is removed second_test_org = Organization.api_create(class_context) org_manager = User.api_create_by_adding_to_organization( class_context, test_org.guid) space_manager_in_org = User.api_create_by_adding_to_space( class_context, test_org.guid, test_space.guid) org_user = User.api_create_by_adding_to_organization( class_context, test_org.guid, roles=User.ORG_ROLES["auditor"]) other_org_manager = User.api_create_by_adding_to_organization( class_context, second_test_org.guid) other_user = User.api_create_by_adding_to_organization( class_context, second_test_org.guid, roles=[]) cls.user_clients = { "admin": HttpClientFactory.get(ConsoleConfigurationProvider.get()), "org_manager": org_manager.login(), "space_manager_in_org": space_manager_in_org.login(), "org_user": org_user.login(), "other_org_manager": other_org_manager.login(), "other_user": other_user.login() }
def test_add_new_user(self, client, is_authorized): step("Try to add new user with each client type.") user_list = User.api_get_list_via_space(TestData.test_space.guid) if is_authorized: test_user = User.api_create_by_adding_to_space( self.context, TestData.test_org.guid, TestData.test_space.guid, inviting_client=self.user_clients[client]) self._assert_user_in_space_with_roles(test_user, TestData.test_space.guid) else: assert_raises_http_exception( HttpStatus.CODE_FORBIDDEN, HttpStatus.MSG_FORBIDDEN, User.api_create_by_adding_to_space, self.context, TestData.test_org.guid, TestData.test_space.guid, inviting_client=self.user_clients[client]) assert User.api_get_list_via_space( TestData.test_space.guid) == user_list, "User was added"