def test_no_staff_authorization(self): """ Tests correct authorization when staff can not masquerade. """ self.assertEqual(masquerading_authorized(self.user, self.user), False) self.assertEqual(masquerading_authorized(self.user, self.staff_user), False) self.assertEqual(masquerading_authorized(self.user, self.superuser), False) self.assertEqual(masquerading_authorized(self.staff_user, self.user), False) self.assertEqual(masquerading_authorized(self.staff_user, self.staff_user), False) self.assertEqual(masquerading_authorized(self.staff_user, self.superuser), False) self.assertEqual(masquerading_authorized(self.superuser, self.user), True) self.assertEqual(masquerading_authorized(self.superuser, self.staff_user), True) self.assertEqual(masquerading_authorized(self.superuser, self.superuser), False)
def test_default_authorization(self): """ Tests that the correct authorization is given with the default settings. For default settings, HIJACK_AUTHORIZE_STAFF = True, HIJACK_AUTHORIZE_STAFF_TO_HIJACK_STAFF = False. """ self.assertEqual(masquerading_authorized(self.user, self.user), False) self.assertEqual(masquerading_authorized(self.user, self.staff_user), False) self.assertEqual(masquerading_authorized(self.user, self.superuser), False) self.assertEqual(masquerading_authorized(self.staff_user, self.user), True) self.assertEqual(masquerading_authorized(self.staff_user, self.staff_user), False) self.assertEqual(masquerading_authorized(self.staff_user, self.superuser), False) self.assertEqual(masquerading_authorized(self.superuser, self.user), True) self.assertEqual(masquerading_authorized(self.superuser, self.staff_user), True) self.assertEqual(masquerading_authorized(self.superuser, self.superuser), False)