File tree Expand file tree Collapse file tree
tests/candidate/presentation/views Expand file tree Collapse file tree Original file line number Diff line number Diff line change 187187# Default primary key field type
188188DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
189189
190+ SECURITY_CONTACT_EMAIL = "ops.csplab@beta.gouv.fr"
191+
190192# Maximum CV size in cv upload flow
191193CV_MAX_SIZE_MB = 5
192194
Original file line number Diff line number Diff line change 77from presentation .candidate import urls as candidate_urls
88from presentation .ingestion import urls as ingestion_urls
99from presentation .pages import urls as pages_urls
10+ from presentation .pages .views import security_txt
1011from presentation .users import urls as users_urls
1112
1213urlpatterns : list [URLPattern | URLResolver ] = [
14+ path (".well-known/security.txt" , security_txt ),
1315 path ("" , include (pages_urls )),
1416 path ("api/" , include (api_urls )),
1517 path ("admin/" , admin .site .urls ),
Original file line number Diff line number Diff line change 88 LegalNoticesView ,
99 PrivacyView ,
1010 TermsView ,
11+ security_txt ,
1112)
1213
1314app_name = "pages"
Original file line number Diff line number Diff line change 1+ from django .conf import settings
2+ from django .http import HttpResponse
13from django .views .generic import TemplateView
24
35
@@ -19,3 +21,8 @@ class PrivacyView(TemplateView):
1921
2022class LegalNoticesView (TemplateView ):
2123 template_name = "pages/legal_notices.html"
24+
25+
26+ def security_txt (request ):
27+ content = f"Contact: mailto:{ settings .SECURITY_CONTACT_EMAIL } \n Preferred-Languages: fr, en\n "
28+ return HttpResponse (content , content_type = "text/plain; charset=utf-8" )
Original file line number Diff line number Diff line change 55from pytest_django .asserts import assertTemplateUsed
66
77
8+ class TestSecurityTxtView :
9+ def test_returns_ok (self , client , db ):
10+ response = client .get ("/.well-known/security.txt" )
11+ assert response .status_code == HTTPStatus .OK
12+
13+ def test_content_type (self , client , db ):
14+ response = client .get ("/.well-known/security.txt" )
15+ assert "text/plain" in response ["Content-Type" ]
16+
17+ def test_content (self , client , db ):
18+ response = client .get ("/.well-known/security.txt" )
19+ content = response .content .decode ()
20+ assert "Contact: mailto:ops.csplab@beta.gouv.fr" in content
21+ assert "Preferred-Languages: fr, en" in content
22+
23+
824@pytest .mark .parametrize (
925 ("url_name" , "template_name" ),
1026 [
You can’t perform that action at this time.
0 commit comments