Skip to content

Commit

Permalink
Remove empty when separate. (#37549)
Browse files Browse the repository at this point in the history
* Remove empty when separate.

* update date

* also fix aspnetcore.

* update UT.
  • Loading branch information
JialinXin authored Jul 12, 2023
1 parent 7c27998 commit e9a1e68
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.6.0 (2023-06-30)
## 1.6.0 (2023-07-12)

### Bugs Fixed
- Fix secondary key validation failed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.WebPubSub
{
internal static class Constants
{
public static readonly char[] HeaderSeparator = { ',' };
public static readonly char[] HeaderSeparator = { ',', ' '};
public const string AllowedAllOrigins = "*";

// WebPubSubOptions can be set by customers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ public async Task TestProcessRequest_AbuseProtectionInvalidBadRequest(string met
Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
}

[TestCase("sha256=something,sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561")]
[TestCase("sha256=something, sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561")]
[TestCase("sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561, sha256=something")]
[TestCase("sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561,sha256=something")]
public async Task TestProcessRequest_MultiSignaturesSuccess(string signatures)
{
var dispatcher = SetupDispatcher(connectionString: $"Endpoint=http://{TestOrigin};Port=8080;AccessKey=7aab239577fd4f24bc919802fb629f5f;Version=1.0;");
var request = TestHelpers.CreateHttpRequestMessage(TestHub, TestType, TestEvent, TestKey.ConnectionId, new string[] { signatures }, httpMethod: "GET", origin: new string[] { TestOrigin });
var response = await dispatcher.ExecuteAsync(request);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
}

[TestCase("application/xml", HttpStatusCode.BadRequest)]
public async Task TestProcessRequest_MessageMediaTypes(string mediaType, HttpStatusCode expectedCode)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.1.0 (2023-06-30)
## 1.1.0 (2023-07-12)

### Bugs Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.Azure.WebPubSub.AspNetCore
{
internal static class Constants
{
public static readonly char[] HeaderSeparator = { ',' };
public static readonly char[] HeaderSeparator = { ',', ' ' };
public const string AllowedAllOrigins = "*";

public static class ContentTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,16 @@ public void TestSignatureCheck_SignatureNullFail()
Assert.False(result);
}

[Test]
public void TestSignatureCheck_SecondSignatureSuccess()
[TestCase("sha256=something,sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561")]
[TestCase("sha256=something, sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561")]
[TestCase("sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561, sha256=something")]
[TestCase("sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561,sha256=something")]
public void TestSignatureCheck_MultiSignatureSuccess(string signatures)
{
var connectionContext = new WebPubSubConnectionContext(
WebPubSubEventType.System,
null, null, "0f9c97a2f0bf4706afe87a14e0797b11",
signature: "sha256=something,sha256=7767effcb3946f3e1de039df4b986ef02c110b1469d02c0a06f41b3b727ab561",
signature: signatures,
origin: TestUri.Host);
var validator = new RequestValidator(Options.Create(new WebPubSubOptions { ServiceEndpoint = new WebPubSubServiceEndpoint($"Endpoint={TestUri};Version=1.0;") }));
var result = validator.IsValidSignature(connectionContext);
Expand Down

0 comments on commit e9a1e68

Please sign in to comment.