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 create_plan(self): self.plan = Plan(self.TEST_PLAN) res = self.plan.create() self.assertEqual(res.json()["success"], True) self.user = User(self.email) self.user.create() self.site = Site(self.target_url, plans=[self.plan.plan["name"]]) self.site.create() self.group = Group("testgroup", sites=[self.site.url], users=[self.user.email]) self.group.create()
def test_retrieve_issue_status_and_issues_by_group(self): # Don't be shock. This test fits here; by querying # user and group, we should only be given the latest # issue status. bob = User(self.email) bob.create() group1 = Group("group1", users=[bob.email]) group2 = Group("group2", users=[bob.email]) res1 = group1.create() res2 = group2.create() plan = Plan(self.TEST_PLAN) plan.create() site1 = Site(self.target_url, groups=[group1.group_name], plans=[self.TEST_PLAN["name"]]) site1.create() site2 = Site(self.target_url, groups=[group2.group_name], plans=[self.TEST_PLAN["name"]]) site2.create() # if we query just test1, should get back only foo.com report = Reports() res5 = report.get_status(user=bob.email, group_name=group1.group_name) r = res5.json()['report'] self.assertEqual( len(r), 1) # there should just be one dict returned in the list self.assertEqual(r[0]['target'], site1.url) # if we try it on get_report_issues we should see similar result res6 = report.get_issues(user=bob.email, group_name=group1.group_name) r = res6.json()['report'] self.assertEqual( len(r), 1) # there should just be one dict returned in the list self.assertEqual(r[0]['target'], site1.url)
def _create_plan(self, plan=None): """ Create a plan in Minion and assign a site to a group and a user. Use Plan(self.TEST_PLAN) to test plan only. """ _plan = plan or self.TEST_PLAN self.plan = Plan(_plan) resp = self.plan.create() self.user = User(self.email) self.user.create() self.site = Site(self.target_url, plans=[self.plan.plan["name"]]) self.site.create() self.group = Group("testgroup", sites=[self.site.url], users=[self.user.email]) self.group.create() self.plan = Plan(_plan) return resp
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])