Exemplo n.º 1
0
    def test_decline_invite(self):
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # create a group in minion that includes the recipient (bug#175)
        group = Group(self.group_name, users=[recipient.email])
        group.create()

        # ensure now the recipient is part of the new group
        res2 = recipient.get()
        self.assertEqual(res2.json()['user']['groups'], [group.group_name])

        # recipient has declined the invitation
        res3 = invite.update(invite_id, "decline", login=recipient.email)
        self.assertEqual(res3.json()['invite']['status'], 'declined')

        # when recipient declined, user account is deleted (bug #175)
        res4 = recipient.get()
        self.assertEqual(res4.json()['success'], False)
        self.assertEqual(res4.json()['reason'], 'no-such-user')

        # when recipient declined, user is also not part of a group anymore (bug #175)
        res5 = group.get()
        self.assertEqual(res5.json()['group']['users'], [])
    def test_decline_invite(self):
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # create a group in minion that includes the recipient (bug#175)
        group = Group(self.group_name, users=[recipient.email])
        group.create()

        # ensure now the recipient is part of the new group
        res2 = recipient.get()
        self.assertEqual(res2.json()['user']['groups'], [group.group_name])

        # recipient has declined the invitation
        res3 = invite.update(invite_id, "decline", login=recipient.email)
        self.assertEqual(res3.json()['invite']['status'], 'declined')

        # when recipient declined, user account is deleted (bug #175)
        res4 = recipient.get()
        self.assertEqual(res4.json()['success'], False)
        self.assertEqual(res4.json()['reason'], 'no-such-user')

        # when recipient declined, user is also not part of a group anymore (bug #175)
        res5 = group.get()
        self.assertEqual(res5.json()['group']['users'], [])
    def test_accept_invite_with_a_different_login_email(self):
        # we allow recipient to login with a different email address.
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # create a group and a site and add the recipient to the group
        site = Site(self.target_url)
        res2 = site.create()

        # create a group in minion
        group = Group(self.group_name,
                      sites=[site.url],
                      users=[recipient.email])
        group.create()

        # ensure user and site are in this new group
        res3 = group.get()
        self.assertEqual(res3.json()["group"]["sites"], [site.url])
        self.assertEqual(res3.json()["group"]["users"], [recipient.email])

        # user should have access to the group and the site
        res4 = recipient.get()
        self.assertEqual(res4.json()["user"]["sites"], [site.url])
        self.assertEqual(res4.json()["user"]["groups"], [group.group_name])

        # recipient accepts the invitation with a different login email address
        actual_login = self.random_email()
        recipient_2 = User(actual_login)
        res5 = invite.update(invite_id, "accept", login=recipient_2.email)
        self.assertEqual(res5.json()["success"], True)

        # upon invitation acceptance, user status changed to active
        res6 = recipient_2.get()
        self.assertEqual(res6.json()['user']['email'], recipient_2.email)
        self.assertEqual(res6.json()['user']['status'], 'active')
        # the new email address has access to the group and site
        self.assertEqual(res6.json()["user"]["groups"], [group.group_name])
        self.assertEqual(res6.json()["user"]["sites"], [site.url])

        # if we query the old recipient email, it should not be found
        res7 = recipient.get()
        self.assertEqual(res7.json()["success"], False)
        self.assertEqual(res7.json()["reason"], "no-such-user")

        # group should agree that user and site are still member of the group
        res8 = group.get()
        self.assertEqual(res8.json()["group"]["sites"], [site.url])
        self.assertEqual(res8.json()["group"]["users"], [recipient_2.email])
Exemplo n.º 4
0
    def test_accept_invite_with_a_different_login_email(self):
        # we allow recipient to login with a different email address.
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # create a group and a site and add the recipient to the group
        site = Site(self.target_url)
        res2 = site.create()

        # create a group in minion
        group = Group(self.group_name, sites=[site.url], users=[recipient.email])
        group.create()

        # ensure user and site are in this new group
        res3 = group.get()
        self.assertEqual(res3.json()["group"]["sites"], [site.url])
        self.assertEqual(res3.json()["group"]["users"], [recipient.email])

        # user should have access to the group and the site
        res4 = recipient.get()
        self.assertEqual(res4.json()["user"]["sites"], [site.url])
        self.assertEqual(res4.json()["user"]["groups"], [group.group_name])

        # recipient accepts the invitation with a different login email address
        actual_login = self.random_email()
        recipient_2 = User(actual_login)
        res5 = invite.update(invite_id, "accept", login=recipient_2.email)
        self.assertEqual(res5.json()["success"], True)

        # upon invitation acceptance, user status changed to active
        res6 = recipient_2.get()
        self.assertEqual(res6.json()['user']['email'], recipient_2.email)
        self.assertEqual(res6.json()['user']['status'], 'active')
        # the new email address has access to the group and site
        self.assertEqual(res6.json()["user"]["groups"], [group.group_name])
        self.assertEqual(res6.json()["user"]["sites"], [site.url])

        # if we query the old recipient email, it should not be found
        res7 = recipient.get()
        self.assertEqual(res7.json()["success"], False)
        self.assertEqual(res7.json()["reason"], "no-such-user")

        # group should agree that user and site are still member of the group
        res8 = group.get()
        self.assertEqual(res8.json()["group"]["sites"], [site.url])
        self.assertEqual(res8.json()["group"]["users"], [recipient_2.email])
Exemplo n.º 5
0
    def test_resend_invite(self):
        recipient = User(self.random_email())
        recipient.invite()

        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        self.assertEqual(res1.json()["success"], True)
        old_invite_id = res1.json()["invite"]["id"]

        # resent invitation to recipient should produce a new invitiation id
        res2 = invite.update(old_invite_id, "resend", login=recipient.email)
        self.assertNotEqual(res2.json()['invite']['id'], old_invite_id)
    def test_resend_invite(self):
        recipient = User(self.random_email())
        recipient.invite()

        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)
        res1 = invite.create()
        self.assertEqual(res1.json()["success"], True)
        old_invite_id = res1.json()["invite"]["id"]

        # resent invitation to recipient should produce a new invitiation id
        res2 = invite.update(old_invite_id, "resend", login=recipient.email)
        self.assertNotEqual(res2.json()['invite']['id'], old_invite_id)
Exemplo n.º 7
0
    def test_delete_invite_does_not_delete_accepted_user(self):
        # Delete recipient's invite does not delete the user if
        # recipient has already accepted the invitation.
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)

        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # accept the invitation with the same invitation email
        res2 = invite.update(invite_id, "accept", login=recipient.email)
        self.assertEqual(res2.json()["success"], True)

        # upon invitation acceptance, user status changed to active
        res3 = recipient.get()        
        self.assertEqual(res3.json()['user']['email'], recipient.email)
        self.assertEqual(res3.json()['user']['status'], 'active')

        # now admin chooses to delete the invitation
        res4 = invite.delete(invite_id)
        self.assertEqual(res4.json()["success"], True)

        # check invitation is gone
        res5 = invite.get(invite_id)
        self.assertEqual(res5.json()['success'], False)
        self.assertEqual(res5.json()['reason'], 'invitation-does-not-exist')

        # yet, the user is still present
        res6 = recipient.get()
        self.assertEqual(res6.json()['success'], True)
        self.assertEqual(res6.json()['user']['email'], recipient.email)
        self.assertEqual(res6.json()['user']['status'], 'active')
    def test_delete_invite_does_not_delete_accepted_user(self):
        # Delete recipient's invite does not delete the user if
        # recipient has already accepted the invitation.
        recipient = User(self.random_email())
        recipient.invite()
        sender = User(self.random_email())
        sender.create()

        invite = Invite(sender.email, recipient.email)

        res1 = invite.create()
        invite_id = res1.json()["invite"]["id"]

        # accept the invitation with the same invitation email
        res2 = invite.update(invite_id, "accept", login=recipient.email)
        self.assertEqual(res2.json()["success"], True)

        # upon invitation acceptance, user status changed to active
        res3 = recipient.get()
        self.assertEqual(res3.json()['user']['email'], recipient.email)
        self.assertEqual(res3.json()['user']['status'], 'active')

        # now admin chooses to delete the invitation
        res4 = invite.delete(invite_id)
        self.assertEqual(res4.json()["success"], True)

        # check invitation is gone
        res5 = invite.get(invite_id)
        self.assertEqual(res5.json()['success'], False)
        self.assertEqual(res5.json()['reason'], 'invitation-does-not-exist')

        # yet, the user is still present
        res6 = recipient.get()
        self.assertEqual(res6.json()['success'], True)
        self.assertEqual(res6.json()['user']['email'], recipient.email)
        self.assertEqual(res6.json()['user']['status'], 'active')