Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/macosx/SigningPackageTest.java
51315 views
1
/*
2
* Copyright (c) 2019, 2021, 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 jdk.jpackage.test.JPackageCommand;
26
import jdk.jpackage.test.PackageTest;
27
import jdk.jpackage.test.PackageType;
28
import jdk.jpackage.test.MacHelper;
29
import jdk.jpackage.test.Annotations.Test;
30
31
/**
32
* Tests generation of dmg and pkg with --mac-sign and related arguments.
33
* Test will generate pkg and verifies its signature. It verifies that dmg
34
* is not signed, but app image inside dmg is signed. This test requires that
35
* the machine is configured with test certificate for
36
* "Developer ID Installer: jpackage.openjdk.java.net" in
37
* jpackagerTest keychain with
38
* always allowed access to this keychain for user which runs test.
39
* note:
40
* "jpackage.openjdk.java.net" can be over-ridden by systerm property
41
* "jpackage.mac.signing.key.user.name", and
42
* "jpackagerTest" can be over-ridden by system property
43
* "jpackage.mac.signing.keychain"
44
*/
45
46
/*
47
* @test
48
* @summary jpackage with --type pkg,dmg --mac-sign
49
* @library ../helpers
50
* @library /test/lib
51
* @library base
52
* @key jpackagePlatformPackage
53
* @build SigningBase
54
* @build SigningCheck
55
* @build jtreg.SkippedException
56
* @build jdk.jpackage.test.*
57
* @build SigningPackageTest
58
* @modules jdk.jpackage/jdk.jpackage.internal
59
* @requires (os.family == "mac")
60
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
61
* --jpt-run=SigningPackageTest
62
*/
63
public class SigningPackageTest {
64
65
private static void verifyPKG(JPackageCommand cmd) {
66
Path outputBundle = cmd.outputBundle();
67
SigningBase.verifyPkgutil(outputBundle);
68
SigningBase.verifySpctl(outputBundle, "install");
69
}
70
71
private static void verifyDMG(JPackageCommand cmd) {
72
Path outputBundle = cmd.outputBundle();
73
SigningBase.verifyCodesign(outputBundle, false);
74
}
75
76
private static void verifyAppImageInDMG(JPackageCommand cmd) {
77
MacHelper.withExplodedDmg(cmd, dmgImage -> {
78
Path launcherPath = dmgImage.resolve(Path.of("Contents", "MacOS", cmd.name()));
79
SigningBase.verifyCodesign(launcherPath, true);
80
SigningBase.verifyCodesign(dmgImage, true);
81
SigningBase.verifySpctl(dmgImage, "exec");
82
});
83
}
84
85
@Test
86
public static void test() throws Exception {
87
SigningCheck.checkCertificates();
88
89
new PackageTest()
90
.configureHelloApp()
91
.forTypes(PackageType.MAC)
92
.addInitializer(cmd -> {
93
cmd.addArguments("--mac-sign",
94
"--mac-signing-key-user-name", SigningBase.DEV_NAME,
95
"--mac-signing-keychain", SigningBase.KEYCHAIN);
96
})
97
.forTypes(PackageType.MAC_PKG)
98
.addBundleVerifier(SigningPackageTest::verifyPKG)
99
.forTypes(PackageType.MAC_DMG)
100
.addBundleVerifier(SigningPackageTest::verifyDMG)
101
.addBundleVerifier(SigningPackageTest::verifyAppImageInDMG)
102
.run();
103
}
104
}
105
106