-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Blazor] Fix multiple CSP policies #55200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4c48edd
3e34de0
bdc7640
9eb95db
9b2b5ad
9bbfb29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,39 @@ public async Task EmbeddingServerAppInsideIframe_WorksAsync() | |
Assert.DoesNotContain("Content-Security-Policy", response.Headers.Select(h => h.Key)); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task EmbeddingServerAppInsideIframe_WorksWithMultipleCspHeaders() | ||
{ | ||
Navigate("/subdir/iframe?add-csp"); | ||
|
||
var logs = Browser.GetBrowserLogs(LogLevel.Severe); | ||
|
||
Assert.Empty(logs); | ||
|
||
// Get the iframe element from the page, and inspect its contents for a p element with id inside-iframe | ||
var iframe = Browser.FindElement(By.TagName("iframe")); | ||
Browser.SwitchTo().Frame(iframe); | ||
Browser.Exists(By.Id("inside-iframe")); | ||
|
||
using var client = new HttpClient() { BaseAddress = _serverFixture.RootUri }; | ||
var response = await client.GetAsync("/subdir/iframe?add-csp"); | ||
response.EnsureSuccessStatusCode(); | ||
|
||
if (ExpectedPolicy != null) | ||
{ | ||
Assert.Equal( | ||
response.Headers.GetValues("Content-Security-Policy"), | ||
[ | ||
"script-src 'self' 'unsafe-inline'", | ||
$"frame-ancestors {ExpectedPolicy}" | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]); | ||
} | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
{ | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Assert.DoesNotContain("Content-Security-Policy", response.Headers.Select(h => h.Key)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this assertion really correct? If you're requesting the Or is it possible this test code never actually runs? It's hard to reason about with the subclasses and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's hard to write these tests. I copy pasted it from another test but validated that it works (that section doesn't run). I'll clean that up. |
||
} | ||
} | ||
javiercn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public abstract partial class BlockedWebSocketCompressionTests( | ||
|
Uh oh!
There was an error while loading. Please reload this page.