Path: blob/master/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java
51315 views
/*1* Copyright (c) 2019, 2021, 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 jdk.jpackage.test.JPackageCommand;25import jdk.jpackage.test.Annotations.Test;2627/**28* Tests generation of app image with --mac-sign and related arguments. Test will29* generate app image and verify signature of main launcher and app bundle itself.30* This test requires that machine is configured with test certificate for31* "Developer ID Application: jpackage.openjdk.java.net" or alternately32* "Developer ID Application: " + name specified by system property:33* "jpackage.mac.signing.key.user.name"34* in the jpackagerTest keychain (or alternately the keychain specified with35* the system property "jpackage.mac.signing.keychain".36* If this certificate is self-signed, it must have be set to37* always allowe access to this keychain" for user which runs test.38* (If cert is real (not self signed), the do not set trust to allow.)39*/4041/*42* @test43* @summary jpackage with --type app-image --mac-sign44* @library ../helpers45* @library /test/lib46* @library base47* @build SigningBase48* @build SigningCheck49* @build jtreg.SkippedException50* @build jdk.jpackage.test.*51* @build SigningAppImageTest52* @modules jdk.jpackage/jdk.jpackage.internal53* @requires (os.family == "mac")54* @run main/othervm -Xmx512m jdk.jpackage.test.Main55* --jpt-run=SigningAppImageTest56*/57public class SigningAppImageTest {5859@Test60public static void test() throws Exception {61SigningCheck.checkCertificates();6263JPackageCommand cmd = JPackageCommand.helloAppImage();64cmd.addArguments("--mac-sign", "--mac-signing-key-user-name",65SigningBase.DEV_NAME, "--mac-signing-keychain",66SigningBase.KEYCHAIN);67cmd.executeAndAssertHelloAppImageCreated();6869Path launcherPath = cmd.appLauncherPath();70SigningBase.verifyCodesign(launcherPath, true);7172Path appImage = cmd.outputBundle();73SigningBase.verifyCodesign(appImage, true);74SigningBase.verifySpctl(appImage, "exec");75}76}777879