def another_org_user(self, context, another_org):
     step("Add users to the organization")
     User.create_by_adding_to_organization(context=context,
                                           org_guid=another_org.guid,
                                           role=User.ORG_ROLE["admin"])
     return User.create_by_adding_to_organization(
         context=context,
         org_guid=another_org.guid,
         role=User.ORG_ROLE["user"])
Exemplo n.º 2
0
    def test_non_admin_user_cannot_invite_another_user(self, context,
                                                       test_org):
        """
        <b>Description:</b>
        Checks if non-admin user cannot invite other user.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when non-admin user receives access denied reply on adding other user attempt and the user doesn't
        obtain an invitation.

        <b>Steps:</b>
        1. Create a test user.
        2. Check an error is returned when non-admin tries to onboard another user.
        """
        step("Create a test user")
        user = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=User.ORG_ROLE["user"])
        non_admin_user_client = user.login()
        step(
            "Check an error is returned when non-admin tries to onboard another user"
        )
        username = generate_test_object_name(email=True)
        assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                     HttpStatus.MSG_ACCESS_IS_DENIED,
                                     Invitation.api_send,
                                     context,
                                     username=username,
                                     inviting_client=non_admin_user_client)
        self._assert_user_received_messages(username, 0)
Exemplo n.º 3
0
    def test_remove_user(self, context, test_org):
        """ Validate if user is properly removed from organization and from HDFS

            Create user, check that user is synchronized. Then remove user from organization and check that user is
            deleted from there. After remove check that user is not removed in auth-gateway.

            Input data:
                organization: organization wherein will be new user
                user name: name for new user

            Expected results:
                It is possible to create new user by adding to organization and remove by deleting from organization.
                User removed from organization is not in auth-gateway.

            Steps:
                1. Create new user
                2. Admin removes user from organization
                3. Check that the user is removed from organization
                4. Check that the user is removed in auth-gateway
        """
        step("Create new user")
        user_to_delete = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=User.ORG_ROLE["user"])
        removed_user_guid = user_to_delete.guid
        step("Admin removes the user from the test org")
        user_to_delete.delete_from_organization(org_guid=test_org.guid)
        step("Check that the user is not in the organization.")
        assert_user_not_in_org(user_to_delete, test_org.guid)

        user = next((u for u in AuthGatewayOrganization.get_org_state(
            org_guid=test_org.guid).users if u.guid == removed_user_guid),
                    None)
        assert user is None, "User was not removed in auth-gateway"
Exemplo n.º 4
0
    def test_platform_admin_adds_new_user_in_org_where_they_are_not_added(
            self, context, admin_user, test_org, test_case,
            add_user_test_cases, remove_admin_from_test_org):
        """
        <b>Description:</b>
        Checks if platform admin can add a user to the organization.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when non-admin cannot get user's list.

        <b>Steps:</b>
        1. Create new user by adding them to an organization with user role.
        2. Check that the user was added with user role.
        """
        # TODO change test case to use test_org_admin_client instead of default client - when DPNG-10987 is done
        role_sent = add_user_test_cases[test_case]["sent"]
        role_expected = add_user_test_cases[test_case]["expected"]
        step(
            "Create new user by adding them to an organization with user role")
        new_user = User.create_by_adding_to_organization(
            context=context, org_guid=test_org.guid, role=role_sent)
        step("Check that the user was added with user role")
        assert_user_in_org_and_role(new_user, test_org.guid, role_expected)
Exemplo n.º 5
0
    def test_add_new_user_with_no_roles(self, context, test_org, test_case,
                                        add_user_test_cases):
        """
        <b>Description:</b>
        Checks if user with admin, non-admin and no role can be added.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when user with admin, non-admin and no role was added.

        <b>Steps:</b>
        1. Create new user by adding to an organization with a role.
        2. Check that the user was added with the role.
        """
        # TODO change test case to use test_org_admin_client instead of default client - when DPNG-10987 is done
        role_sent = add_user_test_cases[test_case]["sent"]
        role_expected = add_user_test_cases[test_case]["expected"]
        step(
            "Create new user by adding to an organization with role {}".format(
                role_sent))
        user = User.create_by_adding_to_organization(context=context,
                                                     org_guid=test_org.guid,
                                                     role=role_sent)
        step(
            "Check that the user was added with role {}".format(role_expected))
        assert_user_in_org_and_role(user, test_org.guid, role_expected)
Exemplo n.º 6
0
    def test_org_admin_adds_new_user(self, context, test_org,
                                     test_org_admin_client):
        """
        <b>Description:</b>
        Checks if organization admin can add new user.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when organization admin successfully adds new user.

        <b>Steps:</b>
        1. Org admin adds a new user to an organization.
        2. Check that the user was added correctly.
        """
        step("Org admin adds a new user to an organization")
        expected_role = User.ORG_ROLE["user"]
        user = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=expected_role,
            inviting_client=test_org_admin_client)
        step("Check that the user was added correctly")
        assert_user_in_org_and_role(user, test_org.guid, expected_role)
 def update_test_cases(self, class_context, test_org):
     step("Create users to be updated")
     roles_to_update = {
         "admin_to_user": {
             "before": User.ORG_ROLE["admin"],
             "after": User.ORG_ROLE["user"],
             "expected": User.ORG_ROLE["user"]
         },
         "user_to_admin": {
             "before": User.ORG_ROLE["user"],
             "after": User.ORG_ROLE["admin"],
             "expected": User.ORG_ROLE["admin"]
         },
     }
     for key, val in roles_to_update.items():
         val["user"] = User.create_by_adding_to_organization(
             context=class_context,
             org_guid=test_org.guid,
             role=val["before"])
     return roles_to_update
Exemplo n.º 8
0
    def test_add_user(self, test_org, context):
        """ Verify if user data are properly saved in HDFS while creating user and uploading data file to TAP.

            After create user test verifies that user is synchronized. Then login to platform as new user.
            Create transfer to HDFS and check that transfer is completed.

            Input data:
                user name: name for new user
                data file: file which is transferred to HDFS
                organization: organization wherein will be new user

            Expected results:
               It is possible to create new user and login to platform as new user. New user is able to create
               transfer to HDFS. User data are properly saved on HDFS.

            Steps:
                1. Create new user
                2. Check that user is created completely
                3. Login as new registered user
                4. Check that the user is able to create a transfer
                5. Ensure that transfer is completed successfully
        """
        step("Create new user")
        user = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=User.ORG_ROLE["user"])
        step("Check that user was synchronized")
        ag_user = AuthGatewayUser.get_user_state(org_guid=test_org.guid,
                                                 user_id=user.guid)
        assert ag_user.is_synchronized, "User {} was not synchronized".format(
            user.username)
        step("Login new registered user")
        client = user.login()
        step("Check that the user is able to create a transfer")
        transfer = Transfer.api_create_by_file_upload(
            context,
            test_org.guid,
            file_utils.generate_csv_file(),
            client=client)
        transfer.ensure_finished()
    def test_non_admin_cannot_access_platform_operations(self, context, test_org):
        """
        <b>Description:</b>
        Checks if non-admin user cannot reach summary operations page /app/platformdashboard/summary.

        <b>Input data:</b>
        1. User email.

        <b>Expected results:</b>
        Test passes when non-admin user was not able to reach summary operations page.

        <b>Steps:</b>
        1. Create non-admin user.
        2. Verify that the user cannot reach summary operations page.
        """
        step("Create non-admin user")
        test_user = User.create_by_adding_to_organization(context=context, org_guid=test_org.guid)
        client = test_user.login(rest_prefix="")
        step("Checking if non-admin user cannot request admin-only data")
        assertions.assert_raises_http_exception(HttpStatus.CODE_UNAUTHORIZED, HttpStatus.MSG_UNAUTHORIZED,
                                                client.request, method=HttpMethod.GET, url=console_url,
                                                path=self.PLATFORM_SUMMARY_PATH)
Exemplo n.º 10
0
 def user(cls, test_org, class_context):
     step("Create test user")
     cls._test_user = User.create_by_adding_to_organization(
         context=class_context, org_guid=test_org.guid)
 def existing_user(self, context, test_org):
     step("Create test user in test org")
     return User.create_by_adding_to_organization(context=context,
                                                  org_guid=test_org.guid)
Exemplo n.º 12
0
def test_org_admin(request, session_context, test_org):
    log_fixture("test_org_user: Add admin to test org")
    return User.create_by_adding_to_organization(context=session_context, org_guid=test_org.guid,
                                                 role=User.ORG_ROLE["admin"])
 def user(self, request, test_org, context):
     step("Create test user")
     self.test_user = User.create_by_adding_to_organization(
         context=context, org_guid=test_org.guid)
 def user_to_delete(self, context, test_org):
     step("Create user to be deleted")
     return User.create_by_adding_to_organization(
         context=context,
         org_guid=test_org.guid,
         role=User.ORG_ROLE["user"])