Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,25 +246,32 @@ public void testEncryptedPassword() throws Exception {
return;
}

SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource(
JavaUtils.isFIPSEnabled()
? "client-fips.xml" : "client.xml");

Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);

URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPasswordPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
assertEquals(50, port.doubleIt(25));

((java.io.Closeable)port).close();
bus.shutdown(true);
try {
if (!JavaUtils.isFIPSEnabled()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coheigea may I suggest please to have two independent test runs in Maven, non-FIPs as defaut:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <systemPropertyVariables>
<org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm>true</org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
</plugin>

And FIPS one:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>

                    <execution>
                        <id>fips-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm>false</org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

More than happy to help with that, it is very difficult to eliminate side effects of system properties in tests, thank you.

System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true");
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ActionTest.class.getResource(
JavaUtils.isFIPSEnabled()
? "client-fips.xml" : "client.xml");

Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);

URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPasswordPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
assertEquals(50, port.doubleIt(25));

((java.io.Closeable)port).close();
bus.shutdown(true);
} finally {
System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm");
}
}

@org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ public static void startServers() throws Exception {
// set this to false to fork
launchServer(ModifiedRequestServer.class, true)
);
if (!JavaUtils.isFIPSEnabled()) {
System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true");
}
}

@org.junit.AfterClass
public static void cleanup() throws Exception {
stopAllServers();
System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm");
}

@org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,33 +845,41 @@ public void testAsymmetricEncryptedPassword() throws Exception {
return;
}

SpringBusFactory bf = new SpringBusFactory();
URL busFile = X509TokenTest.class.getResource(
JavaUtils.isFIPSEnabled()
? "client-fips.xml"
: "client.xml");
try {
if (!JavaUtils.isFIPSEnabled()) {
System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true");
}

Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
SpringBusFactory bf = new SpringBusFactory();
URL busFile = X509TokenTest.class.getResource(
JavaUtils.isFIPSEnabled()
? "client-fips.xml"
: "client.xml");

Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);

URL wsdl = X509TokenTest.class.getResource(JavaUtils.isFIPSEnabled()
? "DoubleItX509-fips.wsdl"
: "DoubleItX509.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptedPasswordPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(x509Port, test.getPort());

if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(x509Port);
}

URL wsdl = X509TokenTest.class.getResource(JavaUtils.isFIPSEnabled()
? "DoubleItX509-fips.wsdl"
: "DoubleItX509.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptedPasswordPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(x509Port, test.getPort());
assertEquals(50, x509Port.doubleIt(25));

if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(x509Port);
((java.io.Closeable)x509Port).close();
bus.shutdown(true);
} finally {
System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm");
}

assertEquals(50, x509Port.doubleIt(25));

((java.io.Closeable)x509Port).close();
bus.shutdown(true);
}

@org.junit.Test
Expand Down
Loading