Skip to content

Commit b7f5a4e

Browse files
Merge pull request #312 from GeekInTheNorth/release/v3.2.0
Release 3.2.0
2 parents c215112 + ffbdfa3 commit b7f5a4e

16 files changed

Lines changed: 9197 additions & 24636 deletions

src/Stott.Security.Optimizely.Test/Features/Cors/CorsConfigurationTests.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,93 @@ public void Validate_GivenAnValidExposeHeader_ThenAnErrorWillNotBeReturned(strin
130130
// Assert
131131
Assert.That(result, Is.Empty);
132132
}
133+
134+
[Test]
135+
[TestCase(true, 1)]
136+
[TestCase(false, 0)]
137+
public void Validate_GivenAllowCredentialsIsTrueAndNoOriginsAreDefined_ThenAnErrorWillBeReturned(bool allowCredentials, int expectedErrorCount)
138+
{
139+
// Arrange
140+
var configuration = new CorsConfiguration
141+
{
142+
AllowCredentials = allowCredentials
143+
};
144+
145+
// Act
146+
var result = configuration.Validate(null).ToList();
147+
var errorCount = result.Count(x => x.MemberNames.Contains(nameof(CorsConfiguration.AllowCredentials)));
148+
149+
// Assert
150+
Assert.That(errorCount, Is.EqualTo(expectedErrorCount));
151+
}
152+
153+
[Test]
154+
[TestCase(true, 1)]
155+
[TestCase(false, 0)]
156+
public void Validate_GivenAllowCredentialsIsTrueAndAnyOriginAllowed_ThenAnErrorWillBeReturned(bool allowCredentials, int expectedErrorCount)
157+
{
158+
// Arrange
159+
var configuration = new CorsConfiguration
160+
{
161+
AllowOrigins = new List<CorsConfigurationItem>
162+
{
163+
new() { Id = Guid.NewGuid(), Value = "*" }
164+
},
165+
AllowCredentials = allowCredentials
166+
};
167+
168+
// Act
169+
var result = configuration.Validate(null).ToList();
170+
var errorCount = result.Count(x => x.MemberNames.Contains(nameof(CorsConfiguration.AllowCredentials)));
171+
172+
// Assert
173+
Assert.That(errorCount, Is.EqualTo(expectedErrorCount));
174+
}
175+
176+
[Test]
177+
[TestCase(true, 0)]
178+
[TestCase(false, 0)]
179+
public void Validate_GivenAllowCredentialsIsTrueAndASpecificOriginIsAllowed_ThenAnErrorWillNotBeReturned(bool allowCredentials, int expectedErrorCount)
180+
{
181+
// Arrange
182+
var configuration = new CorsConfiguration
183+
{
184+
AllowOrigins = new List<CorsConfigurationItem>
185+
{
186+
new() { Id = Guid.NewGuid(), Value = "https://www.example.com" }
187+
},
188+
AllowCredentials = allowCredentials
189+
};
190+
191+
// Act
192+
var result = configuration.Validate(null).ToList();
193+
var errorCount = result.Count(x => x.MemberNames.Contains(nameof(CorsConfiguration.AllowCredentials)));
194+
195+
// Assert
196+
Assert.That(errorCount, Is.EqualTo(expectedErrorCount));
197+
}
198+
199+
[Test]
200+
[TestCase(true, 1)]
201+
[TestCase(false, 0)]
202+
public void Validate_GivenAllowCredentialsIsTrueAndAnyOriginAndSpecificOriginAllowed_ThenAnErrorWillBeReturned(bool allowCredentials, int expectedErrorCount)
203+
{
204+
// Arrange
205+
var configuration = new CorsConfiguration
206+
{
207+
AllowOrigins = new List<CorsConfigurationItem>
208+
{
209+
new() { Id = Guid.NewGuid(), Value = "*" },
210+
new() { Id = Guid.NewGuid(), Value = "https://www.example.com" }
211+
},
212+
AllowCredentials = allowCredentials
213+
};
214+
215+
// Act
216+
var result = configuration.Validate(null).ToList();
217+
var errorCount = result.Count(x => x.MemberNames.Contains(nameof(CorsConfiguration.AllowCredentials)));
218+
219+
// Assert
220+
Assert.That(errorCount, Is.EqualTo(expectedErrorCount));
221+
}
133222
}

src/Stott.Security.Optimizely/Features/Cors/CorsConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
6767

6868
private bool IsAnyOriginAllowed()
6969
{
70-
return AllowOrigins.Count == 0 || !AllowOrigins.Any(x => x.Value == "*");
70+
return AllowOrigins.Count == 0 || AllowOrigins.Any(x => x.Value == "*");
7171
}
7272
}

src/Stott.Security.Optimizely/Static/main.4c1fdadd.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Stott.Security.Optimizely/Static/main.4c1fdadd.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Stott.Security.Optimizely/Static/main.7247e2b1.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Stott.Security.Optimizely/Static/main.eeb91523.js.LICENSE.txt renamed to src/Stott.Security.Optimizely/Static/main.7247e2b1.js.LICENSE.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
http://jedwatson.github.io/classnames
55
*/
66

7-
/*! Moment Duration Format v2.2.2
8-
* https://github.com/jsmreese/moment-duration-format
9-
* Date: 2018-02-16
10-
*
11-
* Duration format plugin function for the Moment.js library
12-
* http://momentjs.com/
13-
*
14-
* Copyright 2018 John Madhavan-Reese
15-
* Released under the MIT license
16-
*/
7+
/*!
8+
react-datepicker v8.4.0
9+
https://github.com/Hacker0x01/react-datepicker
10+
Released under the MIT License.
11+
*/
1712

1813
/**
1914
* @license React
@@ -54,5 +49,3 @@
5449
* This source code is licensed under the MIT license found in the
5550
* LICENSE file in the root directory of this source tree.
5651
*/
57-
58-
//! moment.js

src/Stott.Security.Optimizely/Static/main.7247e2b1.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Stott.Security.Optimizely/Static/main.ec0c2eda.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Stott.Security.Optimizely/Static/main.ec0c2eda.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Stott.Security.Optimizely/Static/main.eeb91523.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)