Ejemplo n.º 1
0
 def test_accepting_invitation_deletes_it_from_pending_list(self):
     self.step("Invite new user")
     invitation = Invitation.api_send(self.context)
     self.step("Register user with the received code")
     onboarding.register(self.context, code=invitation.code, username=invitation.username)
     self.step("Check that invitation is no longer present in pending invitation list")
     self.assertNotInWithRetry(invitation, Invitation.api_get_list)
Ejemplo n.º 2
0
 def register(cls, context, *, org_guid, tap_cli, username):
     code = gmail_api.get_invitation_code_for_user(username)
     onboarding.register(context=context, code=code,
                         username=username, org_guid=org_guid)
     cli_user = cls(tap_cli=tap_cli, username=username)
     context.test_objects.append(cli_user)
     return cli_user
    def test_accepting_invitation_deletes_it_from_pending_list(
            self, context, test_org):
        """
        <b>Description:</b>
        Checks if invitation is removed from pending invitations list after invitation acceptance.

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

        <b>Expected results:</b>
        Test passes when pending invitation is not present on pending invitations list after invitation acceptance.

        <b>Steps:</b>
        1. Invite new user.
        2. Register user with the received code.
        3. Check that invitation is no longer present in pending invitation list.
        """
        step("Invite new user")
        invitation = Invitation.api_send(context)
        step("Register user with the received code")
        onboarding.register(context=context,
                            org_guid=test_org.guid,
                            code=invitation.code,
                            username=invitation.username)
        step(
            "Check that invitation is no longer present in pending invitation list"
        )
        assert_not_in_with_retry(invitation, Invitation.api_get_list)
Ejemplo n.º 4
0
    def test_simple_onboarding(self, context, test_org):
        """
        <b>Description:</b>
        Checks if onboarding functionality works.

        <b>Input data:</b>
        1. Email address.

        <b>Expected results:</b>
        Test passes when exactly one invitation was sent to the user; content, subject and sender of invitation are
        correct and user was correctly added to the organization with appropriate role.

        <b>Steps:</b>
        1. Invite new user.
        2. Register the new user.
        3. Check that the user and their organization exist.
        """
        step("Send an invite to a new user")
        invitation = Invitation.api_send(context)
        messages = gmail_api.wait_for_messages_to(
            recipient=invitation.username, messages_number=1)
        assert len(
            messages
        ) == 1, "There are {} messages for the user. Expected: 1".format(
            len(messages))
        message = messages[0]
        self._assert_message_correct(message["subject"], message["content"],
                                     message["sender"])
        step("Register the new user")
        user = onboarding.register(context=context,
                                   org_guid=test_org.guid,
                                   code=invitation.code,
                                   username=invitation.username)
        step("Check that the user and their organization exist")
        assert_user_in_org_and_role(user, test_org.guid, User.ORG_ROLE["user"])
Ejemplo n.º 5
0
 def test_resend_pending_invitation(self):
     self.step("Invite new user")
     invitation = Invitation.api_send(self.context)
     self.step("Check that the user received the message")
     messages = gmail_api.wait_for_messages_to(recipient=invitation.username, messages_number=1)
     self.assertEqual(len(messages), 1)
     self.step("Resend invitation")
     invitation.api_resend()
     self.step("Check that the user received the new message")
     messages = gmail_api.wait_for_messages_to(recipient=invitation.username, messages_number=2)
     self.assertEqual(len(messages), 2)
     self.step("Register user with the received code")
     user, org = onboarding.register(self.context, code=invitation.code, username=invitation.username)
     self.assert_user_in_org_and_roles(user, org.guid, User.ORG_ROLES["manager"])
Ejemplo n.º 6
0
    def test_cannot_use_the_same_activation_code_twice(self, context,
                                                       test_org):
        """
        <b>Description:</b>
        Checks if the same activation code cannot be used twice.

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

        <b>Expected results:</b>
        Test passes when 403 Forbidden HTTP status is returned on attempt of registering a user twice with the same
        code.

        <b>Steps:</b>
        1. Invite a user.
        2. The new user registers.
        3. Check that error is returned when the user tries to use code twice.
        """
        step("Invite a user")
        invitation = Invitation.api_send(context)
        step("The new user registers")
        onboarding.register(context=context,
                            org_guid=test_org.guid,
                            code=invitation.code,
                            username=invitation.username)
        step(
            "Check that error is returned when the user tries to use code twice"
        )
        assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                     HttpStatus.MSG_EMPTY,
                                     onboarding.register,
                                     context=context,
                                     org_guid=test_org.guid,
                                     code=invitation.code,
                                     username=invitation.username)
Ejemplo n.º 7
0
    def test_use_invitation_after_pod_restart(self, context, test_org):
        """
        <b>Description:</b>
        Checks if user invitation is valid after user-management POD restart.

        <b>Input data:</b>
        1. User name.
        2. Password.

        <b>Expected results:</b>
        Test passes when user was correctly added to the platform.

        <b>Steps:</b>
        1. Invite new user.
        2. Retrieve user-management POD
        2. Restart user-management POD, verify health.
        3. Register user with the invitation.
        """

        step("Invite new user")
        invitation = Invitation.api_send(context)

        step("Retrieve user-management pod")
        pods_list = KubernetesPod.get_list()
        user_mngt_pod = next((pod for pod in pods_list
                              if pod.name.startswith(self.POD_NAME_PREFIX)),
                             None)
        assert user_mngt_pod is not None, \
            "POD {} wasn't found on the PODs list".format(self.POD_NAME_PREFIX)

        step("Restart user-management POD, verify health")
        user_mngt_pod.restart_pod()
        user_mngt_pod.ensure_pod_in_good_health()

        step("Register user with the invitation")
        user = onboarding.register(context=context,
                                   org_guid=test_org.guid,
                                   code=invitation.code,
                                   username=invitation.username)
        assert_user_in_org_and_role(user, test_org.guid, User.ORG_ROLE["user"])
    def test_resend_pending_invitation(self, context, test_org):
        """
        <b>Description:</b>
        Checks if resending emails works.

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

        <b>Expected results:</b>
        Test passes when user obtained email with invitation and second email with invitation after it's resent.

        <b>Steps:</b>
        1. Invite new user.
        2. Check that the user received the message.
        3. Resend invitation.
        4. Check that the user received the new message.
        5. Register user with the received code.
        """
        step("Invite new user")
        invitation = Invitation.api_send(context)
        step("Check that the user received the message")
        messages = gmail_api.wait_for_messages_to(
            recipient=invitation.username, messages_number=1)
        assert len(messages) == 1
        step("Resend invitation")
        invitation.api_resend()
        step("Check that the user received the new message")
        messages = gmail_api.wait_for_messages_to(
            recipient=invitation.username, messages_number=2)
        assert len(messages) == 2
        step("Register user with the received code")
        user = onboarding.register(context=context,
                                   org_guid=test_org.guid,
                                   code=invitation.code,
                                   username=invitation.username)
        assert_user_in_org_and_role(user, test_org.guid, User.ORG_ROLE["user"])