diff --git a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy index eebbb24e..17908149 100644 --- a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy +++ b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy @@ -1,3 +1,9 @@ +// security parameters used as elements: https://issues.redhat.com/browse/WFLY-18324 +stringSubsystemValues = datasources.'@xmlns'.text().tokenize(":")[-1].tokenize(".") +major = stringSubsystemValues[0].toInteger() +minor = stringSubsystemValues[1].toInteger() +securityParamsAsElements = major <= 7 && minor < 2 + // attributes of datasourceAttrs = ['pool-name': poolName] if (nn(jta)) datasourceAttrs['jta'] = jta @@ -44,9 +50,16 @@ def dsDefinition = { } } if (nn(userName, password, securityDomain)) { - security { - if (nn(userName)) 'user-name'(userName) - if (nn(password)) 'password'(password) + securityAttrs = [:] + if (!securityParamsAsElements) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) securityAttrs['user-name'] = userName + if (nn(password)) securityAttrs['password'] = password + } + security(securityAttrs) { + if (securityParamsAsElements) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) 'user-name'(userName) + if (nn(password)) 'password'(password) + } if (nn(securityDomain)) 'security-domain'(securityDomain) } } diff --git a/testsuite/standalone/src/test/java/org/wildfly/extras/creaper/commands/datasources/AddDatasourceOfflineTest.java b/testsuite/standalone/src/test/java/org/wildfly/extras/creaper/commands/datasources/AddDatasourceOfflineTest.java index 5857e1c4..b1b2cade 100644 --- a/testsuite/standalone/src/test/java/org/wildfly/extras/creaper/commands/datasources/AddDatasourceOfflineTest.java +++ b/testsuite/standalone/src/test/java/org/wildfly/extras/creaper/commands/datasources/AddDatasourceOfflineTest.java @@ -39,10 +39,7 @@ public class AddDatasourceOfflineTest { + " \n" + " jdbc:h2:mem:test-creaper;DB_CLOSE_DELAY=-1;\n" + " h2\n" - + " \n" - + " creaper\n" - + " creaper\n" - + " \n" + + " \n" + " \n" + " \n" + " \n" @@ -73,10 +70,7 @@ public class AddDatasourceOfflineTest { + " EntirePool\n" + " true\n" + " \n" - + " \n" - + " creaper\n" - + " creaper\n" - + " \n" + + " \n" + " \n" + " \n" + " ok\n"