Update auth urls in tests

This commit is contained in:
Martin Pépin 2020-09-17 21:36:53 +02:00
parent 7b8d1575c0
commit 0815f79739
No known key found for this signature in database
GPG key ID: E7520278B1774448
6 changed files with 22 additions and 14 deletions

View file

@ -31,7 +31,7 @@ app_dict = {
"bda": "gestion/bda/", "bda": "gestion/bda/",
"petitscours": "gestion/petitcours/", "petitscours": "gestion/petitcours/",
"events": "gestion/event_v2/", # the events module is still experimental ! "events": "gestion/event_v2/", # the events module is still experimental !
"authens": "gestion/authens/", "authens": "gestion/auth/",
} }
for (app_name, url_prefix) in app_dict.items(): for (app_name, url_prefix) in app_dict.items():
if app_name in settings.INSTALLED_APPS: if app_name in settings.INSTALLED_APPS:

View file

@ -168,7 +168,9 @@ class GenericLoginViewTests(TestCase):
r = self.client.post(self.url) r = self.client.post(self.url)
self.assertRedirects( self.assertRedirects(
r, "/gestion/logout?next={}".format(self.url), fetch_redirect_response=False r,
"/gestion/auth/logout?next={}".format(self.url),
fetch_redirect_response=False,
) )
def test_notoken_not_team(self): def test_notoken_not_team(self):
@ -180,13 +182,17 @@ class GenericLoginViewTests(TestCase):
# With GET. # With GET.
r = self.client.get(self.url) r = self.client.get(self.url)
self.assertRedirects( self.assertRedirects(
r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False r,
"/gestion/auth/login/choose?next={}".format(self.url),
fetch_redirect_response=False,
) )
# Also with POST. # Also with POST.
r = self.client.post(self.url) r = self.client.post(self.url)
self.assertRedirects( self.assertRedirects(
r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False r,
"/gestion/auth/login/choose?next={}".format(self.url),
fetch_redirect_response=False,
) )
def _set_signed_cookie(self, client, key, value): def _set_signed_cookie(self, client, key, value):

View file

@ -61,7 +61,7 @@ class TestStats(TestCase):
self.assertEqual(404, resp2.status_code) self.assertEqual(404, resp2.status_code)
# 2. FOO is a member of the team and can get these pages but BAR # 2. FOO is a member of the team and can get these pages but BAR
# receives a Redirect response # receives a 403 response
articles_urls = [ articles_urls = [
"/k-fet/articles/{}/stat/sales/list".format(article.pk), "/k-fet/articles/{}/stat/sales/list".format(article.pk),
"/k-fet/articles/{}/stat/sales?{}".format( "/k-fet/articles/{}/stat/sales?{}".format(
@ -80,4 +80,4 @@ class TestStats(TestCase):
resp = client.get(url) resp = client.get(url)
self.assertEqual(200, resp.status_code) self.assertEqual(200, resp.status_code)
resp2 = client2.get(url, follow=True) resp2 = client2.get(url, follow=True)
self.assertRedirects(resp2, "/gestion/") self.assertEqual(403, resp2.status_code)

View file

@ -232,7 +232,7 @@ class AccountReadViewTests(ViewTestCaseMixin, TestCase):
response = client.get(url) response = client.get(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:
@ -344,7 +344,7 @@ class AccountUpdateViewTests(ViewTestCaseMixin, TestCase):
response = meth(url) response = meth(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:
@ -629,7 +629,7 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase):
response = client.get(url) response = client.get(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:
@ -723,7 +723,7 @@ class AccountStatOperationViewTests(ViewTestCaseMixin, TestCase):
response = client.get(url) response = client.get(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:
@ -764,7 +764,7 @@ class AccountStatBalanceListViewTests(ViewTestCaseMixin, TestCase):
response = client.get(url) response = client.get(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:
@ -830,7 +830,7 @@ class AccountStatBalanceViewTests(ViewTestCaseMixin, TestCase):
response = client.get(url) response = client.get(url)
self.assertRedirects( self.assertRedirects(
response, response,
"/gestion/login?next={}".format(url), "/gestion/auth/login/choose?next={}".format(url),
fetch_redirect_response=False, fetch_redirect_response=False,
) )
else: else:

View file

@ -39,7 +39,9 @@ class TestCaseMixin:
querystring = QueryDict(mutable=True) querystring = QueryDict(mutable=True)
querystring["next"] = full_path querystring["next"] = full_path
login_url = "/gestion/login?" + querystring.urlencode(safe="/") login_url = "/gestion/auth/login/choose?{}".format(
querystring.urlencode(safe="/")
)
# We don't focus on what the login view does. # We don't focus on what the login view does.
# So don't fetch the redirect. # So don't fetch the redirect.

View file

@ -173,7 +173,7 @@ class TestCaseMixin:
querystring["next"] = full_path querystring["next"] = full_path
login_url = "{}?{}".format( login_url = "{}?{}".format(
reverse("cof-login"), querystring.urlencode(safe="/") reverse("authens:login"), querystring.urlencode(safe="/")
) )
# We don't focus on what the login view does. # We don't focus on what the login view does.