예제 #1
0
    def test_authenticate_failure(self, mock_urlopen):
        self.response.read.return_value = SAML_FAIL
        mock_urlopen.return_value = self.response

        w = SAMLAuthBackend()
        r = w.authenticate(
            "foo",
            url=("https://slank.ccnmtl.columbia.edu/accounts/"
                 "caslogin/?next=/"))
        self.assertEqual(r, None)
예제 #2
0
    def test_authenticate_success_with_mappers(self, mock_urlopen):
        self.response.read.return_value = saml_success_affils()
        mock_urlopen.return_value = self.response

        with self.settings(
                WIND_AFFIL_HANDLERS=['djangowind.auth.AffilGroupMapper']):
            w = SAMLAuthBackend()
            r = w.authenticate(
                "foo",
                url=("https://slank.ccnmtl.columbia.edu/accounts/"
                     "caslogin/?next=/"))
            self.assertEqual(r.username, "anp8")
            self.assertFalse(r.has_usable_password())
예제 #3
0
    def test_authenticate_success_existing_user(self, mock_urlopen):
        self.response.read.return_value = saml_success_affils()
        mock_urlopen.return_value = self.response

        u = User.objects.create(username="******")
        u.set_password("something other than unusable")
        u.save()
        w = SAMLAuthBackend()
        r = w.authenticate(
            "foo",
            url=("https://slank.ccnmtl.columbia.edu/accounts/"
                 "caslogin/?next=/"))
        self.assertEqual(r.username, "anp8")
        self.assertNotEqual(r.password, "!")
예제 #4
0
 def test_authenticate_no_ticket(self, mock_urlopen):
     w = SAMLAuthBackend()
     self.assertEqual(w.authenticate(None, None), None)