-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an MTA-STS entry for email policy
- Loading branch information
1 parent
71f6878
commit ad7f176
Showing
5 changed files
with
70 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: STSv1 | ||
mode: enforce | ||
mx: mx1.alwaysdata.com. | ||
mx: mx2.alwaysdata.com. | ||
max_age: 604800 |
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 @@ | ||
version: STSv1 | ||
mode: enforce | ||
mx: aspmx.l.google.com | ||
mx: alt1.aspmx.l.google.com | ||
mx: alt2.aspmx.l.google.com | ||
mx: alt3.aspmx.l.google.com | ||
mx: alt4.aspmx.l.google.com | ||
max_age: 604800 |
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,41 @@ | ||
import pathlib | ||
|
||
from django.conf import settings | ||
from django.test import TestCase, override_settings | ||
from django.urls import reverse | ||
|
||
|
||
class TestMTASTS(TestCase): | ||
def test_access_from_tests(self): | ||
response = self.client.get(reverse("mta-sts")) | ||
self.assertEqual(response.status_code, 404) | ||
|
||
def test_access_from_localhost(self): | ||
response = self.client.get( | ||
reverse("mta-sts"), | ||
HTTP_HOST="localhost", | ||
SERVER_NAME="localhost", | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual( | ||
response.content, | ||
b"Content depends on the domain, because MX servers are per domain.", | ||
) | ||
|
||
@override_settings(ALLOWED_HOSTS=["inclusion.beta.gouv.fr", "inclusion.gouv.fr"]) | ||
def test_access_from_domain(self): | ||
for domain in settings.ALLOWED_HOSTS: | ||
with self.subTest(domain): | ||
response = self.client.get( | ||
reverse("mta-sts"), | ||
HTTP_HOST=domain, | ||
SERVER_NAME=domain, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
policy_path = ( | ||
pathlib.Path(settings.BASE_DIR) | ||
/ "static" | ||
/ ".well-known" | ||
/ f"mta-sts.{domain}.txt" | ||
) | ||
self.assertEqual(response.content, policy_path.read_bytes()) |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
from django.urls import path | ||
|
||
from .views import serve_text_file | ||
from .views import mta_sts, serve_text_file | ||
|
||
|
||
urlpatterns = [ | ||
path("pdi-pgp.asc", serve_text_file, {"file_name": "pdi-pgp.asc"}, name="pdi-pgp"), | ||
path("security-policy.txt", serve_text_file, {"file_name": "security-policy.txt"}, name="security-policy"), | ||
path("security.txt", serve_text_file, {"file_name": "security.txt"}, name="security"), | ||
path("mta-sts.txt", mta_sts, name="mta-sts"), | ||
] |
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