-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
7 changed files
with
741 additions
and
605 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Vonage.Test.Common.Extensions; | ||
using Vonage.VerifyV2.NextWorkflow; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.VerifyV2.NextWorkflow; | ||
|
||
[Trait("Category", "E2E")] | ||
public class E2ETest : E2EBase | ||
{ | ||
[Fact] | ||
public async Task NextWorkflow() | ||
{ | ||
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() | ||
.WithPath("/v2/verify/68c2b32e-55ba-4a8e-b3fa-43b3ae6cd1fb/next_workflow") | ||
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) | ||
.UsingPost()) | ||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)); | ||
await this.Helper.VonageClient.VerifyV2Client.NextWorkflowAsync( | ||
NextWorkflowRequest.Parse(Guid.Parse("68c2b32e-55ba-4a8e-b3fa-43b3ae6cd1fb"))) | ||
.Should() | ||
.BeSuccessAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Vonage.Test.Common.Extensions; | ||
using Vonage.VerifyV2.NextWorkflow; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.VerifyV2.NextWorkflow; | ||
|
||
[Trait("Category", "Request")] | ||
public class RequestTest | ||
{ | ||
[Fact] | ||
public void GetEndpointPath_ShouldReturnApiEndpoint() => | ||
NextWorkflowRequest.Parse(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287")) | ||
.Map(request => request.GetEndpointPath()) | ||
.Should() | ||
.BeSuccess("/v2/verify/f3a065af-ac5a-47a4-8dfe-819561a7a287/next_workflow"); | ||
|
||
[Fact] | ||
public void Parse_ShouldReturnFailure_GivenRequestIsEmpty() => | ||
NextWorkflowRequest.Parse(Guid.Empty) | ||
.Should() | ||
.BeParsingFailure("RequestId cannot be empty."); | ||
|
||
[Fact] | ||
public void Parse_ShouldReturnSuccess() => | ||
NextWorkflowRequest.Parse(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287")) | ||
.Map(request => request.RequestId) | ||
.Should() | ||
.BeSuccess(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Net.Http; | ||
using Vonage.Common.Client; | ||
using Vonage.Common.Monads; | ||
using Vonage.Common.Validation; | ||
|
||
namespace Vonage.VerifyV2.NextWorkflow; | ||
|
||
/// <inheritdoc /> | ||
public readonly struct NextWorkflowRequest : IVonageRequest | ||
{ | ||
private NextWorkflowRequest(Guid requestId) => this.RequestId = requestId; | ||
|
||
/// <summary> | ||
/// ID of the verify request. | ||
/// </summary> | ||
public Guid RequestId { get; internal init; } | ||
|
||
/// <inheritdoc /> | ||
public HttpRequestMessage BuildRequestMessage() => VonageRequestBuilder | ||
.Initialize(HttpMethod.Post, this.GetEndpointPath()) | ||
.Build(); | ||
|
||
/// <inheritdoc /> | ||
public string GetEndpointPath() => $"/v2/verify/{this.RequestId}/next_workflow"; | ||
|
||
/// <summary> | ||
/// Parses the input into a NextWorkflowRequest. | ||
/// </summary> | ||
/// <param name="requestId">The verify request identifier.</param> | ||
/// <returns>A success state with the request if the parsing succeeded. A failure state with an error if it failed.</returns> | ||
public static Result<NextWorkflowRequest> Parse(Guid requestId) => | ||
Result<NextWorkflowRequest> | ||
.FromSuccess(new NextWorkflowRequest(requestId)) | ||
.Map(InputEvaluation<NextWorkflowRequest>.Evaluate) | ||
.Bind(evaluation => evaluation.WithRules(VerifyRequestId)); | ||
|
||
private static Result<NextWorkflowRequest> VerifyRequestId(NextWorkflowRequest request) => | ||
InputValidation.VerifyNotEmpty(request, request.RequestId, nameof(RequestId)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters