Skip to content

Commit

Permalink
Merge pull request datakaveri#168 from ananjaykumar2/update/rest-assured
Browse files Browse the repository at this point in the history
restAssured configuration upadate
  • Loading branch information
ankitmashu authored Apr 17, 2024
2 parents 6292ac6 + a4b64f4 commit e5fb0cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void beforeAll(ExtensionContext context) {
JsonObject config = fileServerConfig.configLoader(0, vertx);
JsonObject testValues = config.getJsonObject("testValues");
Boolean isSsl = config.getBoolean("ssl");

rsId = testValues.getString("rsId");
openRsId = testValues.getString("openRsId");
openRsGroupId = testValues.getString("openRsGroupId");
Expand All @@ -63,6 +62,7 @@ public void beforeAll(ExtensionContext context) {

JsonObject config2 = fileServerConfig.configLoader(1, vertx);
String authServerHost = config2.getString("authHost");
String audience = config2.getString("audience");

boolean testOnDepl = Boolean.parseBoolean(System.getProperty("intTestDepl"));
if (testOnDepl) {
Expand Down Expand Up @@ -102,7 +102,7 @@ public void beforeAll(ExtensionContext context) {
proxy(proxyHost, Integer.parseInt(proxyPort));
}
logger.info("setting up the tokens");
TokenSetup.setupTokens(authEndpoint, clientId, clientSecret, delegationId);
TokenSetup.setupTokens(authEndpoint, clientId, clientSecret, delegationId,audience);

// Wait for tokens to be available before proceeding
waitForTokens();
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/iudx/file/server/authenticator/TokenSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
public class TokenSetup {
private static final Logger logger = LoggerFactory.getLogger(TokenSetup.class);
private static WebClient webClient;
private static String audience4Admin;

public static void setupTokens(String authEndpoint, String clientId, String clientSecret, String delegationId) {
public static void setupTokens(String authEndpoint, String clientId, String clientSecret, String delegationId, String audience) {
audience4Admin = audience;
// Fetch tokens asynchronously and wait for all completions
CompositeFuture.all(
fetchToken("openResourceToken", authEndpoint, clientId, clientSecret),
Expand Down Expand Up @@ -99,6 +101,7 @@ private static Future<String> fetchToken(String userType, String authEndpoint, S
}
promise.complete(accessToken);
} else {
logger.error("error : "+response.bodyAsString());
promise.fail("Failed to get token. Status code: " + response.statusCode());
}
return Future.succeededFuture();
Expand Down Expand Up @@ -129,7 +132,7 @@ private static JsonObject getPayload(String userType) {
jsonPayload.put("role", "consumer");
break;
case "adminToken":
jsonPayload.put("itemId", "rs.iudx.io");
jsonPayload.put("itemId", audience4Admin);
jsonPayload.put("itemType", "resource_server");
jsonPayload.put("role", "admin");
break;
Expand Down

0 comments on commit e5fb0cc

Please sign in to comment.