Skip to content

Commit

Permalink
Merge branch 'release/0.78.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jul 12, 2024
2 parents 436e835 + 14ca8a3 commit bbf26d3
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Source/ZoomNet.UnitTests/Extensions/InternalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ public async Task ThrowsExceptionWhenExpectedRecordsAreMissing()
{
// Arrange
var responseContent = @"{
""next_page_token"": """",
""page_number"": 1,
""page_size"": 100,
""total_records"": 5
}";
""next_page_token"": """",
""page_number"": 1,
""page_size"": 100,
""total_records"": 5
}";
var message = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(responseContent)
Expand Down
9 changes: 5 additions & 4 deletions Source/ZoomNet.UnitTests/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ public static class Utils
{
private const string ZOOM_V2_BASE_URI = "https://api.zoom.us/v2";

public static Pathoschild.Http.Client.IClient GetFluentClient(MockHttpMessageHandler httpMessageHandler)
public static Pathoschild.Http.Client.IClient GetFluentClient(MockHttpMessageHandler httpMessageHandler, MockHttpMessageHandler tokenMessageHandler = null)
{
var httpClient = httpMessageHandler.ToHttpClient();
var client = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpClient);
client.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), null));
var client = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpMessageHandler.ToHttpClient());
var tokenHandler = tokenMessageHandler == null ? null : new OAuthTokenHandler(OAuthConnectionInfo.ForServerToServer("bogus clientId", "bogus secret", "bogus accountId"), tokenMessageHandler.ToHttpClient(), null);

client.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler));
client.Filters.Remove<DefaultErrorFilter>();

// Remove all the built-in formatters and replace them with our custom JSON formatter
Expand Down
39 changes: 39 additions & 0 deletions Source/ZoomNet.UnitTests/WebhookParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,5 +502,44 @@ public void WebinarEnded()
parsedEvent.Webinar.Password.ShouldBeNull();
parsedEvent.Webinar.Settings.ShouldBeNull();
}

public class VerifySignature
{
[Fact]
public void Simple()
{
// Arange
var requestBody = "{\"payload\":{\"plainToken\":\"xys8n8PGS7mAU0m5-YJjRA\"},\"event_ts\":1720705455858,\"event\":\"endpoint.url_validation\"}";
var secretToken = "4fv1RkqGQUq5sWbEz6hA5A";
var signature = "v0=93a1a675965ceb9c5a50c5dfb31f20e50f763be37a54ef74cd2d16a1a8e5c0d6";
var timestamp = "1720705455";

var parser = new WebhookParser();

// Act
var result = parser.VerifySignature(requestBody, secretToken, signature, timestamp);

//Assert
result.ShouldBeTrue();
}

[Fact]
public void Topic_contains_non_ASCII_characters()
{
// Arange
var requestBody = "{\"event\":\"meeting.started\",\"payload\":{\"account_id\":\"VjZoEArIT5y-HlWxkV-tVA\",\"object\":{\"duration\":60,\"start_time\":\"2024-07-11T14:12:55Z\",\"timezone\":\"America/New_York\",\"topic\":\"Test \\uD83D\\uDE92\\uD83D\\uDE92 ? - ’ - – \\uD83D\\uDE97 HOLA\",\"id\":\"85393847045\",\"type\":2,\"uuid\":\"jUh5o3dKQIytvcsfTtKBlg==\",\"host_id\":\"8lzIwvZTSOqjndWPbPqzuA\"}},\"event_ts\":1720707175904}";
var secretToken = "4fv1RkqGQUq5sWbEz6hA5A";
var signature = "v0=1a14e79349318fa1bead50ebbd3c185ae078e182d3bbd30ab8010fcb7f4357c7";
var timestamp = "1720707175";

var parser = new WebhookParser();

// Act
var result = parser.VerifySignature(requestBody, secretToken, signature, timestamp);

//Assert
result.ShouldBeTrue();
}
}
}
}
4 changes: 2 additions & 2 deletions Source/ZoomNet.UnitTests/ZoomNet.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</PackageReference>
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
5 changes: 3 additions & 2 deletions Source/ZoomNet/WebhookParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public bool VerifySignature(string requestBody, string secretToken, string signa
var message = $"v0:{timestamp}:{requestBody}";

// Hash the message
var hmac = new HMACSHA256(Encoding.ASCII.GetBytes(secretToken));
var hashAsBytes = hmac.ComputeHash(Encoding.ASCII.GetBytes(message));
var hashingEncoding = Encoding.UTF8; // Switched from ASCII to UTF8 in July 2024. See https://github.com/Jericho/ZoomNet/issues/349 for more information.
var hmac = new HMACSHA256(hashingEncoding.GetBytes(secretToken));
var hashAsBytes = hmac.ComputeHash(hashingEncoding.GetBytes(message));
var hashAsHex = hashAsBytes.ToHexString();

// Create the signature
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomNet/ZoomNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="4.4.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Websocket.Client" Version="4.6.1" />
</ItemGroup>
Expand Down
18 changes: 10 additions & 8 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Install tools.
#tool dotnet:?package=GitVersion.Tool&version=5.12.0
#tool dotnet:?package=coveralls.net&version=4.0.1
#tool nuget:https://f.feedz.io/jericho/jericho/nuget/?package=GitReleaseManager&version=0.17.0-collaborators0004
#tool nuget:?package=ReportGenerator&version=5.3.5
#tool nuget:?package=xunit.runner.console&version=2.8.1
#tool nuget:https://f.feedz.io/jericho/jericho/nuget/?package=GitReleaseManager&version=0.17.0-collaborators0007
#tool nuget:?package=ReportGenerator&version=5.3.7
#tool nuget:?package=xunit.runner.console&version=2.9.0
#tool nuget:?package=CodecovUploader&version=0.7.3

// Install addins.
#addin nuget:?package=Cake.Coveralls&version=1.1.0
#addin nuget:?package=Cake.Coveralls&version=4.0.0
#addin nuget:?package=Cake.Git&version=4.0.0
#addin nuget:?package=Cake.Codecov&version=3.0.0

Expand Down Expand Up @@ -86,6 +86,8 @@ var isTagged = BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag && !string.
var isIntegrationTestsProjectPresent = FileExists(integrationTestsProject);
var isUnitTestsProjectPresent = FileExists(unitTestsProject);
var isBenchmarkProjectPresent = FileExists(benchmarkProject);
var removeIntegrationTests = isIntegrationTestsProjectPresent && (!isLocalBuild || target == "coverage");
var removeBenchmarks = isBenchmarkProjectPresent && (!isLocalBuild || target == "coverage");

var publishingError = false;

Expand Down Expand Up @@ -162,7 +164,7 @@ Setup(context =>
// Integration tests are intended to be used for debugging purposes and not intended to be executed in CI environment.
// Also, the runner for these tests contains windows-specific code (such as resizing window, moving window to center of screen, etc.)
// which can cause problems when attempting to run unit tests on an Ubuntu image on AppVeyor.
if (!isLocalBuild && isIntegrationTestsProjectPresent)
if (removeIntegrationTests)
{
Information("");
Information("Removing integration tests");
Expand All @@ -172,7 +174,7 @@ Setup(context =>
// Similarly, benchmarking can causes problems similar to this one:
// error NETSDK1005: Assets file '/home/appveyor/projects/stronggrid/Source/StrongGrid.Benchmark/obj/project.assets.json' doesn't have a target for 'net5.0'.
// Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project.
if (!isLocalBuild && isBenchmarkProjectPresent)
if (removeBenchmarks)
{
Information("");
Information("Removing benchmark project");
Expand All @@ -182,7 +184,7 @@ Setup(context =>

Teardown(context =>
{
if (!isLocalBuild)
if (removeIntegrationTests || removeBenchmarks)
{
Information("Restoring projects that may have been removed during build script setup");
GitCheckout(".", new FilePath[] { solutionFile });
Expand Down Expand Up @@ -352,7 +354,7 @@ Task("Generate-Code-Coverage-Report")
new FilePath(coverageFile),
codeCoverageDir,
new ReportGeneratorSettings() {
ClassFilters = new[] { "*.UnitTests*" }
ClassFilters = new[] { "+*" }
}
);
});
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.301",
"version": "8.0.303",
"rollForward": "patch",
"allowPrerelease": false
}
Expand Down

0 comments on commit bbf26d3

Please sign in to comment.