MCPcopy Index your code
hub / github.com/plotly/dash / test_incs001_csp_hashes_inline_scripts

Function test_incs001_csp_hashes_inline_scripts

tests/integration/test_csp.py:25–58  ·  view source on GitHub ↗
(
    dash_duo, add_hashes, hash_algorithm, expectation
)

Source from the content-addressed store, hash-verified

23 ],
24)
25def test_incs001_csp_hashes_inline_scripts(
26 dash_duo, add_hashes, hash_algorithm, expectation
27):
28 app = Dash(__name__)
29
30 app.layout = html.Div(
31 [dcc.Input(id="input_element", type="text"), html.Div(id="output_element")]
32 )
33
34 app.clientside_callback(
35 """
36 function(input) {
37 return input;
38 }
39 """,
40 Output("output_element", "children"),
41 [Input("input_element", "value")],
42 )
43
44 with expectation:
45 csp = {
46 "default-src": "'self'",
47 "script-src": ["'self'"]
48 + (app.csp_hashes(hash_algorithm) if add_hashes else []),
49 }
50
51 flask_talisman.Talisman(
52 app.server, content_security_policy=csp, force_https=False
53 )
54
55 dash_duo.start_server(app)
56
57 dash_duo.find_element("#input_element").send_keys("xyz")
58 assert dash_duo.wait_for_element("#output_element").text == "xyz"

Callers

nothing calls this directly

Calls 9

clientside_callbackMethod · 0.95
csp_hashesMethod · 0.95
DashClass · 0.90
OutputClass · 0.90
InputClass · 0.90
send_keysMethod · 0.80
find_elementMethod · 0.80
wait_for_elementMethod · 0.80
start_serverMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…