Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/tools/jpackage/macosx/SigningAppImageTest.java
66644 views
1
/*
2
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.nio.file.Path;
25
import java.util.List;
26
27
import jdk.jpackage.test.JPackageCommand;
28
import jdk.jpackage.test.Annotations.Test;
29
import jdk.jpackage.test.Annotations.Parameter;
30
import jdk.jpackage.test.AdditionalLauncher;
31
32
/**
33
* Tests generation of app image with --mac-sign and related arguments. Test will
34
* generate app image and verify signature of main launcher and app bundle itself.
35
* This test requires that machine is configured with test certificate for
36
* "Developer ID Application: jpackage.openjdk.java.net" or alternately
37
* "Developer ID Application: " + name specified by system property:
38
* "jpackage.mac.signing.key.user.name"
39
* in the jpackagerTest keychain (or alternately the keychain specified with
40
* the system property "jpackage.mac.signing.keychain".
41
* If this certificate is self-signed, it must have be set to
42
* always allowe access to this keychain" for user which runs test.
43
* (If cert is real (not self signed), the do not set trust to allow.)
44
*/
45
46
/*
47
* @test
48
* @summary jpackage with --type app-image --mac-sign
49
* @library ../helpers
50
* @library /test/lib
51
* @library base
52
* @build SigningBase
53
* @build SigningCheck
54
* @build jtreg.SkippedException
55
* @build jdk.jpackage.test.*
56
* @build SigningAppImageTest
57
* @modules jdk.jpackage/jdk.jpackage.internal
58
* @requires (os.family == "mac")
59
* @run main/othervm -Xmx512m jdk.jpackage.test.Main
60
* --jpt-run=SigningAppImageTest
61
*/
62
public class SigningAppImageTest {
63
64
@Test
65
@Parameter("true")
66
@Parameter("false")
67
public void test(boolean doSign) throws Exception {
68
SigningCheck.checkCertificates();
69
70
JPackageCommand cmd = JPackageCommand.helloAppImage();
71
if (doSign) {
72
cmd.addArguments("--mac-sign", "--mac-signing-key-user-name",
73
SigningBase.DEV_NAME, "--mac-signing-keychain",
74
SigningBase.KEYCHAIN);
75
}
76
AdditionalLauncher testAL = new AdditionalLauncher("testAL");
77
testAL.applyTo(cmd);
78
cmd.executeAndAssertHelloAppImageCreated();
79
80
Path launcherPath = cmd.appLauncherPath();
81
SigningBase.verifyCodesign(launcherPath, doSign);
82
83
Path testALPath = launcherPath.getParent().resolve("testAL");
84
SigningBase.verifyCodesign(testALPath, doSign);
85
86
Path appImage = cmd.outputBundle();
87
SigningBase.verifyCodesign(appImage, doSign);
88
if (doSign) {
89
SigningBase.verifySpctl(appImage, "exec");
90
}
91
}
92
}
93
94