def test_user_cannot_register_without_password(self, context, test_org): """ <b>Description:</b> Checks if the user registration without password fails. <b>Input data:</b> 1. Email address. <b>Expected results:</b> Test passes when 400 Bad request HTTP status is returned on attempt of user registration without password and the user is not created. <b>Steps:</b> 1. Invite a user. 2. Check that an error is returned when the user tries to register without a password. 3. Check that the user was not created. """ step("Invite a new user") invitation = Invitation.api_send(context) step( "Check that an error is returned when the user tries to register without a password" ) assert_raises_http_exception(HttpStatus.CODE_BAD_REQUEST, HttpStatus.MSG_PASSWORD_CANNOT_BE_EMPTY, user_management.api_register_new_user, code=invitation.code, org_name=generate_test_object_name()) step("Check that the user was not created") username_list = [ user.username for user in User.get_all_users(test_org.guid) ] assert invitation.username not in username_list, "User was created"
def test_onboarding(context, test_org): """ <b>Description:</b> Checks if user can be added to the platform with onboarding functionality. <b>Input data:</b> 1. User email. <b>Expected results:</b> Test passes when user was successfully added to the platform with onboading functionality. <b>Steps:</b> 1. Onboard new user to the platform. 2. Get list of all users on the platform. 3. Verify that the user is present on the platform. """ step("Onboard new user") username = generate_test_object_name(email=True, separator="") test_user = onboarding.onboard(context=context, org_guid=test_org.guid, username=username, check_email=False) step("Check that user is created") users = User.get_all_users(test_org.guid) assert test_user in users
def test_user_cannot_register_with_no_organization_name(self, context): step("Invite a new user") invitation = Invitation.api_send(context) step( "Check that an error is returned when user registers without passing an org name" ) assert_raises_http_exception( HttpStatus.CODE_BAD_REQUEST, HttpStatus.MSG_ORGANIZATION_CANNOT_CONTAIN_ONLY_WHITESPACES, user_management.api_register_new_user, code=invitation.code, password=User.generate_password()) step("Check that the user was not created") username_list = [user.username for user in User.get_all_users()] assert invitation.username not in username_list, "User was created"
def create_users(): logger.info('Create users') names = [TapObjectName(prefix='perf_user').as_email() for _ in range(config.num_clients)] for name in names: onboarding.onboard(context=PERFORMANCE_CONTEXT, username=name, password=config.admin_password, org_guid=CORE_ORG.guid, check_email=False) usernames_on_platform = (user.username for user in User.get_all_users(CORE_ORG.guid)) assert set(names).issubset(set(usernames_on_platform)), 'Failed to create required number of users' os.environ['PT_PERF_USER_NAMES'] = ' '.join(names)
def from_reference(cls, org_guid): from modules.tap_object_model import Application, User, Organization, ServiceOffering, ServiceInstance, DataSet metrics = [] app_down_states = [TapEntityState.FAILURE, TapEntityState.STOPPED] apps = Application.get_list() apps_count = len(apps) apps_running_count = len( [app for app in apps if app.state == TapEntityState.RUNNING]) apps_down_count = len( [app for app in apps if app.state in app_down_states]) user_count = len(User.get_all_users(org_guid)) orgs_count = len(Organization.get_list()) services_count = len(ServiceOffering.get_list()) services_inst = len([ instance for instance in ServiceInstance.get_list() if instance.state == TapEntityState.RUNNING ]) nodes = KubernetesNode.get_list() for node in nodes: metrics.append(node.get_metrics()) cpu_usage_org = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF * cls.NODE) cpu_usage_platform = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF * cls.NODE) memory_usage_org = cls.parse_memory(metrics) memory_usage_platform = cls.parse_memory(metrics) datasets = DataSet.api_get_list(org_guid_list=[org_guid]) return cls(apps=apps_count, apps_running=apps_running_count, apps_down=apps_down_count, users_org=user_count, users_platform=user_count, orgs=orgs_count, services=services_count, service_instances=services_inst, service_usage=services_inst, cpu_usage_org=cpu_usage_org, memory_usage_org=memory_usage_org, cpu_usage_platform=cpu_usage_platform, memory_usage_platform=memory_usage_platform, datasets=datasets)
def test_user_cannot_register_already_existing_organization( self, context, test_org): step("Invite a new user") invitation = Invitation.api_send(context) step( "Check that an error is returned when the user registers with an already-existing org name" ) assert_raises_http_exception( HttpStatus.CODE_CONFLICT, HttpStatus.MSG_ORGANIZATION_ALREADY_EXISTS.format(test_org.name), onboarding.register, context=context, code=invitation.code, username=invitation.username, org_name=test_org.name) step("Check that the user was not created") username_list = [user.username for user in User.get_all_users()] assert invitation.username not in username_list, "User was created"