Skip to content

Commit daf1a75

Browse files
committed
2 parents a16558d + d790164 commit daf1a75

File tree

2 files changed

+35
-47
lines changed

2 files changed

+35
-47
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiDomain.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@
8686
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainResourceImagePatched;
8787
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podImagePatched;
8888
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
89+
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminConsoleAccessible;
8990
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
9091
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
92+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.startPortForwardProcess;
93+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.stopPortForwardProcess;
9194
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
9295
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCredentials;
9396
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withQuickRetryPolicy;
@@ -158,7 +161,11 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
158161
* the cluster and accessible from all the managed server pods
159162
* Make sure two external NodePort services are created in domain namespace.
160163
* Make sure WebLogic console is accessible through both
161-
* `default-secure` service and `default` service.
164+
* `default-secure` service and `default` service.
165+
*
166+
* Negative test case for when domain resource attribute domain.spec.adminServer.adminChannelPortForwardingEnabled
167+
* is set to false, the WLS admin console can not be accessed using the forwarded port, like
168+
* http://localhost:localPort/console/login/LoginForm.jsp.
162169
*/
163170
@Test
164171
@Order(1)
@@ -168,6 +175,9 @@ void testCreateMiiDomain() {
168175
final String adminServerPodName = domainUid + "-admin-server";
169176
final String managedServerPrefix = domainUid + "-managed-server";
170177
final int replicaCount = 2;
178+
final String hostName = "localhost";
179+
final int adminServerPort = 7001;
180+
final int adminServerSecurePort = 7008;
171181

172182
// Create the repo secret to pull the image
173183
// this secret is used only for non-kind cluster
@@ -191,7 +201,7 @@ void testCreateMiiDomain() {
191201
+ " 'admin-server':\n"
192202
+ " SSL: \n"
193203
+ " Enabled: true \n"
194-
+ " ListenPort: '7008' \n";
204+
+ " ListenPort: '" + adminServerSecurePort + "' \n";
195205
createModelConfigMap(configMapName, yamlString, domainUid);
196206

197207
// create the domain object
@@ -276,6 +286,17 @@ void testCreateMiiDomain() {
276286
verifyCredentials(adminServerPodName, domainNamespace,
277287
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, true);
278288
}
289+
290+
// Test that `kubectl port-foward` is able to forward a local port to default channel port (7001 in this test)
291+
// and default secure channel port (7002 in this test)
292+
// Verify that the WLS admin console can not be accessed using http://localhost:localPort/console/login/LoginForm.jsp
293+
String forwardedPortNo = startPortForwardProcess(hostName, domainNamespace, domainUid, adminServerPort);
294+
verifyAdminConsoleAccessible(domainNamespace, hostName, forwardedPortNo, false, Boolean.FALSE);
295+
296+
forwardedPortNo = startPortForwardProcess(hostName, domainNamespace, domainUid, adminServerSecurePort);
297+
verifyAdminConsoleAccessible(domainNamespace, hostName, forwardedPortNo, true, Boolean.FALSE);
298+
299+
stopPortForwardProcess(domainNamespace);
279300
}
280301

281302
@Test
@@ -807,6 +828,7 @@ private Domain createDomainResourceWithConfigMap(String domainUid,
807828
.value("-Djava.security.egd=file:/dev/./urandom ")))
808829
.adminServer(new AdminServer()
809830
.serverStartState("RUNNING")
831+
.adminChannelPortForwardingEnabled(false)
810832
.serverService(new ServerService()
811833
.annotations(keyValueMap)
812834
.labels(keyValueMap))

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItParameterizedDomain.java

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -396,32 +396,6 @@ void testScaleClustersByPatchingDomainResource(Domain domain) {
396396
}
397397
}
398398

399-
/**
400-
* Negative test case for when domain resource attribute domain.spec.adminServer.adminChannelPortForwardingEnabled
401-
* is set to false, the WLS admin console can not be accessed using the forwarded port, like
402-
* http://localhost:localPort/console/login/LoginForm.jsp
403-
*/
404-
@DisabledIfEnvironmentVariable(named = "OKD", matches = "true")
405-
@Test
406-
@DisplayName("Forward a local port to admin default and default secure channel port "
407-
+ "and verify WLS admin console is not accessible")
408-
void testPortforwardDisabledInMiiDomain() {
409-
Domain domain = createMiiDomainWithMultiClusters(miiDomainUid + "neg", miiDomainNamespace, "negativeTest");
410-
assertDomainNotNull(domain);
411-
412-
String domainUid = domain.getSpec().getDomainUid();
413-
String domainNamespace = domain.getMetadata().getNamespace();
414-
final String hostName = "localhost";
415-
416-
String forwardedPortNo = startPortForwardProcess(hostName, domainNamespace, domainUid, ADMIN_SERVER_PORT);
417-
verifyAdminConsoleAccessible(domainNamespace, hostName, forwardedPortNo, false, Boolean.FALSE);
418-
419-
forwardedPortNo = startPortForwardProcess(hostName, domainNamespace, domainUid, ADMIN_SERVER_SECURE_PORT);
420-
verifyAdminConsoleAccessible(domainNamespace, hostName, forwardedPortNo, true, Boolean.FALSE);
421-
422-
stopPortForwardProcess(domainNamespace);
423-
}
424-
425399
/**
426400
* Scale cluster using REST API for three different type of domains.
427401
* i.e. domain-on-pv, domain-in-image and model-in-image
@@ -923,13 +897,7 @@ public void tearDownAll() {
923897
* @return oracle.weblogic.domain.Domain objects
924898
*/
925899
private static Domain createMiiDomainWithMultiClusters(String domainUid,
926-
String domainNamespace,
927-
String... args) {
928-
929-
boolean adminChannelPortForwardingEnabled = (args.length == 0) ? true : false;
930-
logger.info("Creating a Domain with adminChannelPortForwardingEnabled = {0}",
931-
adminChannelPortForwardingEnabled);
932-
900+
String domainNamespace) {
933901
// admin/managed server name here should match with WDT model yaml file
934902
String adminServerPodName = domainUid + "-" + ADMIN_SERVER_NAME_BASE;
935903

@@ -939,17 +907,15 @@ private static Domain createMiiDomainWithMultiClusters(String domainUid,
939907
createOcirRepoSecret(domainNamespace);
940908

941909
String adminSecretName = "weblogic-credentials";
942-
if (adminChannelPortForwardingEnabled) {
943-
// create secret for admin credentials
944-
logger.info("Creating secret for admin credentials");
945-
createSecretWithUsernamePassword(adminSecretName, domainNamespace,
946-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
947-
948-
// create encryption secret
949-
logger.info("Creating encryption secret");
950-
createSecretWithUsernamePassword(encryptionSecretName, domainNamespace,
951-
"weblogicenc", "weblogicenc");
952-
}
910+
// create secret for admin credentials
911+
logger.info("Creating secret for admin credentials");
912+
createSecretWithUsernamePassword(adminSecretName, domainNamespace,
913+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
914+
915+
// create encryption secret
916+
logger.info("Creating encryption secret");
917+
createSecretWithUsernamePassword(encryptionSecretName, domainNamespace,
918+
"weblogicenc", "weblogicenc");
953919

954920
// construct the cluster list used for domain custom resource
955921
List<Cluster> clusterList = new ArrayList<>();
@@ -994,7 +960,7 @@ private static Domain createMiiDomainWithMultiClusters(String domainUid,
994960
.limits(resourceLimit)))
995961
.adminServer(new AdminServer()
996962
.serverStartState("RUNNING")
997-
.adminChannelPortForwardingEnabled(adminChannelPortForwardingEnabled)
963+
.adminChannelPortForwardingEnabled(true)
998964
.adminService(new AdminService()
999965
.addChannelsItem(new Channel()
1000966
.channelName("default-secure")

0 commit comments

Comments
 (0)