-
Notifications
You must be signed in to change notification settings - Fork 43
/
FeaturePolicyBuilderTests.cs
57 lines (45 loc) · 1.77 KB
/
FeaturePolicyBuilderTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Joonasw.AspNetCore.SecurityHeaders.FeaturePolicy.Builder;
using Xunit;
namespace Joonasw.AspNetCore.SecurityHeaders.Tests
{
public class FeaturePolicyBuilderTests
{
[Fact]
public void PaymentFromNowhere_SetsValue()
{
var builder = new FeaturePolicyBuilder();
builder.AllowPayment.FromNowhere();
var options = builder.BuildFeaturePolicyOptions();
string headerValue = options.ToString();
Assert.Equal("payment 'none'", headerValue);
}
[Fact]
public void PaymentFromSelfAndGoogle_SetsValue()
{
var builder = new FeaturePolicyBuilder();
builder.AllowPayment.FromSelf().From("https://www.google.com");
var options = builder.BuildFeaturePolicyOptions();
string headerValue = options.ToString();
Assert.Equal("payment 'self' https://www.google.com", headerValue);
}
[Fact]
public void PaymentFromNowhereAndFullScreenFromSelf_SetsValue()
{
var builder = new FeaturePolicyBuilder();
builder.AllowPayment.FromNowhere();
builder.AllowFullscreen.FromSelf();
var options = builder.BuildFeaturePolicyOptions();
string headerValue = options.ToString();
Assert.Equal("fullscreen 'self'; payment 'none'", headerValue);
}
[Fact]
public void OtherNewFeatureFromSelf_SetsValue()
{
var builder = new FeaturePolicyBuilder();
builder.AllowOtherFeature("new-feature").FromSelf();
var options = builder.BuildFeaturePolicyOptions();
string headerValue = options.ToString();
Assert.Equal("new-feature 'self'", headerValue);
}
}
}