use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class NotYetValidCertTest method start.
protected void start() throws Throwable {
// create a jar file that contains one class file
Utils.createFiles(FIRST_FILE);
JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
// create certificate that will be valid only tomorrow
ProcessTools.executeCommand(KEYTOOL, "-genkey", "-alias", KEY_ALIAS, "-keyalg", KEY_ALG, "-keysize", Integer.toString(KEY_SIZE), "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, "-dname", "CN=Test", "-startdate", "+1d", "-validity", Integer.toString(VALIDITY));
// sign jar
OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER, "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, "-signedjar", SIGNED_JARFILE, UNSIGNED_JARFILE, KEY_ALIAS);
checkSigning(analyzer, NOT_YET_VALID_CERT_SIGNING_WARNING);
// verify signed jar
analyzer = ProcessTools.executeCommand(JARSIGNER, "-verify", "-verbose", "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, SIGNED_JARFILE, KEY_ALIAS);
checkVerifying(analyzer, 0, NOT_YET_VALID_CERT_VERIFYING_WARNING);
// verify jar in strict mode
analyzer = ProcessTools.executeCommand(JARSIGNER, "-verify", "-verbose", "-strict", "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, SIGNED_JARFILE, KEY_ALIAS);
checkVerifying(analyzer, HAS_EXPIRED_CERT_EXIT_CODE, NOT_YET_VALID_CERT_VERIFYING_WARNING);
System.out.println("Test passed");
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class BadExtendedKeyUsageTest method start.
private void start() throws Throwable {
// create a jar file that contains one class file
Utils.createFiles(FIRST_FILE);
JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
// create a certificate whose signer certificate's
// ExtendedKeyUsage extension doesn't allow code signing
ProcessTools.executeCommand(KEYTOOL, "-genkey", "-alias", KEY_ALIAS, "-keyalg", KEY_ALG, "-keysize", Integer.toString(KEY_SIZE), "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, "-dname", "CN=Test", "-ext", "ExtendedkeyUsage=serverAuth", "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
// sign jar
OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER, "-verbose", "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, "-signedjar", SIGNED_JARFILE, UNSIGNED_JARFILE, KEY_ALIAS);
checkSigning(analyzer, BAD_EXTENDED_KEY_USAGE_SIGNING_WARNING);
// verify signed jar
analyzer = ProcessTools.executeCommand(JARSIGNER, "-verify", "-verbose", "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, SIGNED_JARFILE);
checkVerifying(analyzer, 0, BAD_EXTENDED_KEY_USAGE_VERIFYING_WARNING);
// verity signed jar in strict mode
analyzer = ProcessTools.executeCommand(JARSIGNER, "-verify", "-verbose", "-strict", "-keystore", KEYSTORE, "-storepass", PASSWORD, "-keypass", PASSWORD, SIGNED_JARFILE);
checkVerifying(analyzer, BAD_EXTENDED_KEY_USAGE_EXIT_CODE, BAD_EXTENDED_KEY_USAGE_VERIFYING_WARNING);
System.out.println("Test passed");
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJcmdDefaults method testJcmdDefaults.
/**
* jcmd -J-XX:+UsePerfData
* jcmd -J-XX:+UsePerfData -l
*/
private static void testJcmdDefaults(String... jcmdArgs) throws Exception {
OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs);
output.shouldHaveExitValue(0);
output.shouldContain("sun.tools.jcmd.JCmd");
matchListedProcesses(output);
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJcmdDefaults method testJcmdUsage.
/**
* jcmd -J-XX:+UsePerfData -h
* jcmd -J-XX:+UsePerfData -help
*/
private static void testJcmdUsage(String... jcmdArgs) throws Exception {
OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs);
assertNotEquals(output.getExitValue(), 0);
verifyOutputAgainstFile(output);
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJcmdSanity method testJcmdPidBigScript.
/**
* Tests that it possible send a file over 1024 bytes large via jcmd -f.
*
* jcmd -J-XX:+UsePerfData pid -f dcmd-big-script.txt
*/
private static void testJcmdPidBigScript() throws Exception {
File scrpitFile = new File(TEST_SRC, "dcmd-big-script.txt");
OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, new String[] { "-f", scrpitFile.getAbsolutePath() });
output.shouldHaveExitValue(0);
output.shouldNotContain("Exception");
output.shouldContain(System.getProperty("java.vm.name").trim());
}
Aggregations