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

feat: support check_url on VerifyV2 silent auth #540

Merged
merged 1 commit into from
Oct 18, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"request_id": "c11236f4-00bf-4b89-84ba-88b25df97315",
"check_url": "https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect"
}
3 changes: 2 additions & 1 deletion Vonage.Test.Unit/VerifyV2/StartVerification/E2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public async Task StartWhatsAppVerification()

private static void VerifyResponseBody(Result<StartVerificationResponse> response) =>
response.Should()
.BeSuccess(new StartVerificationResponse(new Guid("c11236f4-00bf-4b89-84ba-88b25df97315")));
.BeSuccess(new StartVerificationResponse(new Guid("c11236f4-00bf-4b89-84ba-88b25df97315"),
Maybe<Uri>.None));
}
}
23 changes: 15 additions & 8 deletions Vonage.Test.Unit/VerifyV2/StartVerification/SerializationTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using FluentAssertions;
using Vonage.Common;
using Vonage.Common.Monads;
using Vonage.Common.Test;
using Vonage.Common.Test.Extensions;
using Vonage.VerifyV2.StartVerification;
Expand All @@ -16,19 +16,26 @@ namespace Vonage.Test.Unit.VerifyV2.StartVerification
{
public class SerializationTest
{
private readonly SerializationTestHelper helper;

public SerializationTest() =>
this.helper = new SerializationTestHelper(
typeof(SerializationTest).Namespace,
JsonSerializer.BuildWithSnakeCase());
private readonly SerializationTestHelper helper = new SerializationTestHelper(
typeof(SerializationTest).Namespace,
JsonSerializer.BuildWithSnakeCase());

[Fact]
public void ShouldDeserialize200() =>
this.helper.Serializer
.DeserializeObject<StartVerificationResponse>(this.helper.GetResponseJson())
.Should()
.BeSuccess(success => success.RequestId.Should().Be(new Guid("c11236f4-00bf-4b89-84ba-88b25df97315")));
.BeSuccess(new StartVerificationResponse(new Guid("c11236f4-00bf-4b89-84ba-88b25df97315"),
Maybe<Uri>.None));

[Fact]
public void ShouldDeserialize200WithCheckUrl() =>
this.helper.Serializer
.DeserializeObject<StartVerificationResponse>(this.helper.GetResponseJson())
.Should()
.BeSuccess(new StartVerificationResponse(new Guid("c11236f4-00bf-4b89-84ba-88b25df97315"),
new Uri(
"https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect")));

[Fact]
public void ShouldSerialize() =>
Expand Down
3 changes: 3 additions & 0 deletions Vonage.Test.Unit/Vonage.Test.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,9 @@
<None Update="Data\ApplicationTests\CreateApplicationWithMeetingsCapabilities-response.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="VerifyV2\StartVerification\Data\ShouldDeserialize200WithCheckUrl-response.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="node ../.scripts/init.js"/>
Expand Down
11 changes: 10 additions & 1 deletion Vonage/VerifyV2/StartVerification/StartVerificationResponse.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using System;
using System.Text.Json.Serialization;
using Vonage.Common.Monads;
using Vonage.Common.Serialization;

namespace Vonage.VerifyV2.StartVerification;

/// <summary>
/// Represents a response of a StartVerification request.
/// </summary>
/// <param name="RequestId">The Id of the request.</param>
public record StartVerificationResponse(Guid RequestId);
/// <param name="CheckUrl">URL for Silent Auth Verify workflow completion (only shows if using Silent Auth).</param>
public record StartVerificationResponse(
[property: JsonPropertyOrder(0)] Guid RequestId,
[property: JsonPropertyOrder(1)]
[property: JsonConverter(typeof(MaybeJsonConverter<Uri>))]
[property: JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
Maybe<Uri> CheckUrl);
Loading