Search in sources :

Example 36 with OutputAnalyzer

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");
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 37 with OutputAnalyzer

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");
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 38 with OutputAnalyzer

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);
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 39 with OutputAnalyzer

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);
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 40 with OutputAnalyzer

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());
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer) File(java.io.File)

Aggregations

OutputAnalyzer (jdk.testlibrary.OutputAnalyzer)54 File (java.io.File)5 JDKToolLauncher (jdk.testlibrary.JDKToolLauncher)5 ArrayList (java.util.ArrayList)4 PortUnreachableException (java.net.PortUnreachableException)1 LocateRegistry (java.rmi.registry.LocateRegistry)1 Registry (java.rmi.registry.Registry)1 KeyStore (java.security.KeyStore)1 X509Certificate (java.security.cert.X509Certificate)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 MissingResourceException (java.util.MissingResourceException)1 ProcessThread (jdk.testlibrary.ProcessThread)1