Skip to content

Commit

Permalink
fixes #993 add a test case to generate a bootstrap token for service …
Browse files Browse the repository at this point in the history
…to connect to light-config-server (#994)
  • Loading branch information
stevehu authored Jul 9, 2021
1 parent 644a068 commit a30c1bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions security/src/test/java/com/networknt/security/ClaimsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public static JwtClaims getTestCcClaimsScope(String clientId, String scope) {
return claims;
}

public static JwtClaims getTestCcClaimsScopeService(String clientId, String scope, String serviceId) {
JwtClaims claims = JwtIssuer.getDefaultJwtClaims();
claims.setClaim("client_id", clientId);
claims.setClaim("scope", scope);
claims.setClaim("service", serviceId);
return claims;
}

public static JwtClaims getTestCcClaimsScopeScp(String clientId, String scope) {
JwtClaims claims = JwtIssuer.getDefaultJwtClaims();
claims.setClaim("client_id", clientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,12 @@ public void longlivedCcLocalProxyWithScp() throws Exception {
System.out.println("***Long lived token for proxy***: " + jwt);
}

@Test
public void sidecarReferenceBootstrap() throws Exception {
JwtClaims claims = ClaimsUtil.getTestCcClaimsScopeService("f7d42348-c647-4efb-a52d-4c5787421e72", "portal.r portal.w", "0100");
claims.setExpirationTimeMinutesInTheFuture(5256000);
String jwt = JwtIssuer.getJwt(claims);
System.out.println("***Reference Long lived Bootstrap token for config server and controller: " + jwt);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private Map<String, Object> getServiceConfigs(String configServerPath) {

Map<String, Object> configs = new HashMap<>();

logger.debug("Calling Config Server endpoint:{}{}", configServerUri, configServerPath);
logger.debug("Calling Config Server endpoint:host{}:path{}", configServerUri, configServerPath);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(configServerUri.trim() + configServerPath.trim()))
.header(Headers.AUTHORIZATION_STRING, authorization)
Expand Down

0 comments on commit a30c1bc

Please sign in to comment.