Skip to content

Commit 012b566

Browse files
author
rathnapandi
committed
- fix oadmin issue
1 parent fbbbe68 commit 012b566

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public class CoreInitializationTestIT extends TestRunnerBeforeSuiteSupport {
5555
@Value("${apiManagerPass}")
5656
private String password;
5757

58+
@Value(("${oadminPassword1}"))
59+
private String orgAdminPassword;
60+
5861
@Autowired
5962
GlobalVariables globalVariables;
6063

@@ -71,7 +74,7 @@ public void beforeSuite(TestRunner testRunner) {
7174
try {
7275
if (System.getenv("reset_password") != null && System.getenv("reset_password").equalsIgnoreCase("true")) {
7376
testRunner.echo("Change password of user for initial setup");
74-
postRequest(url + "/currentuser/changepassword", authorizationHeaderValue);
77+
postRequest(url + "/currentuser/changepassword", authorizationHeaderValue, password);
7578
format = username + ":" + password;
7679
authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes());
7780
}
@@ -172,8 +175,11 @@ public void beforeSuite(TestRunner testRunner) {
172175
testRunner.http(action -> action.client(apiManager).send()
173176
.post("/users/${oadminUserId1}/changepassword/")
174177
.header("Content-Type", "application/x-www-form-urlencoded")
175-
.payload("newPassword=${oadminPassword1}"));
178+
.payload("newPassword="+DEFAULT_PASSWORD));
176179
testRunner.http(action -> action.client(apiManager).receive().response(HttpStatus.NO_CONTENT));
180+
format = username + ":" + DEFAULT_PASSWORD;
181+
authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes());
182+
postRequest(url + "/currentuser/changepassword", authorizationHeaderValue, orgAdminPassword);
177183
}
178184
String appName = (String) globalVariables.getVariables().get("testAppName");
179185
response = getRequest(url + "/applications?field=name&op=eq&value=" + appName, authorizationHeaderValue);
@@ -228,9 +234,9 @@ public String getRequest(String url, String authorizationHeaderValue) {
228234
}
229235
}
230236

231-
public void postRequest(String url, String authorizationHeaderValue) throws URISyntaxException {
237+
public void postRequest(String url, String authorizationHeaderValue, String newPassword) throws URISyntaxException {
232238
URI uri = new URIBuilder(url).build();
233-
HttpEntity entity = new StringEntity("newPassword=" + password + "&oldPassword=" + DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED);
239+
HttpEntity entity = new StringEntity("newPassword=" + newPassword + "&oldPassword=" + DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED);
234240
HttpPost post = new HttpPost(uri);
235241
post.setEntity(entity);
236242
post.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue);

0 commit comments

Comments
 (0)