Skip to content

Commit 89f2b85

Browse files
authored
added additional checks to the system test for file permissions in WDT model-only (#299)
1 parent 2da5a21 commit 89f2b85

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -970,31 +970,33 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
970970
// verify the docker image is created
971971
assertTrue(imageExists(tagName), "Image was not created: " + tagName);
972972

973-
validateDirectoryPermissions("/u01/domains", "drwxrwxr-x", tagName, out);
974-
validateDirectoryPermissions("/u01/wdt", "drwxrwxr-x", tagName, out);
975-
validateDirectoryPermissions("/u01/wdt/models", "drwxrwxr-x", tagName, out);
976-
validateDirectoryPermissions("/u01/wdt/weblogic-deploy", "drwxr-x---", tagName, out);
977-
validateDirectoryPermissions("/u01/oracle", "drwxr-xr-x", tagName, out);
973+
validateFilePermissions("/u01/domains", "drwxrwxr-x", tagName, out);
974+
validateFilePermissions("/u01/wdt", "drwxrwxr-x", tagName, out);
975+
validateFilePermissions("/u01/wdt/models", "drwxrwxr-x", tagName, out);
976+
validateFilePermissions("/u01/wdt/weblogic-deploy", "drwxr-x---", tagName, out);
977+
validateFilePermissions("/u01/oracle", "drwxr-xr-x", tagName, out);
978+
validateFilePermissions("/u01/wdt/weblogic-deploy/bin/createDomain.sh", "-rwxr-x---", tagName, out);
979+
validateFilePermissions("/u01/wdt/weblogic-deploy/bin/validateModel.sh", "-rwxr-x---", tagName, out);
978980
}
979981
}
980982

981983
/**
982984
* Verify file permissions for a specified path on the given image.
983-
* @param directory Directory name to check for permissions value.
985+
* @param path Filename or Directory to check for permissions value.
984986
* @param expected Expected permission string, such as "drwxrwxr-x"
985987
* @param tagName Tag name or image ID of the image to inspect
986988
* @param out The printwriter where the docker run command will send stdout/stderr
987989
* @throws IOException if process start fails
988990
* @throws InterruptedException if the wait is interrupted before the process completes
989991
*/
990-
private void validateDirectoryPermissions(String directory, String expected, String tagName, PrintWriter out)
992+
private void validateFilePermissions(String path, String expected, String tagName, PrintWriter out)
991993
throws IOException, InterruptedException {
992-
String command = String.format(" docker run -t %s ls -ld %s", tagName, directory);
994+
String command = String.format(" docker run --rm -t %s ls -ld %s", tagName, path);
993995
String actual = Runner.run(command, out, logger).stdout().trim();
994996
String[] tokens = actual.split(" ", 2);
995-
assertEquals(2, tokens.length, "Unable to get directory permissions for " + directory);
997+
assertEquals(2, tokens.length, "Unable to get file permissions for " + path);
996998
// When running on an SELinux host, the permissions shown by ls will end with a "."
997-
assertTrue(tokens[0].startsWith(expected), "Incorrect directory permissions for " + directory);
999+
assertTrue(tokens[0].startsWith(expected), "Incorrect file permissions for " + path);
9981000
}
9991001

10001002
/**
@@ -1026,6 +1028,8 @@ void updateAddModel(TestInfo testInfo) throws Exception {
10261028

10271029
// verify the docker image is created
10281030
assertTrue(imageExists(tagName), "Image was not created: " + tagName);
1031+
validateFilePermissions("/u01/wdt/weblogic-deploy/bin/createDomain.sh", "-rwxr-x---", tagName, out);
1032+
validateFilePermissions("/u01/wdt/weblogic-deploy/bin/validateModel.sh", "-rwxr-x---", tagName, out);
10291033
}
10301034
}
10311035

0 commit comments

Comments
 (0)