Skip to content

Commit bfd22df

Browse files
author
Chris Wiechmann
committed
Disabled Update-User tests on API-Manager version before Sept-2020
For more details see ImportExportUserTestIT.java
1 parent d59b93a commit bfd22df

2 files changed

Lines changed: 60 additions & 46 deletions

File tree

modules/apim-adapter/src/test/resources/apimanager/buildDockerImage.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function exitScript() {
1414
echo "`basename $0` 7.7-20200930"
1515
echo "`basename $0` 7.7-20200730"
1616
echo "`basename $0` 7.7-20200530"
17+
echo "`basename $0` 7.7-20200331"
1718
echo "`basename $0` 7.7-20200130"
1819
echo "`basename $0` 7.7-SP2"
1920
echo "`basename $0` 7.6.2-SP5"
@@ -40,7 +41,7 @@ case "$version" in
4041
installer="APIGateway_7.7.20210530_Install_linux-x86-64_BN02.run";;
4142
7.7-20210330)
4243
fedFile="swagger-promote-7.7-20210330.fed"
43-
installer="APIGateway_7.7.20210330_Install_linux-x86-64_BN06.run";;
44+
installer="APIGateway_7.7.20210330_Install_linux-x86-64_BN06.run";;
4445
7.7-20200930)
4546
fedFile="swagger-promote-7.7-20200930.fed"
4647
installer="APIGateway_7.7.20200930_Install_linux-x86-64_BN03.run"

modules/users/src/test/java/com/axway/apim/user/it/tests/ImportExportUserTestIT.java

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.testng.annotations.Parameters;
1010
import org.testng.annotations.Test;
1111

12+
import com.axway.apim.adapter.APIManagerAdapter;
1213
import com.axway.apim.api.model.apps.ClientApplication;
1314
import com.axway.apim.lib.errorHandling.AppException;
1415
import com.axway.apim.user.it.ExportUserTestAction;
@@ -61,50 +62,62 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
6162

6263
echo("####### Try to login with created user #######");
6364
http(builder -> builder.client("apiManager").send().post("/login").payload("username=${loginName}&password=${password}&success=/title").header("Content-Type", "application/x-www-form-urlencoded"));
64-
65-
echo("####### Change some user details #######");
66-
variable("phone", "+1111111111111");
67-
variable("mobile", "+2222222222222");
68-
variable("userCustomProperty1", "Changed custom value 1");
69-
variable("userCustomProperty2", "3");
70-
variable("userCustomProperty3", "false");
71-
importApp.doExecute(context);
72-
73-
echo("####### Validate details of user: '${loginName}' (ID: ${userId}) have changed #######");
74-
http(builder -> builder.client("apiManager").send().get("/users/${userId}").header("Content-Type", "application/json"));
75-
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
76-
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty1", "Changed custom value 1")
77-
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty2", "3")
78-
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty3", "false")
79-
.validate("$.[?(@.loginName=='${loginName}')].phone", "+1111111111111")
80-
.validate("$.[?(@.loginName=='${loginName}')].mobile", "+2222222222222"));
81-
82-
echo("####### Re-Import same user - Should be a No-Change #######");
83-
createVariable(PARAM_EXPECTED_RC, "10");
84-
importApp.doExecute(context);
85-
86-
echo("####### Export the user #######");
87-
variable("targetFolder", "citrus:systemProperty('java.io.tmpdir')");
88-
createVariable(PARAM_TARGET, exportApp.getTestDirectory().getPath());
89-
createVariable(PARAM_LOGINNAME, "${loginName}");
90-
createVariable(PARAM_OUTPUT_FORMAT, "json");
91-
createVariable(PARAM_EXPECTED_RC, "0");
92-
exportApp.doExecute(context);
93-
94-
Assert.assertEquals(exportApp.getLastResult().getExportedFiles().size(), 1, "One exported user is expected.");
95-
String exportedConfig = exportApp.getLastResult().getExportedFiles().get(0);
96-
97-
ClientApplication exportedUser = mapper.readValue(new File(exportedConfig), ClientApplication.class);
98-
99-
Assert.assertNotNull(exportedUser.getCustomProperties(), "Exported user must have custom properties");
100-
Assert.assertEquals(exportedUser.getCustomProperties().size(), 3, "Exported user must have 3 custom properties");
101-
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty1"), "Changed custom value 1");
102-
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty2"), "3");
103-
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty3"), "false");
104-
105-
echo("####### Re-Import EXPORTED user - Should be a No-Change #######");
106-
createVariable(PARAM_CONFIGFILE, exportedConfig);
107-
createVariable("expectedReturnCode", "10");
108-
importApp.doExecute(context);
65+
66+
/*
67+
* The following tests are only executed on newer API Manager versions. On older versions, updating a user fails with the error message:
68+
* {"errors":[{"code":500, "message": "Internal server error"}]}.
69+
* The API Manager reports this in the trace log:
70+
* java.lang.IllegalArgumentException: Cannot refine property with name: orgs2Role, as this property is not defined in the type: API Portal_PortalUsers
71+
* The reason is that the FED file: swagger-promote-7.7-20200130.fed for building the test images of earlier versions did not yet
72+
* include the update of the KPS table PortalUsers.
73+
* So the conclusion is that the CLI code works and there is no problem at this point with the CLI. The effort to update the test images
74+
* is in no relation to the benefit.
75+
*/
76+
if(APIManagerAdapter.hasAPIManagerVersion("7.7.20200930")) {
77+
echo("####### Change some user details #######");
78+
variable("phone", "+1111111111111");
79+
variable("mobile", "+2222222222222");
80+
variable("userCustomProperty1", "Changed custom value 1");
81+
variable("userCustomProperty2", "3");
82+
variable("userCustomProperty3", "false");
83+
importApp.doExecute(context);
84+
85+
echo("####### Validate details of user: '${loginName}' (ID: ${userId}) have changed #######");
86+
http(builder -> builder.client("apiManager").send().get("/users/${userId}").header("Content-Type", "application/json"));
87+
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
88+
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty1", "Changed custom value 1")
89+
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty2", "3")
90+
.validate("$.[?(@.loginName=='${loginName}')].userCustomProperty3", "false")
91+
.validate("$.[?(@.loginName=='${loginName}')].phone", "+1111111111111")
92+
.validate("$.[?(@.loginName=='${loginName}')].mobile", "+2222222222222"));
93+
94+
echo("####### Re-Import same user - Should be a No-Change #######");
95+
createVariable(PARAM_EXPECTED_RC, "10");
96+
importApp.doExecute(context);
97+
98+
echo("####### Export the user #######");
99+
variable("targetFolder", "citrus:systemProperty('java.io.tmpdir')");
100+
createVariable(PARAM_TARGET, exportApp.getTestDirectory().getPath());
101+
createVariable(PARAM_LOGINNAME, "${loginName}");
102+
createVariable(PARAM_OUTPUT_FORMAT, "json");
103+
createVariable(PARAM_EXPECTED_RC, "0");
104+
exportApp.doExecute(context);
105+
106+
Assert.assertEquals(exportApp.getLastResult().getExportedFiles().size(), 1, "One exported user is expected.");
107+
String exportedConfig = exportApp.getLastResult().getExportedFiles().get(0);
108+
109+
ClientApplication exportedUser = mapper.readValue(new File(exportedConfig), ClientApplication.class);
110+
111+
Assert.assertNotNull(exportedUser.getCustomProperties(), "Exported user must have custom properties");
112+
Assert.assertEquals(exportedUser.getCustomProperties().size(), 3, "Exported user must have 3 custom properties");
113+
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty1"), "Changed custom value 1");
114+
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty2"), "3");
115+
Assert.assertEquals(exportedUser.getCustomProperties().get("userCustomProperty3"), "false");
116+
117+
echo("####### Re-Import EXPORTED user - Should be a No-Change #######");
118+
createVariable(PARAM_CONFIGFILE, exportedConfig);
119+
createVariable("expectedReturnCode", "10");
120+
importApp.doExecute(context);
121+
}
109122
}
110123
}

0 commit comments

Comments
 (0)