Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8180573: Refactor sun/security/tools shell tests to plain java tests #415

Closed
Closed
12 changes: 3 additions & 9 deletions test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

/*
* @test
* @bug 6802846 8172529
* @bug 6802846 8172529 8227758
* @summary jarsigner needs enhanced cert validation(options)
* @library /test/lib
* @run main/timeout=240 ConciseJarsigner
@@ -227,17 +227,11 @@ public static void main(String[] args) throws Exception {
+ "a.jar altchain")
.shouldHaveExitValue(0);

// if ca2 is removed, -certchain still work because altchain is a
// self-signed entry and it is trusted by jarsigner
// if ca2 is removed and cert is imported, -certchain won't work
// because this certificate entry is not trusted
// save ca2.cert for easy replay
kt("-exportcert -file ca2.cert -alias ca2");
kt("-delete -alias ca2");
js("-strict -keystore ks -storepass changeit "
+ "-certchain certchain a.jar altchain")
.shouldHaveExitValue(0);

// if cert is imported, -certchain won't work because this
// certificate entry is not trusted
kt("-importcert -file certchain -alias altchain -noprompt");
js("-strict -keystore ks -storepass changeit "
+ "-certchain certchain a.jar altchain")
2 changes: 1 addition & 1 deletion test/jdk/sun/security/tools/jarsigner/DefaultOptions.java
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ static OutputAnalyzer keytool(String cmd) throws Throwable {
public static void main(String[] args) throws Throwable {
keytool("-genkeypair -dname CN=A -alias a -keyalg rsa")
.shouldHaveExitValue(0);
keytool("-genkeypair -dname CN=CA -alias ca -keyalg rsa")
keytool("-genkeypair -dname CN=CA -alias ca -keyalg rsa -ext bc:c")
.shouldHaveExitValue(0);
keytool("-alias a -certreq -file a.req");
keytool("-alias ca -gencert -infile a.req -outfile a.cert");
2 changes: 1 addition & 1 deletion test/jdk/sun/security/tools/jarsigner/EC.java
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public static void main(String[] args) throws Exception {
Files.write(Path.of("A"), List.of("A"));
JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("A"));

kt("-alias ca -dname CN=ca -keyalg ec -genkey -validity 300")
kt("-alias ca -dname CN=ca -keyalg ec -genkey -validity 300 -ext bc:c")
.shouldHaveExitValue(0);
kt("-alias a -dname CN=a -keyalg ec -genkey")
.shouldHaveExitValue(0);
2 changes: 1 addition & 1 deletion test/jdk/sun/security/tools/jarsigner/OnlyManifest.java
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception {
Files.write(Path.of("manifest"), List.of("Key: Value"));
SecurityTools.jar("cvfm a.jar manifest");

kt("-alias ca -dname CN=ca -genkey -validity 300")
kt("-alias ca -dname CN=ca -genkey -validity 300 -ext bc:c")
.shouldHaveExitValue(0);
kt("-alias a -dname CN=a -genkey -validity 300")
.shouldHaveExitValue(0);