def test_no_user(self):
     """
     Make sure nothing breaks if the user wasn't authenticated or was otherwise
     popped somewhere along the pipeline.
     """
     result = pipeline_set_user_roles({}, None)
     self.assertEqual(result, {})
Esempio n. 2
0
 def test_no_user(self):
     """
     Make sure nothing breaks if the user wasn't authenticated or was otherwise
     popped somewhere along the pipeline.
     """
     result = pipeline_set_user_roles({}, None)
     self.assertEqual(result, {})
 def test_admin_role_is_assigned(self):
     """
     Make sure the user is assigned the ADMINS role if the "administrator" claim
     is set to true.
     """
     self.assert_has_admin_role(False)
     result = pipeline_set_user_roles({"administrator": True}, self.user)
     self.assert_has_admin_role()
     self.assert_pipeline_result(result)
Esempio n. 4
0
 def test_admin_role_is_assigned(self):
     """
     Make sure the user is assigned the ADMINS role if the "administrator" claim
     is set to true.
     """
     self.assert_has_admin_role(False)
     result = pipeline_set_user_roles({"administrator": True}, self.user)
     self.assert_has_admin_role()
     self.assert_pipeline_result(result)
 def test_admin_role_is_unassigned(self, payload):
     """
     Make sure the user is unassigned from the ADMINS role, even if they previously
     had that role, if the "administrator" claim is not set to true.
     """
     self.user.groups.add(Group.objects.get(name=Role.ADMINS))  # pylint: disable=no-member
     self.assert_has_admin_role()
     result = pipeline_set_user_roles(payload, self.user)
     self.assert_has_admin_role(False)
     self.assert_pipeline_result(result)
Esempio n. 6
0
 def test_admin_role_is_unassigned(self, payload):
     """
     Make sure the user is unassigned from the ADMINS role, even if they previously
     had that role, if the "administrator" claim is not set to true.
     """
     self.user.groups.add(Group.objects.get(name=Role.ADMINS))
     self.assert_has_admin_role()
     result = pipeline_set_user_roles(payload, self.user)
     self.assert_has_admin_role(False)
     self.assert_pipeline_result(result)