Skip to content

Commit

Permalink
Added test cases to validate request status with http status returned
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimms committed Feb 1, 2024
1 parent 81a4735 commit 951a32f
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,33 @@ public async Task TokenIssuanceStartObjectModelTest()
Assert.True(TestHelper.DoesPayloadMatch(Payload.TokenIssuanceStart.ExpectedPayload, httpResponseMessage.Content.ReadAsStringAsync().Result));
}

/// <summary>Test the request object to verify the correct HttpStatusCode is respond</summary>
[Test]
[TestCase(RequestStatusType.Successful, HttpStatusCode.OK)]
[TestCase(RequestStatusType.Failed, HttpStatusCode.BadRequest)]
[TestCase(RequestStatusType.ValidationError, HttpStatusCode.BadRequest)]
[TestCase(RequestStatusType.TokenInvalid, HttpStatusCode.Unauthorized)]
public async Task TokenIssuanceStartRequestValidationTest(RequestStatusType requestStatusType, HttpStatusCode httpStatusCode)
{
HttpResponseMessage httpResponseMessage = await TestHelper.EventResponseBaseTest(eventsResponseHandler =>
{
if (eventsResponseHandler.Request is TokenIssuanceStartRequest request)
{
request.Response.Actions.Add(
new ProvideClaimsForToken(
new TokenClaim("DateOfBirth", "01/01/2000"),
new TokenClaim("CustomRoles", "Writer", "Editor")
));

// set the request status type
request.RequestStatus = requestStatusType;
eventsResponseHandler.SetValueAsync(request.Completed().Result, CancellationToken.None);
}
});

Assert.AreEqual(httpStatusCode, httpResponseMessage.StatusCode);
}

/// <summary>Tests the OnTokenIssuanceStart request and response object model when the response is set to null</summary>
[Test]
[Description("Tests the OnTokenIssuanceStart request and response object model when the response is set to null")]
Expand Down

0 comments on commit 951a32f

Please sign in to comment.