Skip to content

Commit 261f49e

Browse files
anpanigrANTARYAMI.PANIGRAHI@ORACLE.COMANTARYAMI.PANIGRAHI@ORACLE.COM
authored
Integration Test to check umask warning on MII/DomainOnPV/DomainInImage (#2550)
* Integration Test to check umask warning on MII/DomainOnPV/DomainInImage Co-authored-by: ANTARYAMI.PANIGRAHI@ORACLE.COM <anpanigr@anpanigr-2.subnet1ad3phx.devweblogicphx.oraclevcn.com> Co-authored-by: ANTARYAMI.PANIGRAHI@ORACLE.COM <anpanigr@anpanigr-1.subnet1ad2phx.devweblogicphx.oraclevcn.com>
1 parent 09f72b4 commit 261f49e

File tree

4 files changed

+127
-2
lines changed

4 files changed

+127
-2
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@
2626
import oracle.weblogic.kubernetes.logging.LoggingFacade;
2727
import oracle.weblogic.kubernetes.utils.ExecResult;
2828
import org.junit.jupiter.api.BeforeAll;
29+
import org.junit.jupiter.api.Disabled;
2930
import org.junit.jupiter.api.DisplayName;
31+
import org.junit.jupiter.api.MethodOrderer;
32+
import org.junit.jupiter.api.Order;
3033
import org.junit.jupiter.api.Test;
34+
import org.junit.jupiter.api.TestMethodOrder;
3135

3236
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
3337
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
@@ -37,6 +41,7 @@
3741
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
3842
import static oracle.weblogic.kubernetes.TestConstants.WDT_BASIC_IMAGE_NAME;
3943
import static oracle.weblogic.kubernetes.TestConstants.WDT_BASIC_IMAGE_TAG;
44+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
4045
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
4146
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
4247
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
@@ -45,8 +50,10 @@
4550
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
4651
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
4752
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
53+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isWebLogicPsuPatchApplied;
4854
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
4955
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployToClusterUsingRest;
56+
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
5057
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
5158
import static oracle.weblogic.kubernetes.utils.ImageUtils.createOcirRepoSecret;
5259
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployHttpIstioGatewayAndVirtualservice;
@@ -62,6 +69,8 @@
6269
import static org.junit.jupiter.api.Assertions.assertNotNull;
6370
import static org.junit.jupiter.api.Assertions.assertTrue;
6471

72+
73+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
6574
@DisplayName("Verify istio enabled WebLogic domain in domainhome-in-image model")
6675
@IntegrationTest
6776
class ItIstioDomainInImage {
@@ -116,6 +125,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
116125
* Deploy a web application thru istio http ingress port using REST api
117126
* Access web application thru istio http ingress port using curl
118127
*/
128+
@Order(1)
119129
@Test
120130
@DisplayName("Create WebLogic domainhome-in-image with istio")
121131
void testIstioDomainHomeInImage() {
@@ -223,6 +233,52 @@ void testIstioDomainHomeInImage() {
223233
logger.info("Application Access URL {0}", url);
224234
boolean checkApp = checkAppUsingHostHeader(url, domainNamespace + ".org");
225235
assertTrue(checkApp, "Failed to access WebLogic application");
236+
237+
}
238+
239+
/**
240+
* Verify that Security Warning Tool does not detect any security warning
241+
* messages on console.
242+
* Ref https://jira.oraclecorp.com/jira/browse/OWLS-92319
243+
* However due to WDT issue, Security warning (related to minimum umask)
244+
* are reported in Console.
245+
*/
246+
247+
@Test
248+
@Order(2)
249+
@Disabled("Disable test based on issues found reported OWLS-92319")
250+
@DisplayName("Verify the Security Warning in domain in image")
251+
void testVerifySecurityWarnings() {
252+
253+
int istioIngressPort = getIstioHttpIngressPort();
254+
255+
logger.info("Istio Ingress Port is {0}", istioIngressPort);
256+
if (isWebLogicPsuPatchApplied()) {
257+
String curlCmd2 = "curl -j -sk --show-error --noproxy '*' "
258+
+ " -H 'Host: " + domainNamespace + ".org'"
259+
+ " --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
260+
+ " --url http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort
261+
+ "/management/weblogic/latest/domainRuntime/domainSecurityRuntime?"
262+
+ "link=none";
263+
264+
ExecResult result = null;
265+
logger.info("curl command {0}", curlCmd2);
266+
result = assertDoesNotThrow(
267+
() -> exec(curlCmd2, true));
268+
269+
if (result.exitValue() == 0) {
270+
logger.info("curl command returned {0}", result.toString());
271+
assertTrue(result.stdout().contains("SecurityValidationWarnings"),
272+
"Could not access the Security Warning Tool page");
273+
assertTrue(!result.stdout().contains("minimum of umask 027"), "umask warning check failed");
274+
logger.info("No minimum umask warning reported");
275+
} else {
276+
assertTrue(false, "Curl command failed to get DomainSecurityRuntime");
277+
}
278+
} else {
279+
logger.info("Skipping Security warning check, since Security Warning tool "
280+
+ " is not available in the WLS Release {0}", WEBLOGIC_IMAGE_TAG);
281+
}
226282
}
227283

228284
private void createDomainResource(String domainUid, String domNamespace, String adminSecretName,

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET;
4545
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4646
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
47+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
4748
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
4849
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
4950
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
@@ -53,9 +54,11 @@
5354
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
5455
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
5556
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
57+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isWebLogicPsuPatchApplied;
5658
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapForDomainCreation;
5759
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployToClusterUsingRest;
5860
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
61+
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
5962
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
6063
import static oracle.weblogic.kubernetes.utils.ImageUtils.createSecretForBaseImages;
6164
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployHttpIstioGatewayAndVirtualservice;
@@ -296,6 +299,33 @@ void testIstioDomainHomeInPv() {
296299
} else {
297300
logger.info("Skipping WebLogic console in WebLogic slim image");
298301
}
302+
303+
if (isWebLogicPsuPatchApplied()) {
304+
String curlCmd2 = "curl -j -sk --show-error --noproxy '*' "
305+
+ " -H 'Host: " + domainNamespace + ".org'"
306+
+ " --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
307+
+ " --url http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort
308+
+ "/management/weblogic/latest/domainRuntime/domainSecurityRuntime?"
309+
+ "link=none";
310+
311+
ExecResult result = null;
312+
logger.info("curl command {0}", curlCmd2);
313+
result = assertDoesNotThrow(
314+
() -> exec(curlCmd2, true));
315+
316+
if (result.exitValue() == 0) {
317+
logger.info("curl command returned {0}", result.toString());
318+
assertTrue(result.stdout().contains("SecurityValidationWarnings"),
319+
"Could not access the Security Warning Tool page");
320+
assertTrue(!result.stdout().contains("minimum of umask 027"), "umask warning check failed");
321+
logger.info("No minimum umask warning reported");
322+
} else {
323+
assertTrue(false, "Curl command failed to get DomainSecurityRuntime");
324+
}
325+
} else {
326+
logger.info("Skipping Security warning check, since Security Warning tool "
327+
+ " is not available in the WLS Release {0}", WEBLOGIC_IMAGE_TAG);
328+
}
299329

300330
Path archivePath = Paths.get(ITTESTS_DIR, "../operator/integration-tests/apps/testwebapp.war");
301331
ExecResult result = null;

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
4242
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
4343
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
44+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
4445
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
4546
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
4647
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -53,10 +54,12 @@
5354
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodIntrospectVersionUpdated;
5455
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodsNotRolled;
5556
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
57+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isWebLogicPsuPatchApplied;
5658
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
5759
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
5860
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployToClusterUsingRest;
5961
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
62+
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
6063
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
6164
import static oracle.weblogic.kubernetes.utils.ImageUtils.createOcirRepoSecret;
6265
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployHttpIstioGatewayAndVirtualservice;
@@ -138,7 +141,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
138141
*/
139142
@Test
140143
@DisplayName("Create WebLogic Domain with mii model with istio")
141-
void testIstioMiiDomainWithDynamicUpdate() {
144+
void testIstioModelInImageDomain() {
142145

143146
// Create the repo secret to pull the image
144147
// this secret is used only for non-kind cluster
@@ -242,7 +245,34 @@ void testIstioMiiDomainWithDynamicUpdate() {
242245
} else {
243246
logger.info("Skipping WebLogic console in WebLogic slim image");
244247
}
245-
248+
249+
if (isWebLogicPsuPatchApplied()) {
250+
String curlCmd2 = "curl -j -sk --show-error --noproxy '*' "
251+
+ " -H 'Host: " + domainNamespace + ".org'"
252+
+ " --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
253+
+ " --url http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort
254+
+ "/management/weblogic/latest/domainRuntime/domainSecurityRuntime?"
255+
+ "link=none";
256+
257+
ExecResult result = null;
258+
logger.info("curl command {0}", curlCmd2);
259+
result = assertDoesNotThrow(
260+
() -> exec(curlCmd2, true));
261+
262+
if (result.exitValue() == 0) {
263+
logger.info("curl command returned {0}", result.toString());
264+
assertTrue(result.stdout().contains("SecurityValidationWarnings"),
265+
"Could not access the Security Warning Tool page");
266+
assertTrue(!result.stdout().contains("minimum of umask 027"), "umask warning check failed");
267+
logger.info("No minimum umask warning reported");
268+
} else {
269+
assertTrue(false, "Curl command failed to get DomainSecurityRuntime");
270+
}
271+
} else {
272+
logger.info("Skipping Security warning check, since Security Warning tool "
273+
+ " is not available in the WLS Release {0}", WEBLOGIC_IMAGE_TAG);
274+
}
275+
246276
Path archivePath = Paths.get(ITTESTS_DIR, "../operator/integration-tests/apps/testwebapp.war");
247277
ExecResult result = null;
248278
result = deployToClusterUsingRest(K8S_NODEPORT_HOST,

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonTestUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
4040
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4141
import static oracle.weblogic.kubernetes.TestConstants.OKD;
42+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
4243
import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource;
4344
import static oracle.weblogic.kubernetes.actions.TestActions.getPodCreationTimestamp;
4445
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
@@ -914,6 +915,14 @@ public static void verifyCommandResultContainsMsg(String command, String expecte
914915
expectedMsg);
915916
}
916917

918+
/**
919+
* Verify if the WebLogic image is patched with psu.
920+
* @return true if the WEBLOGIC_IMAGE_TAG contains the string psu
921+
*/
922+
public static boolean isWebLogicPsuPatchApplied() {
923+
return WEBLOGIC_IMAGE_TAG.contains("psu") ? true : false;
924+
}
925+
917926
/**
918927
* Verify domain status conditions contains the given condition type and message.
919928
*

0 commit comments

Comments
 (0)