743 if (!signingKeysPresent) { 744 keychain = createFakeCerts(bundleParams); 745 if (keychain != null) { 746 bundleParams.put(SIGNING_KEYCHAIN.getID(), keychain); 747 } 748 } 749 750 boolean valid = bundler.validate(bundleParams); 751 assertTrue(valid); 752 753 File output = bundler.execute(bundleParams, new File(workDir, "JRETest")); 754 System.err.println("Bundle at - " + output); 755 assertNotNull(output); 756 assertTrue(output.exists()); 757 if (signingKeysPresent || keychain != null) { 758 validateSignatures(output); 759 } 760 } 761 762 /** 763 * Verify a match on too many keys doesn't blow things up 764 */ 765 @Test 766 public void testTooManyKeyMatches() { 767 Assume.assumeTrue(MacBaseInstallerBundler.findKey("Developer ID Application:", null, true) != null); 768 Assume.assumeTrue(MacBaseInstallerBundler.findKey("Developer ID Installer:", null, true) != null); 769 assertTrue(MacBaseInstallerBundler.findKey("Developer", null, true) == null); 770 assertTrue(MacBaseInstallerBundler.findKey("A completely bogus key that should never realistically exist unless we are attempting to falsely break the tests", null, true) == null); 771 } 772 773 public void validateSignatures(File appLocation) throws IOException { 774 // shallow validation 775 ProcessBuilder pb = new ProcessBuilder( 776 "codesign", "--verify", 777 "-v", // single verbose 778 appLocation.getCanonicalPath()); 779 IOUtils.exec(pb, true); 780 781 // deep validation 782 pb = new ProcessBuilder( | 743 if (!signingKeysPresent) { 744 keychain = createFakeCerts(bundleParams); 745 if (keychain != null) { 746 bundleParams.put(SIGNING_KEYCHAIN.getID(), keychain); 747 } 748 } 749 750 boolean valid = bundler.validate(bundleParams); 751 assertTrue(valid); 752 753 File output = bundler.execute(bundleParams, new File(workDir, "JRETest")); 754 System.err.println("Bundle at - " + output); 755 assertNotNull(output); 756 assertTrue(output.exists()); 757 if (signingKeysPresent || keychain != null) { 758 validateSignatures(output); 759 } 760 } 761 762 /** 763 * Turn on AppCDS 764 */ 765 @Test 766 public void testAppCDS() throws IOException, ConfigException, UnsupportedPlatformException { 767 Bundler bundler = new MacAppBundler(); 768 769 Map<String, Object> bundleParams = new HashMap<>(); 770 771 // not part of the typical setup, for testing 772 bundleParams.put(BUILD_ROOT.getID(), tmpBase); 773 bundleParams.put(VERBOSE.getID(), true); 774 775 bundleParams.put(APP_NAME.getID(), "AppCDSTest"); 776 bundleParams.put(IDENTIFIER.getID(), "com.example.appcds.Test"); 777 bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources)); 778 bundleParams.put(UNLOCK_COMMERCIAL_FEATURES.getID(), true); 779 bundleParams.put(ENABLE_APP_CDS.getID(), true); 780 781 if (runtimeJdk != null) { 782 bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk); 783 } 784 785 boolean valid = bundler.validate(bundleParams); 786 assertTrue(valid); 787 788 File output = bundler.execute(bundleParams, new File(workDir, "CDSTest")); 789 System.err.println("Bundle at - " + output); 790 assertNotNull(output); 791 assertTrue(output.exists()); 792 } 793 794 /** 795 * Verify a match on too many keys doesn't blow things up 796 */ 797 @Test 798 public void testTooManyKeyMatches() { 799 Assume.assumeTrue(MacBaseInstallerBundler.findKey("Developer ID Application:", null, true) != null); 800 Assume.assumeTrue(MacBaseInstallerBundler.findKey("Developer ID Installer:", null, true) != null); 801 assertTrue(MacBaseInstallerBundler.findKey("Developer", null, true) == null); 802 assertTrue(MacBaseInstallerBundler.findKey("A completely bogus key that should never realistically exist unless we are attempting to falsely break the tests", null, true) == null); 803 } 804 805 public void validateSignatures(File appLocation) throws IOException { 806 // shallow validation 807 ProcessBuilder pb = new ProcessBuilder( 808 "codesign", "--verify", 809 "-v", // single verbose 810 appLocation.getCanonicalPath()); 811 IOUtils.exec(pb, true); 812 813 // deep validation 814 pb = new ProcessBuilder( |