def test_authenticated_user(self):
        url = reverse(self.URL_NAME)
        request = RequestFactory().get(url)
        request.user = mixer.blend("auth.User", is_superuser=False, is_staff=False)
        response = views.custom_password_change(request)

        assert response.status_code == 200, "Should be callable"
Beispiel #2
0
    def test_anonymous_default(self):
        url = reverse(self.URL_NAME)
        request = RequestFactory().get(url)
        request.user = AnonymousUser()
        response = views.custom_password_change(request)

        assert response.status_code == 302, "Should redirect to login page"
        assert response.url == reverse("login") + "?next=" + url, \
            "Should contain a next parameter for redirect"
    def test_anonymous_default(self):
        url = reverse(self.URL_NAME)
        request = RequestFactory().get(url)
        request.user = AnonymousUser()
        response = views.custom_password_change(request)

        assert response.status_code == 302, "Should redirect to login page"
        assert response.url == reverse("login") + "?next=" + url, \
            "Should contain a next parameter for redirect"
    def test_authenticated_ldap_user(self, monkeypatch, settings):
        """LDAP users are not allowed to change there passwords, this must happen in the directory itself"""
        # mock the custom LDAP backend
        monkeypatch.setattr(context_processors, "LDAPBackend", LDAPBackendMock)

        # when using the LDAP integration, a custom LDAP backend exists for the user
        # if they are readable, the account is an LDAP account
        settings.LDAP_ENABLE = True

        url = reverse(self.URL_NAME)
        request = RequestFactory().get(url)
        request.user = mixer.blend("auth.User", is_superuser=False, is_staff=False)

        response = views.custom_password_change(request)

        assert response.status_code == 403