コード例 #1
0
ファイル: tweens_test.py プロジェクト: ackermann/h
def test_tween_csp_noop_by_default():
    request = DummyRequest()
    handler = mock.sentinel.HANDLER
    result = tweens.content_security_policy_tween_factory(
        handler, request.registry)

    assert result == handler
コード例 #2
0
ファイル: tweens_test.py プロジェクト: Cinemacloud/h
def test_tween_csp_noop_by_default():
    request = DummyRequest()
    handler = mock.sentinel.HANDLER
    result = tweens.content_security_policy_tween_factory(handler,
                                                          request.registry)

    assert result == handler
コード例 #3
0
ファイル: tweens_test.py プロジェクト: ssin122/test-h
def test_tween_csp_default_headers(pyramid_request):
    pyramid_request.registry.settings['csp.enabled'] = True
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response, pyramid_request.registry)

    response = tween(pyramid_request)

    assert 'Content-Security-Policy-Report-Only' not in response.headers
    assert 'Content-Security-Policy' in response.headers
コード例 #4
0
ファイル: tweens_test.py プロジェクト: djcun95/h
def test_tween_csp_default_headers(pyramid_request):
    pyramid_request.registry.settings['csp.enabled'] = True
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response,
        pyramid_request.registry)

    response = tween(pyramid_request)

    assert 'Content-Security-Policy-Report-Only' not in response.headers
    assert 'Content-Security-Policy' in response.headers
コード例 #5
0
ファイル: tweens_test.py プロジェクト: ssin122/test-h
def test_tween_csp_report_only_headers(pyramid_request):
    pyramid_request.registry.settings.update({
        'csp.enabled': True,
        'csp.report_only': True,
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response, pyramid_request.registry)

    response = tween(pyramid_request)

    assert 'Content-Security-Policy-Report-Only' in response.headers
    assert 'Content-Security-Policy' not in response.headers
コード例 #6
0
ファイル: tweens_test.py プロジェクト: djcun95/h
def test_tween_csp_report_only_headers(pyramid_request):
    pyramid_request.registry.settings.update({
        'csp.enabled': True,
        'csp.report_only': True,
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response,
        pyramid_request.registry)

    response = tween(pyramid_request)

    assert 'Content-Security-Policy-Report-Only' in response.headers
    assert 'Content-Security-Policy' not in response.headers
コード例 #7
0
ファイル: tweens_test.py プロジェクト: djcun95/h
def test_tween_csp_uri(pyramid_request):
    pyramid_request.registry.settings.update({
        'csp.enabled': True,
        'csp.report_only': False,
        'csp': {'report-uri': ['localhost']},
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response,
        pyramid_request.registry)

    response = tween(pyramid_request)

    expected = 'report-uri localhost'
    assert expected == response.headers['Content-Security-Policy']
コード例 #8
0
ファイル: tweens_test.py プロジェクト: ssin122/test-h
def test_tween_csp_uri(pyramid_request):
    pyramid_request.registry.settings.update({
        'csp.enabled': True,
        'csp.report_only': False,
        'csp': {
            'report-uri': ['localhost']
        },
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response, pyramid_request.registry)

    response = tween(pyramid_request)

    expected = 'report-uri localhost'
    assert expected == response.headers['Content-Security-Policy']
コード例 #9
0
ファイル: tweens_test.py プロジェクト: ssin122/test-h
def test_tween_csp_header(pyramid_request):
    pyramid_request.registry.settings.update({
        "csp.enabled": True,
        "csp.report_only": False,
        "csp": {
            "font-src": ["'self'", "fonts.gstatic.com"],
            "report-uri": ['localhost'],
            "script-src": ["'self'"],
            "style-src": ["'self'", "fonts.googleapis.com"],
        },
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response, pyramid_request.registry)

    response = tween(pyramid_request)

    expected = "font-src 'self' fonts.gstatic.com; report-uri localhost; " \
        "script-src 'self'; style-src 'self' fonts.googleapis.com"

    assert expected == response.headers['Content-Security-Policy']
コード例 #10
0
ファイル: tweens_test.py プロジェクト: djcun95/h
def test_tween_csp_header(pyramid_request):
    pyramid_request.registry.settings.update({
        "csp.enabled": True,
        "csp.report_only": False,
        "csp": {
            "font-src": ["'self'", "fonts.gstatic.com"],
            "report-uri": ['localhost'],
            "script-src": ["'self'"],
            "style-src": ["'self'", "fonts.googleapis.com"],
        },
    })
    tween = tweens.content_security_policy_tween_factory(
        lambda req: req.response,
        pyramid_request.registry)

    response = tween(pyramid_request)

    expected = "font-src 'self' fonts.gstatic.com; report-uri localhost; " \
        "script-src 'self'; style-src 'self' fonts.googleapis.com"

    assert expected == response.headers['Content-Security-Policy']
コード例 #11
0
ファイル: tweens_test.py プロジェクト: djcun95/h
def test_tween_csp_noop_by_default(pyramid_request):
    handler = mock.sentinel.HANDLER
    result = tweens.content_security_policy_tween_factory(handler,
                                                          pyramid_request.registry)

    assert result == handler
コード例 #12
0
ファイル: tweens_test.py プロジェクト: ssin122/test-h
def test_tween_csp_noop_by_default(pyramid_request):
    handler = mock.sentinel.HANDLER
    result = tweens.content_security_policy_tween_factory(
        handler, pyramid_request.registry)

    assert result == handler