Skip to content

Commit

Permalink
Add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dilanSachi committed Dec 4, 2023
1 parent dd64d16 commit 03de640
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ service http:InterceptableService /requestInterceptorJwtInformation on new http:

@test:Config{}
function testJwtInformationInRequestContext() returns error? {
reqCtxJwtValues = [];
http:Client jwtClient = check new("https://localhost:" + jwtInformationInReqCtxtTestPort.toString(),
secureSocket = {
cert: common:CERT_FILE
Expand Down Expand Up @@ -602,6 +603,19 @@ function testJwtInformationInRequestContext() returns error? {
test:assertEquals(reqCtxJwtValues[1]["scp"], "admin");
}

@test:Config{}
function testEmptyJwtInformationInRequestContext() returns error? {
reqCtxJwtValues = [];
http:Client jwtClient = check new("https://localhost:" + jwtInformationInReqCtxtTestPort.toString(),
secureSocket = {
cert: common:CERT_FILE
});
http:Response response = check jwtClient->get("/requestInterceptorJwtInformation", {"authorization": "Basic "});
test:assertEquals(response.statusCode, 500);
check common:assertJsonErrorPayload(check response.getJsonPayload(), "no member found for key: JWT_INFORMATION",
"Internal Server Error", 500, "/requestInterceptorJwtInformation", "GET");
}

@test:Config{}
function testJwtInformationDecodeErrorInRequestContext() returns error? {
http:Client jwtClient = check new("https://localhost:" + jwtInformationInReqCtxtTestPort.toString(),
Expand Down

0 comments on commit 03de640

Please sign in to comment.