Skip to content

Commit

Permalink
Test checkpoint/restore with AES decryption for basicRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
anjumfatima90 committed Jan 23, 2025
1 parent 6215cce commit cbbc169
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 41 deletions.
2 changes: 2 additions & 0 deletions dev/com.ibm.ws.security.registry.basic_fat/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ src: \

fat.project: true

tested.features: checkpoint

# Dependencies may be local bundles (e.g. com.ibm.websphere.javaee.servlet.3.1)
# or binaries from Artifactory (e.g. commons-logging:commons-logging)
# For all project names that match the pattern "*_fat*", dependencies for junit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 IBM Corporation and others.
* Copyright (c) 2011, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,45 +18,58 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assume.assumeTrue;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.ibm.websphere.simplicity.log.Log;
import com.ibm.ws.security.registry.SearchResult;
import com.ibm.ws.security.registry.test.UserRegistryServletConnection;

import componenttest.annotation.CheckpointTest;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.rules.repeater.CheckpointRule;
import componenttest.rules.repeater.CheckpointRule.ServerMode;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.impl.LibertyServerFactory;
import componenttest.vulnerability.LeakedPasswordChecker;

@RunWith(FATRunner.class)
@CheckpointTest(alwaysRun = true)
public class FATTest {
private static final String DEFAULT_CONFIG_FILE = "basic.server.xml.orig";
private static final String ALTERNATE_BASIC_REGISTRY_CONFIG = "alternateBasicRegistry.xml";
private static final String DEFAULT_AES_CONFIG_FILE = "defaultAESBasicRegistry.xml";
private static final String CUSTOM_AES_CONFIG_FILE = "customAESBasicRegistry.xml";
private static final String DEFAULT_HASH_CONFIG_FILE = "defaultHashBasicRegistry.xml";
private static String serverConfigurationFile = DEFAULT_CONFIG_FILE;
private static LibertyServer server = LibertyServerFactory.getLibertyServer("com.ibm.ws.security.registry.basic.fat");
private static LibertyServer server;
private static final Class<?> c = FATTest.class;
private static UserRegistryServletConnection servlet;
private final LeakedPasswordChecker passwordChecker = new LeakedPasswordChecker(server);

@ClassRule
public static CheckpointRule checkpointRule = new CheckpointRule()
.setConsoleLogName(FATTest.class.getSimpleName() + ".log")
.setServerSetup(FATTest::serverSetUp)
.setServerStart(FATTest::serverStart)
.setServerTearDown(FATTest::serverTearDown);

/**
* Updates the sample, which is expected to be at the hard-coded path.
* If this test is failing, check this path is correct.
*/
@BeforeClass
public static void setUp() throws Exception {
public static LibertyServer serverSetUp(ServerMode mode) throws Exception {
server = LibertyServerFactory.getLibertyServer("com.ibm.ws.security.registry.basic.fat");
server.copyFileToLibertyInstallRoot("lib/features", "basicRegistryInternals-1.0.mf");

Log.info(c, "setUp", "Starting the server... (will wait for userRegistry servlet to start)");
Log.info(c, "serverSetUp", "Starting the server... (will wait for userRegistry servlet to start)");
server.addInstalledAppForValidation("userRegistry");
return server;
}

public static void serverStart(ServerMode mode, LibertyServer server) throws Exception {
startServer();
Log.info(c, "setUp", "Creating servlet connection the server");
Log.info(c, "serverStart", "Creating servlet connection the server");
servlet = new UserRegistryServletConnection(server.getHostname(), server.getHttpDefaultPort());
}

Expand All @@ -65,16 +78,15 @@ public static void setUp() throws Exception {
*/
private static void startServer() throws Exception {
Log.info(c, "startServer", "Starting the server...");
server.startServer(c.getName() + ".log");
server.startServer();
assertNotNull("Security service did not report it was ready",
server.waitForStringInLog("CWWKS0008I"));
assertNotNull("The application did not report is was started",
server.waitForStringInLog("CWWKZ0001I"));
}

@AfterClass
public static void tearDown() throws Exception {
Log.info(c, "tearDown", "Stopping the server...");
public static void serverTearDown(ServerMode mode, LibertyServer server) throws Exception {
Log.info(c, "serverTearDown", "Stopping the server...");
server.stopServer();
}

Expand Down Expand Up @@ -249,7 +261,11 @@ private static void setServerConfiguration(LibertyServer server,
Log.info(c, "setServerConfiguration", "setServerConfigurationFile to : " + serverXML);
server.stopServer();
server.setServerConfigurationFile(serverXML);
startServer();
if (CheckpointRule.isActive()) {
server.checkpointRestore();
} else {
startServer();
}
serverConfigurationFile = serverXML;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018,2021 IBM Corporation and others.
Copyright (c) 2018,2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ IBM-API-Package: com.ibm.ws.security.registry; type="ibm-api",
org.osgi.framework; type="internal",
com.ibm.websphere.ras; type="internal"
IBM-Feature-Version: 2
WLP-InstantOn-Enabled: true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018, 2024 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018, 2024 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018 IBM Corporation and others.
Copyright (c) 2018, 2025 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
###############################################################################
com.ibm.ws.logging.trace.specification=*=info=enabled:com.ibm.ws.security.registry.basic.*=all=enabled

bootstrap.include=../testports.properties
bootstrap.include=../testports.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<include location="../fatTestPorts.xml"/>

<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.1</feature>
<feature>appSecurity-3.0</feature>
<feature>servlet-4.0</feature>
<feature>basicRegistryInternals-1.0</feature>
</featureManager>

Expand Down

0 comments on commit cbbc169

Please sign in to comment.