Path: blob/master/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java
66644 views
/*1* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Path;24import java.util.List;2526import jdk.jpackage.test.JPackageCommand;27import jdk.jpackage.test.Annotations.Test;28import jdk.jpackage.test.Annotations.Parameter;29import jdk.jpackage.test.AdditionalLauncher;3031/**32* Tests generation of app image with --mac-sign and related arguments. Test will33* generate app image and verify signature of main launcher and app bundle itself.34* This test requires that machine is configured with test certificate for35* "Developer ID Application: jpackage.openjdk.java.net" or alternately36* "Developer ID Application: " + name specified by system property:37* "jpackage.mac.signing.key.user.name"38* in the jpackagerTest keychain (or alternately the keychain specified with39* the system property "jpackage.mac.signing.keychain".40* If this certificate is self-signed, it must have be set to41* always allowe access to this keychain" for user which runs test.42* (If cert is real (not self signed), the do not set trust to allow.)43*/4445/*46* @test47* @summary jpackage with --type app-image --mac-sign48* @library ../helpers49* @library /test/lib50* @library base51* @build SigningBase52* @build SigningCheck53* @build jtreg.SkippedException54* @build jdk.jpackage.test.*55* @build SigningAppImageTest56* @modules jdk.jpackage/jdk.jpackage.internal57* @requires (os.family == "mac")58* @run main/othervm -Xmx512m jdk.jpackage.test.Main59* --jpt-run=SigningAppImageTest60*/61public class SigningAppImageTest {6263@Test64@Parameter("true")65@Parameter("false")66public void test(boolean doSign) throws Exception {67SigningCheck.checkCertificates();6869JPackageCommand cmd = JPackageCommand.helloAppImage();70if (doSign) {71cmd.addArguments("--mac-sign", "--mac-signing-key-user-name",72SigningBase.DEV_NAME, "--mac-signing-keychain",73SigningBase.KEYCHAIN);74}75AdditionalLauncher testAL = new AdditionalLauncher("testAL");76testAL.applyTo(cmd);77cmd.executeAndAssertHelloAppImageCreated();7879Path launcherPath = cmd.appLauncherPath();80SigningBase.verifyCodesign(launcherPath, doSign);8182Path testALPath = launcherPath.getParent().resolve("testAL");83SigningBase.verifyCodesign(testALPath, doSign);8485Path appImage = cmd.outputBundle();86SigningBase.verifyCodesign(appImage, doSign);87if (doSign) {88SigningBase.verifySpctl(appImage, "exec");89}90}91}929394