Skip to content

Commit

Permalink
Unskip WebhookUtilityTests on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Apr 12, 2024
1 parent 64a7157 commit 8af4954
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
###############################################################################
* text=auto

###############################################################################
# Set default behavior for JSON files
###############################################################################
*.json text eol=crlf

###############################################################################
# Set default behavior for command prompt diff.
#
Expand Down
1 change: 0 additions & 1 deletion tests/FaluSdk.Tests/FaluSdk.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 3 additions & 9 deletions tests/FaluSdk.Tests/WebhookUtilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,27 @@ public class WebhookUtilityTests
$"t=1658299746,sha256={Signature0},sha256={Signature1}",
];

// TODO: investigate why these tests fail on GitHub workflows but they work on WSL (Ubuntu 20.04) and on Docker (dotnet/runtime:7.0)
private static bool IsGithubAction() => Environment.GetEnvironmentVariable("GITHUB_ACTION") != null;

[SkippableFact]
[Fact]
public async Task ValidateSignature_Works()
{
Skip.If(IsGithubAction());
var now = KnownNow.AddSeconds(100);
var json = await TestSamples.GetCloudEventAsStringAsync();
WebhookUtility.ValidateSignature(json, KnownSignatures[0], Secret0, now: now);
}

[SkippableFact]
[Fact]
public async Task ValidateSignature_Works_With_RolledSecrets()
{
Skip.If(IsGithubAction());
var now = KnownNow.AddSeconds(100);
var json = await TestSamples.GetCloudEventAsStringAsync();

WebhookUtility.ValidateSignature(json, KnownSignatures[1], Secret0, now: now);
WebhookUtility.ValidateSignature(json, KnownSignatures[1], Secret1, now: now);
}

[SkippableFact]
[Fact]
public async Task ValidateSignature_Rejects_OldTimestamp()
{
Skip.If(IsGithubAction());
var now = KnownNow.AddSeconds(400);
var json = await TestSamples.GetCloudEventAsStringAsync();
var exception = Assert.Throws<FaluException>(() => WebhookUtility.ValidateSignature(json, KnownSignatures[0], Secret0, now: now));
Expand Down

0 comments on commit 8af4954

Please sign in to comment.