Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FantasticFiasco committed Nov 3, 2023
1 parent 87a7f39 commit ba8c761
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GET
/

host:example.amazonaws.com
my-header1:value2, value2, value1
my-header1:value2,value2,value1
x-amz-date:20150830T123600Z

host;my-header1;x-amz-date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GET
/

host:example.amazonaws.com
my-header1:value1, value2, value3
my-header1:value1,value2,value3
x-amz-date:20150830T123600Z

host;my-header1;x-amz-date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GET
/

host:example.amazonaws.com
my-header1:value4, value1, value3, value2
my-header1:value4,value1,value3,value2
x-amz-date:20150830T123600Z

host;my-header1;x-amz-date
Expand Down
22 changes: 22 additions & 0 deletions test/TestSuite/Fixtures/TestSuiteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace AwsSignatureVersion4.TestSuite.Fixtures
{
public class TestSuiteFixture
{
private string defaultHeaderValueSeparator;

public RegionEndpoint Region => RegionEndpoint.USEast1;

public string ServiceName => "service";
Expand Down Expand Up @@ -49,5 +51,25 @@ public HttpRequestMessage RedirectRequest(HttpRequestMessage request, string to)

return request;
}

/// <summary>
/// The header value separator chosen by Microsoft in .NET is ", " and not "," as defined
/// by the test suite. This means that we have to change the default behavior to match the
/// test suite.
/// </summary>
public void AdjustHeaderValueSeparator()
{
defaultHeaderValueSeparator = CanonicalRequest.HeaderValueSeparator;
CanonicalRequest.HeaderValueSeparator = ",";
}

/// <summary>
/// Lets reset the default header value separator before we continue with the rest of the
/// tests.
/// </summary>
public void ResetHeaderValueSeparator()
{
CanonicalRequest.HeaderValueSeparator = defaultHeaderValueSeparator;
}
}
}
50 changes: 0 additions & 50 deletions test/TestSuite/TestSuiteContext.cs

This file was deleted.

11 changes: 10 additions & 1 deletion test/Unit/Private/CanonicalRequestShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
namespace AwsSignatureVersion4.Unit.Private
{
[Collection("Canonical request - These tests are modifying global scope which prevents them from running in parallel with other canonical request tests")]
public class CanonicalRequestShould : IClassFixture<TestSuiteFixture>
public class CanonicalRequestShould : IClassFixture<TestSuiteFixture>, IDisposable
{
private readonly Func<string[], Scenario> loadScenario;
private readonly DateTime utcNow;
private readonly Action resetHeaderValueSeparator;

public CanonicalRequestShould(TestSuiteFixture fixture)
{
loadScenario = fixture.LoadScenario;
utcNow = fixture.UtcNow;
resetHeaderValueSeparator = fixture.ResetHeaderValueSeparator;

fixture.AdjustHeaderValueSeparator();
}

[Theory]
Expand Down Expand Up @@ -223,5 +227,10 @@ public void SortQueryParameterValues(string query, string parameterName, string[
// Assert
actual[parameterName].ShouldBe(expected);
}

public void Dispose()
{
resetHeaderValueSeparator();
}
}
}
7 changes: 7 additions & 0 deletions test/Unit/Private/SignerShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace AwsSignatureVersion4.Unit.Private
{
[Collection("Canonical request - These tests are modifying global scope which prevents them from running in parallel with other canonical request tests")]
public class SignerShould : IClassFixture<TestSuiteFixture>, IDisposable
{
private readonly HttpClient httpClient;
Expand All @@ -21,6 +22,7 @@ public class SignerShould : IClassFixture<TestSuiteFixture>, IDisposable
private readonly string region;
private readonly string serviceName;
private readonly ImmutableCredentials immutableCredentials;
private readonly Action resetHeaderValueSeparator;

public SignerShould(TestSuiteFixture fixture)
{
Expand All @@ -30,6 +32,9 @@ public SignerShould(TestSuiteFixture fixture)
region = fixture.Region.SystemName;
serviceName = fixture.ServiceName;
immutableCredentials = fixture.ImmutableCredentials;
resetHeaderValueSeparator = fixture.ResetHeaderValueSeparator;

fixture.AdjustHeaderValueSeparator();
}

#region Pass test suite
Expand Down Expand Up @@ -395,6 +400,8 @@ public void ThrowArgumentExceptionGivenAuthorizationHeaderAddedByName()
public void Dispose()
{
httpClient.Dispose();

resetHeaderValueSeparator();
}
}
}

0 comments on commit ba8c761

Please sign in to comment.