diff --git a/ballerina-tests/http-interceptor-tests/tests/interceptors_basic_tests.bal b/ballerina-tests/http-interceptor-tests/tests/interceptors_basic_tests.bal index d29c452f88..d3ce85c5a2 100644 --- a/ballerina-tests/http-interceptor-tests/tests/interceptors_basic_tests.bal +++ b/ballerina-tests/http-interceptor-tests/tests/interceptors_basic_tests.bal @@ -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 @@ -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(),