예제 #1
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_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, {})
예제 #3
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_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)
예제 #5
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))  # 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)
 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)