Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip WebhookUtilityTests on GitHub Actions #225

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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