Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
614 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from ...conf.test import override_dynamic_settings | ||
from ...test import assert_contains, assert_not_contains | ||
|
||
|
||
@override_dynamic_settings(google_tracking_id=None) | ||
def test_tracking_script_is_not_included_if_tracking_id_is_not_set(db, client): | ||
response = client.get("/") | ||
assert_not_contains(response, "googletagmanager.com/gtag/js") | ||
|
||
|
||
@override_dynamic_settings(google_tracking_id="UA-TEST") | ||
def test_tracking_script_is_included_if_tracking_id_is_not_set(db, client): | ||
response = client.get("/") | ||
assert_contains(response, "googletagmanager.com/gtag/js") | ||
assert_contains(response, "UA-TEST") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.urls import reverse | ||
|
||
from ...conf.test import override_dynamic_settings | ||
from ...test import assert_contains | ||
|
||
|
||
@override_dynamic_settings(google_site_verification=None) | ||
def test_verification_page_returns_404_if_verification_token_is_not_set(db, client): | ||
verification_link = reverse( | ||
"misago:google-site-verification", kwargs={"token": "t0k3n"} | ||
) | ||
response = client.get(verification_link) | ||
assert response.status_code == 404 | ||
|
||
|
||
@override_dynamic_settings(google_site_verification="t0k3n") | ||
def test_verification_page_returns_404_if_verification_token_is_invalid(db, client): | ||
verification_link = reverse( | ||
"misago:google-site-verification", kwargs={"token": "inv4l1d"} | ||
) | ||
response = client.get(verification_link) | ||
assert response.status_code == 404 | ||
|
||
|
||
@override_dynamic_settings(google_site_verification="t0k3n") | ||
def test_verification_page_returns_200_if_verification_token_is_correct(db, client): | ||
verification_link = reverse( | ||
"misago:google-site-verification", kwargs={"token": "t0k3n"} | ||
) | ||
response = client.get(verification_link) | ||
assert response.status_code == 200 | ||
|
||
|
||
@override_dynamic_settings(google_site_verification="t0k3n") | ||
def test_verification_page_contains_token(db, client): | ||
verification_link = reverse( | ||
"misago:google-site-verification", kwargs={"token": "t0k3n"} | ||
) | ||
response = client.get(verification_link) | ||
assert_contains(response, "googlet0k3n.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.conf.urls import url | ||
|
||
from .views import google_site_verification | ||
|
||
urlpatterns = [ | ||
url( | ||
r"^google(?P<token>[a-z0-9]+)\.html$", | ||
google_site_verification, | ||
name="google-site-verification", | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.http import Http404, HttpResponse | ||
|
||
|
||
def google_site_verification(request, token): | ||
if token != request.settings.google_site_verification: | ||
raise Http404() | ||
|
||
return HttpResponse("google-site-verification: google%s.html" % token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.