Skip to content

Commit

Permalink
Merge pull request wso2#21034 from Shenali-SJ/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ashanthamara committed Sep 3, 2024
2 parents 9ca4d9e + 5148d37 commit 8b6aaf3
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -229,10 +230,11 @@ public void testTokenStringArrayClaimAddOperation()
@Test(groups = "wso2.is", description = "Verify the replacement of the 'expires_in' claim in the access token")
public void testTokenExpiresInClaimReplaceOperation() throws Exception {

if (jwtClaims.getClaim("expires_in") != null) {
Object expValue = jwtClaims.getLongClaim("expires_in");
Assert.assertEquals(expValue, 7200);
}
Date exp = jwtClaims.getDateClaim("exp");
Date iat = jwtClaims.getDateClaim("iat");
long expiresIn = (exp.getTime() - iat.getTime()) / 1000;

Assert.assertEquals(expiresIn, 7200);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,92 +35,97 @@ public static void createMockServer(String mockEndpoint) throws Exception {
String jsonResponse = "{\n" +
" \"actionStatus\": \"SUCCESS\",\n" +
" \"operations\": [\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_1\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_2\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_3\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz1.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz2.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz3.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_string_1\",\n" +
" \"value\": \"testCustomClaim1\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_number_1\",\n" +
" \"value\": 78\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_boolean_1\",\n" +
" \"value\": true\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_string_array_1\",\n" +
" \"value\": [\n" +
" \"TestCustomClaim1\",\n" +
" \"TestCustomClaim2\",\n" +
" \"TestCustomClaim3\"\n" +
" ]\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"replace\",\n" +
" \"path\": \"/accessToken/scopes/7\",\n" +
" \"value\": \"replaced_scope\"\n" +
" },\n" +
" {\n" +
" \"op\": \"replace\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzzR.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"remove\",\n" +
" \"path\": \"/accessToken/scopes/6\"\n" +
" },\n" +
" {\n" +
" \"op\": \"remove\",\n" +
" \"path\": \"/accessToken/claims/aud/-\"\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_1\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_2\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/scopes/-\",\n" +
" \"value\": \"new_test_custom_scope_3\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz1.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz2.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzz3.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_string_1\",\n" +
" \"value\": \"testCustomClaim1\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_number_1\",\n" +
" \"value\": 78\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_boolean_1\",\n" +
" \"value\": true\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"add\",\n" +
" \"path\": \"/accessToken/claims/-\",\n" +
" \"value\": {\n" +
" \"name\": \"custom_claim_string_array_1\",\n" +
" \"value\": [\n" +
" \"TestCustomClaim1\",\n" +
" \"TestCustomClaim2\",\n" +
" \"TestCustomClaim3\"\n" +
" ]\n" +
" }\n" +
" },\n" +
" {\n" +
" \"op\": \"replace\",\n" +
" \"path\": \"/accessToken/scopes/7\",\n" +
" \"value\": \"replaced_scope\"\n" +
" },\n" +
" {\n" +
" \"op\": \"replace\",\n" +
" \"path\": \"/accessToken/claims/aud/-\",\n" +
" \"value\": \"zzzR.com\"\n" +
" },\n" +
" {\n" +
" \"op\": \"replace\",\n" +
" \"path\": \"/accessToken/claims/expires_in\",\n" +
" \"value\": 7200\n" +
" },\n" +
" {\n" +
" \"op\": \"remove\",\n" +
" \"path\": \"/accessToken/scopes/6\"\n" +
" },\n" +
" {\n" +
" \"op\": \"remove\",\n" +
" \"path\": \"/accessToken/claims/aud/-\"\n" +
" }\n" +
" ]\n" +
"}\n";
" }";

// TODO: Handle status codes related to different scenarios
wireMockServer.stubFor(post(urlEqualTo(mockEndpoint))
Expand Down

0 comments on commit 8b6aaf3

Please sign in to comment.