-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6a06cd7
commit 411a9f6
Showing
3 changed files
with
11 additions
and
8 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
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,13 +1,14 @@ | ||
from pyramid.events import NewRequest | ||
from pyramid.events import NewResponse | ||
|
||
from riskmatrix.subscribers import csp_header | ||
from riskmatrix.subscribers import csp_header, request_nonce_generator | ||
from riskmatrix.subscribers import sentry_context | ||
from riskmatrix.testing import DummyRequest | ||
|
||
|
||
def test_csp_header(config): | ||
request = DummyRequest() | ||
request.csp_nonce = '123' | ||
response = request.response | ||
event = NewResponse(request, response) | ||
csp_header(event) | ||
|
@@ -21,14 +22,15 @@ def test_csp_header(config): | |
"frame-ancestors 'none'; " | ||
"img-src 'self' data: blob:; " | ||
"object-src 'self'; " | ||
"script-src 'self' blob: resource:; " | ||
"script-src 'self' 'nonce-123' blob: resource:; " | ||
"style-src 'self' 'unsafe-inline'" | ||
) | ||
|
||
|
||
def test_csp_header_sentry(config): | ||
config.registry.settings['sentry_dsn'] = 'https://aa:[email protected]/22' | ||
request = DummyRequest() | ||
request.csp_nonce = '123' | ||
response = request.response | ||
event = NewResponse(request, response) | ||
csp_header(event) | ||
|
@@ -42,13 +44,14 @@ def test_csp_header_sentry(config): | |
"frame-ancestors 'none'; " | ||
"img-src 'self' data: blob:; " | ||
"object-src 'self'; " | ||
"script-src 'self' blob: resource:; " | ||
"script-src 'self' 'nonce-123' blob: resource:; " | ||
"style-src 'self' 'unsafe-inline'; " | ||
"report-uri https://sentry.io/api/22/security/?sentry_key=aa" | ||
) | ||
|
||
config.registry.settings['sentry_dsn'] = 'https://[email protected]/22' | ||
request = DummyRequest() | ||
request.csp_nonce = '123' | ||
response = request.response | ||
event = NewResponse(request, response) | ||
csp_header(event) | ||
|
@@ -62,7 +65,7 @@ def test_csp_header_sentry(config): | |
"frame-ancestors 'none'; " | ||
"img-src 'self' data: blob:; " | ||
"object-src 'self'; " | ||
"script-src 'self' blob: resource:; " | ||
"script-src 'self' 'nonce-123' blob: resource:; " | ||
"style-src 'self' 'unsafe-inline'; " | ||
"report-uri https://sentry.io/api/22/security/?sentry_key=aa" | ||
) | ||
|
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