Skip to content

Commit 46a6389

Browse files
author
rathnapandi
committed
- change password
1 parent 8ba5ed2 commit 46a6389

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

modules/apis/src/test/java/com/axway/apim/test/CoreInitializationTestIT.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ public void beforeSuite(TestRunner testRunner) {
6969
String url = "https://" + host + ":" + port + "/api/portal/v1.4";
7070

7171
try {
72-
testRunner.echo("Change password of user for initial setup");
73-
postRequest(url + "/currentuser/changepassword", authorizationHeaderValue);
74-
72+
if (System.getenv("reset_password") != null && System.getenv("reset_password").equalsIgnoreCase("true")) {
73+
testRunner.echo("Change password of user for initial setup");
74+
postRequest(url + "/currentuser/changepassword", authorizationHeaderValue);
75+
format = username + ":" + password;
76+
authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes());
77+
}
7578
String orgName = URLEncoder.encode((String) globalVariables.getVariables().get("orgName"), StandardCharsets.UTF_8);
7679
String response = getRequest(url + "/organizations?field=name&op=eq&value=" + orgName, authorizationHeaderValue);
7780
DocumentContext documentContext = JsonPath.parse(response);
@@ -227,7 +230,7 @@ public String getRequest(String url, String authorizationHeaderValue) {
227230

228231
public void postRequest(String url, String authorizationHeaderValue) throws URISyntaxException {
229232
URI uri = new URIBuilder(url).build();
230-
HttpEntity entity = new StringEntity("newPassword=" + password + "&oldPassword="+DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED);
233+
HttpEntity entity = new StringEntity("newPassword=" + password + "&oldPassword=" + DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED);
231234
HttpPost post = new HttpPost(uri);
232235
post.setEntity(entity);
233236
post.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue);

0 commit comments

Comments
 (0)