@@ -114,21 +114,36 @@ defmodule TidewaveTest do
114114 assert Plug.Conn . get_resp_header ( conn , "x-frame-options" ) == [ ]
115115 end
116116
117- test "updates CSP header if set" do
117+ test "updates CSP header if set (no toolbar) " do
118118 conn =
119119 conn ( :get , "/foo" )
120120 |> Plug.Conn . put_resp_header (
121121 "content-security-policy" ,
122122 "default-src 'self' http://example.com; connect-src 'none'; script-src 'self'; frame-ancestors 'none'"
123123 )
124- |> Tidewave . call ( Tidewave . init ( [ ] ) )
124+ |> Tidewave . call ( Tidewave . init ( toolbar: false ) )
125125 |> Plug.Conn . send_resp ( 200 , "foo" )
126126
127127 assert Plug.Conn . get_resp_header ( conn , "content-security-policy" ) == [
128128 "default-src 'self' http://example.com; connect-src 'none'; script-src 'unsafe-eval' 'self'"
129129 ]
130130 end
131131
132+ test "updates CSP header if set (toolbar)" do
133+ conn =
134+ conn ( :get , "/foo" )
135+ |> Plug.Conn . put_resp_header (
136+ "content-security-policy" ,
137+ "default-src 'self' http://example.com; connect-src 'none'; script-src 'self'; frame-ancestors 'none'"
138+ )
139+ |> Tidewave . call ( Tidewave . init ( toolbar: true ) )
140+ |> Plug.Conn . send_resp ( 200 , "foo" )
141+
142+ assert Plug.Conn . get_resp_header ( conn , "content-security-policy" ) == [
143+ "default-src 'self' http://example.com; connect-src 'none'; script-src https://tidewave.ai 'unsafe-eval' 'self'"
144+ ]
145+ end
146+
132147 test "updates CSP headers with flags and trailing space" do
133148 conn =
134149 conn ( :get , "/foo" )
@@ -140,7 +155,7 @@ defmodule TidewaveTest do
140155 |> Plug.Conn . send_resp ( 200 , "foo" )
141156
142157 assert Plug.Conn . get_resp_header ( conn , "content-security-policy" ) ==
143- [ "upgrade-insecure-requests; script-src 'unsafe-eval' 'self'; " ]
158+ [ "upgrade-insecure-requests; script-src https://tidewave.ai 'unsafe-eval' 'self'; " ]
144159 end
145160
146161 describe "/mcp" do
0 commit comments