Skip to content

Commit

Permalink
Whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMDavidson committed Dec 31, 2018
1 parent 6800084 commit d6b9d6e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 81 deletions.
22 changes: 11 additions & 11 deletions src/Joonasw.AspNetCore.SecurityHeaders/Csp/Builder/CspBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public class CspBuilder
/// Set up rules for AJAX, WebSockets and EventSource.
/// </summary>
public CspConnectionBuilder AllowConnections { get; } = new CspConnectionBuilder();
/// <summary>
/// Sets up rules for where this app can load web manifests from
/// </summary>
public CspManifestBuilder AllowManifest { get; } = new CspManifestBuilder();
/// <summary>
/// Set up rules for fonts.
/// </summary>
public CspFontsBuilder AllowFonts { get; } = new CspFontsBuilder();
/// <summary>
/// Sets up rules for where this app can load web manifests from
/// </summary>
public CspManifestBuilder AllowManifest { get; } = new CspManifestBuilder();
/// <summary>
/// Set up rules for fonts.
/// </summary>
public CspFontsBuilder AllowFonts { get; } = new CspFontsBuilder();
/// <summary>
/// Set up rules for audio and video in e.g. HTML5 audio and video elements.
/// </summary>
Expand Down Expand Up @@ -129,7 +129,7 @@ public CspOptions BuildCspOptions()
_options.Child = AllowChildren.BuildOptions();
#pragma warning restore CS0618 // Type or member is obsolete
_options.Connect = AllowConnections.BuildOptions();
_options.Manifest = AllowManifest.BuildOptions();
_options.Manifest = AllowManifest.BuildOptions();
_options.Default = ByDefaultAllow.BuildOptions();
_options.Font = AllowFonts.BuildOptions();
_options.FormAction = AllowFormActions.BuildOptions();
Expand All @@ -142,8 +142,8 @@ public CspOptions BuildCspOptions()
_options.Sandbox = _sandboxBuilder.BuildOptions();
_options.Frame = AllowFrames.BuildOptions();
_options.Worker = AllowWorkers.BuildOptions();
_options.Prefetch = AllowPrefetch.BuildOptions();
_options.BaseUri = AllowBaseUri.BuildOptions();
_options.Prefetch = AllowPrefetch.BuildOptions();
_options.BaseUri = AllowBaseUri.BuildOptions();
_options.OnSendingHeader = OnSendingHeader;
return _options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,59 @@

namespace Joonasw.AspNetCore.SecurityHeaders.Csp.Builder
{
/// <summary>
/// Builder for controlling where web manifests can be loaded from
/// </summary>
/// <summary>
/// Builder for controlling where web manifests can be loaded from
/// </summary>
public class CspManifestBuilder {
private readonly CspManifestSrcOptions _options = new CspManifestSrcOptions();
private readonly CspManifestSrcOptions _options = new CspManifestSrcOptions();

/// <summary>
/// Allow manifests to be loaded from the current domain.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder FromSelf() {
_options.AllowSelf = true;
return this;
}
/// <summary>
/// Allow manifests to be loaded from the current domain.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder FromSelf() {
_options.AllowSelf = true;
return this;
}

/// <summary>
/// Allow manifests to load from the given <paramref name="uri"/>.
/// </summary>
/// <param name="uri">The URI to allow.</param>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder From(string uri) {
_options.AllowedSources.Add(uri);
return this;
}
/// <summary>
/// Allow manifests to load from the given <paramref name="uri"/>.
/// </summary>
/// <param name="uri">The URI to allow.</param>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder From(string uri) {
_options.AllowedSources.Add(uri);
return this;
}

/// <summary>
/// Allow manifests to load from anywhere.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder FromAnywhere() {
_options.AllowAny = true;
return this;
}
/// <summary>
/// Allow manifests to load from anywhere.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder FromAnywhere() {
_options.AllowAny = true;
return this;
}

/// <summary>
/// Block all loading of manifests.
/// </summary>
/// <returns>The builder for call chaining</returns>
public void FromNowhere() {
_options.AllowNone = true;
}
/// <summary>
/// Block all loading of manifests.
/// </summary>
/// <returns>The builder for call chaining</returns>
public void FromNowhere() {
_options.AllowNone = true;
}

/// <summary>
/// Allow manifests to load from secure connections.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder OnlyOverHttps() {
_options.AllowOnlyHttps = true;
return this;
}
/// <summary>
/// Allow manifests to load from secure connections.
/// </summary>
/// <returns>The builder for call chaining</returns>
public CspManifestBuilder OnlyOverHttps() {
_options.AllowOnlyHttps = true;
return this;
}

public CspManifestSrcOptions BuildOptions() {
return _options;
}
}
public CspManifestSrcOptions BuildOptions() {
return _options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
public class CspManifestSrcOptions : CspSrcOptionsBase
{
public CspManifestSrcOptions()
:base ("manifest-src")
{
}
public CspManifestSrcOptions()
:base ("manifest-src")
{
}
}
}
12 changes: 6 additions & 6 deletions src/Joonasw.AspNetCore.SecurityHeaders/CspOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class CspOptions
/// Rules to apply for AJAX, WebSockets and EventSource.
/// </summary>
public CspConnectSrcOptions Connect { get; set; }
/// <summary>
/// Rules to control where web manifests can be loaded from
/// </summary>
public CspManifestSrcOptions Manifest { get; set; }
/// <summary>
/// Rules to control where web manifests can be loaded from
/// </summary>
public CspManifestSrcOptions Manifest { get; set; }
/// <summary>
/// Rules to apply for fonts.
/// </summary>
Expand Down Expand Up @@ -145,7 +145,7 @@ public CspOptions()
Child = new CspChildSrcOptions();
#pragma warning restore CS0618 // Type or member is obsolete
Connect = new CspConnectSrcOptions();
Manifest = new CspManifestSrcOptions();
Manifest = new CspManifestSrcOptions();
Font = new CspFontSrcOptions();
FormAction = new CspFormActionOptions();
Img = new CspImgSrcOptions();
Expand Down Expand Up @@ -181,7 +181,7 @@ public CspOptions()
Child.ToString(nonceService),
#pragma warning restore CS0618 // Type or member is obsolete
Connect.ToString(nonceService),
Manifest.ToString(nonceService),
Manifest.ToString(nonceService),
Font.ToString(nonceService),
FormAction.ToString(nonceService),
Img.ToString(nonceService),
Expand Down
24 changes: 12 additions & 12 deletions test/Joonasw.AspNetCore.SecurityHeaders.Tests/CspBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,26 @@ public void WithFramesAndWorkers_ReturnsCorrectHeader()
[Fact]
public void WithPrefetch_ReturnsCorrectHeader()
{
var builder = new CspBuilder();
var builder = new CspBuilder();

builder.AllowPrefetch.From("https://www.google.com");
builder.AllowPrefetch.From("https://www.google.com");

var headerValue = builder.BuildCspOptions().ToString(null).headerValue;
var headerValue = builder.BuildCspOptions().ToString(null).headerValue;

Assert.Equal("prefetch-src https://www.google.com", headerValue);
Assert.Equal("prefetch-src https://www.google.com", headerValue);
}

[Fact]
public void WithManifest_ReturnsCorrectHeader()
{
var builder = new CspBuilder();
[Fact]
public void WithManifest_ReturnsCorrectHeader()
{
var builder = new CspBuilder();

builder.AllowManifest.From("https://www.google.com");
builder.AllowManifest.From("https://www.google.com");

var headerValue = builder.BuildCspOptions().ToString(null).headerValue;
var headerValue = builder.BuildCspOptions().ToString(null).headerValue;

Assert.Equal("manifest-src https://www.google.com", headerValue);
}
Assert.Equal("manifest-src https://www.google.com", headerValue);
}

[Fact]
public async Task OnSendingHeader_ShouldNotSendTest()
Expand Down

0 comments on commit d6b9d6e

Please sign in to comment.