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])
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])
def test_send_invite_with_groups_and_sites(self): sender = User(self.email, name="Bob") sender.create() recipient = User(self.random_email(), name="Alice") recipient.invite() # create the invitation invite = Invite(sender.email, recipient.email) res = invite.create() invite_id = res.json()['invite']['id'] # create a site in minion site = Site(self.target_url) res2 = site.create() site_id = res2.json()["site"]["id"] # Uncomment the following checks when #297 is resolved. # create a group in minion group = Group(self.group_name, sites=[site.url], users=[recipient.email]) res3 = group.create() # site should exists in group and recipient should also be in the same group res4 = group.get() self.assertEqual(res4.json()['group']['users'], [recipient.email,]) res5 = site.get(site_id) self.assertEqual(res5.json()["site"]["groups"], [group.group_name]) # finally, if we query recipient's user object, user should be in # the group and have access to a site. res6 = recipient.get() self.assertEqual(res6.json()["user"]["sites"], [site.url]) self.assertEqual(res6.json()["user"]["groups"], [group.group_name])
def test_delete_not_used_invitation(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]) # also, this user is still marked as "invited" self.assertEqual(res2.json()['user']['status'], 'invited') # admin deletes this invitation off minion res3 = invite.delete(invite_id) self.assertEqual(res3.json()["success"], True) # since invitation is gone, user should be gone too res4 = recipient.get() self.assertEqual(res4.json()['success'], False) self.assertEqual(res4.json()['reason'], 'no-such-user') # recipient is also gone from any group association 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_delete_not_used_invitation(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]) # also, this user is still marked as "invited" self.assertEqual(res2.json()['user']['status'], 'invited') # admin deletes this invitation off minion res3 = invite.delete(invite_id) self.assertEqual(res3.json()["success"], True) # since invitation is gone, user should be gone too res4 = recipient.get() self.assertEqual(res4.json()['success'], False) self.assertEqual(res4.json()['reason'], 'no-such-user') # recipient is also gone from any group association 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_get_group(self): bob = User(self.email) bob.create() group = Group(self.group_name) group.create() res = group.get() self.assertEqual(res.json()['group']['name'], group.group_name) self.assertEqual(res.json()['group']['description'], group.description)
def test_get_group(self): bob = User(self.email) bob.create() group = Group(self.group_name) group.create() res = group.get() self.assertEqual(res.json()['group']['name'], group.group_name) self.assertEqual(res.json()['group']['description'], group.description)
def test_delete_user_also_removes_group_membership(self): # Create a user and add it to a group bob = User(self.email) res = bob.create() self.assertEqual(res.json()['success'], True) group = Group(self.group_name, users=[bob.email]) res2 = group.create() self.assertEqual(res2.json()['success'], True) # Make sure the user is in the group res3 = group.get() self.assertEqual(res3.json()['group']['users'], [bob.email]) # Delete the user res4 = bob.delete() self.assertEqual(res4.json()["success"], True) # Make sure the user is not in the group anymore res5 = group.get() self.assertEqual(res5.json()['group']['users'], [])
def test_delete_user_also_removes_group_membership(self): # Create a user and add it to a group bob = User(self.email) res = bob.create() self.assertEqual(res.json()['success'], True) group = Group(self.group_name, users=[bob.email]) res2 = group.create() self.assertEqual(res2.json()['success'], True) # Make sure the user is in the group res3 = group.get() self.assertEqual(res3.json()['group']['users'], [bob.email]) # Delete the user res4 = bob.delete() self.assertEqual(res4.json()["success"], True) # Make sure the user is not in the group anymore res5 = group.get() self.assertEqual(res5.json()['group']['users'], [])
def test_get_group(self): user = User(self.email) user.create() group = Group(self.group_name, description=self.group_description, users=[user.email]) res1 = group.create() res2 = group.get() self.assertEqual(res2.json()["success"], True) self.assertEqual(res2.json()['group']['name'], group.group_name) self.assertEqual(res2.json()['group']['description'], group.description) self.assertEqual(res2.json()['group']['users'], [user.email])
def test_send_invite_with_groups_and_sites(self): sender = User(self.email, name="Bob") sender.create() recipient = User(self.random_email(), name="Alice") recipient.invite() # create the invitation invite = Invite(sender.email, recipient.email) res = invite.create() invite_id = res.json()['invite']['id'] # create a site in minion site = Site(self.target_url) res2 = site.create() site_id = res2.json()["site"]["id"] # Uncomment the following checks when #297 is resolved. # create a group in minion group = Group(self.group_name, sites=[site.url], users=[recipient.email]) res3 = group.create() # site should exists in group and recipient should also be in the same group res4 = group.get() self.assertEqual(res4.json()['group']['users'], [ recipient.email, ]) res5 = site.get(site_id) self.assertEqual(res5.json()["site"]["groups"], [group.group_name]) # finally, if we query recipient's user object, user should be in # the group and have access to a site. res6 = recipient.get() self.assertEqual(res6.json()["user"]["sites"], [site.url]) self.assertEqual(res6.json()["user"]["groups"], [group.group_name])