Skip to content
Permalink
Browse files
8180573: Refactor sun/security/tools shell tests to plain java tests
Reviewed-by: mdoerr
Backport-of: 15aae2f
  • Loading branch information
RealCLanger committed Oct 5, 2021
1 parent 2b9261a commit efef574b741a49755ee6a95ad46c205012dd52f0
Showing with 2,519 additions and 2,969 deletions.
  1. +96 −0 test/jdk/sun/security/tools/jarsigner/AlgOptions.java
  2. +0 −224 test/jdk/sun/security/tools/jarsigner/AlgOptions.sh
  3. +88 −0 test/jdk/sun/security/tools/jarsigner/CertPolicy.java
  4. +99 −0 test/jdk/sun/security/tools/jarsigner/CheckUsage.java
  5. +60 −0 test/jdk/sun/security/tools/jarsigner/Collator.java
  6. +271 −0 test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java
  7. +61 −0 test/jdk/sun/security/tools/jarsigner/Crl.java
  8. +87 −0 test/jdk/sun/security/tools/jarsigner/DefaultOptions.java
  9. +90 −0 test/jdk/sun/security/tools/jarsigner/DiffEnd.java
  10. +92 −0 test/jdk/sun/security/tools/jarsigner/EC.java
  11. +62 −0 test/jdk/sun/security/tools/jarsigner/EmptyManifest.java
  12. +2 −2 test/jdk/sun/security/tools/jarsigner/EntriesOrder.java
  13. +60 −0 test/jdk/sun/security/tools/jarsigner/JvIndex.java
  14. +58 −0 test/jdk/sun/security/tools/jarsigner/NameClash.java
  15. +66 −0 test/jdk/sun/security/tools/jarsigner/NewSize7.java
  16. +51 −0 test/jdk/sun/security/tools/jarsigner/OldSig.java
  17. +69 −0 test/jdk/sun/security/tools/jarsigner/OnlyManifest.java
  18. +1 −1 test/jdk/sun/security/tools/jarsigner/Options.java
  19. +94 −0 test/jdk/sun/security/tools/jarsigner/PassType.java
  20. +49 −0 test/jdk/sun/security/tools/jarsigner/PercentSign.java
  21. +0 −79 test/jdk/sun/security/tools/jarsigner/PercentSign.sh
  22. +56 −0 test/jdk/sun/security/tools/jarsigner/SameName.java
  23. +69 −0 test/jdk/sun/security/tools/jarsigner/WeakSize.java
  24. +0 −80 test/jdk/sun/security/tools/jarsigner/certpolicy.sh
  25. +0 −109 test/jdk/sun/security/tools/jarsigner/checkusage.sh
  26. +0 −74 test/jdk/sun/security/tools/jarsigner/collator.sh
  27. +0 −247 test/jdk/sun/security/tools/jarsigner/concise_jarsigner.sh
  28. +0 −71 test/jdk/sun/security/tools/jarsigner/crl.sh
  29. +0 −68 test/jdk/sun/security/tools/jarsigner/default_options.sh
  30. +0 −110 test/jdk/sun/security/tools/jarsigner/diffend.sh
  31. +0 −83 test/jdk/sun/security/tools/jarsigner/ec.sh
  32. +0 −76 test/jdk/sun/security/tools/jarsigner/emptymanifest.sh
  33. +0 −74 test/jdk/sun/security/tools/jarsigner/jvindex.sh
  34. +0 −65 test/jdk/sun/security/tools/jarsigner/nameclash.sh
  35. +0 −73 test/jdk/sun/security/tools/jarsigner/newsize7.sh
  36. +0 −79 test/jdk/sun/security/tools/jarsigner/oldsig.sh
  37. +0 −70 test/jdk/sun/security/tools/jarsigner/onlymanifest.sh
  38. +0 −76 test/jdk/sun/security/tools/jarsigner/passtype.sh
  39. +0 −61 test/jdk/sun/security/tools/jarsigner/samename.sh
  40. +0 −62 test/jdk/sun/security/tools/jarsigner/weaksize.sh
  41. +71 −0 test/jdk/sun/security/tools/keytool/CloneKeyAskPassword.java
  42. +0 −94 test/jdk/sun/security/tools/keytool/CloneKeyAskPassword.sh
  43. +109 −0 test/jdk/sun/security/tools/keytool/DefaultOptions.java
  44. +86 −0 test/jdk/sun/security/tools/keytool/EmptySubject.java
  45. +42 −0 test/jdk/sun/security/tools/keytool/FileInHelp.java
  46. +50 −0 test/jdk/sun/security/tools/keytool/ImportReadAll.java
  47. +54 −0 test/jdk/sun/security/tools/keytool/KeyAlg.java
  48. +42 −0 test/jdk/sun/security/tools/keytool/NewHelp.java
  49. +41 −0 test/jdk/sun/security/tools/keytool/NoExtNPE.java
  50. +0 −75 test/jdk/sun/security/tools/keytool/NoExtNPE.sh
  51. +39 −0 test/jdk/sun/security/tools/keytool/Resource.java
  52. +43 −0 test/jdk/sun/security/tools/keytool/SecretKeyKS.java
  53. +0 −73 test/jdk/sun/security/tools/keytool/SecretKeyKS.sh
  54. +61 −0 test/jdk/sun/security/tools/keytool/SecurityToolsTest.java
  55. +67 −0 test/jdk/sun/security/tools/keytool/SelfIssued.java
  56. +81 −0 test/jdk/sun/security/tools/keytool/StandardAlgName.java
  57. +0 −94 test/jdk/sun/security/tools/keytool/StandardAlgName.sh
  58. +48 −1 test/jdk/sun/security/tools/keytool/StorePasswords.java
  59. +0 −132 test/jdk/sun/security/tools/keytool/StorePasswordsByShell.sh
  60. +53 −0 test/jdk/sun/security/tools/keytool/TryStore.java
  61. +0 −99 test/jdk/sun/security/tools/keytool/default_options.sh
  62. +0 −68 test/jdk/sun/security/tools/keytool/emptysubject.sh
  63. +0 −54 test/jdk/sun/security/tools/keytool/file-in-help.sh
  64. +1 −7 test/jdk/sun/security/tools/keytool/i18n.html
  65. +16 −5 test/jdk/sun/security/tools/keytool/i18n.java
  66. +0 −73 test/jdk/sun/security/tools/keytool/i18n.sh
  67. +0 −62 test/jdk/sun/security/tools/keytool/importreadall.sh
  68. +0 −49 test/jdk/sun/security/tools/keytool/keyalg.sh
  69. +0 −54 test/jdk/sun/security/tools/keytool/newhelp.sh
  70. +0 −72 test/jdk/sun/security/tools/keytool/resource.sh
  71. +0 −71 test/jdk/sun/security/tools/keytool/selfissued.sh
  72. +0 −65 test/jdk/sun/security/tools/keytool/trystore.sh
  73. +34 −37 test/lib/jdk/test/lib/SecurityTools.java
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 5094028 6219522
* @summary test new jarsigner -sigalg and -digestalg options
* @author Sean Mullan
* @library /test/lib
*/

import jdk.test.lib.SecurityTools;
import jdk.test.lib.process.OutputAnalyzer;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

public class AlgOptions {
public static void main(String[] args) throws Exception {

// copy jar file into writeable location
Files.copy(Path.of(System.getProperty("test.src"), "AlgOptions.jar"),
Path.of("AlgOptionsTmp.jar"));

// test missing signature algorithm arg
sign("-sigalg").shouldNotHaveExitValue(0);

// test missing digest algorithm arg
sign("-digestalg").shouldNotHaveExitValue(0);

// test BOGUS signature algorithm
sign("-sigalg", "BOGUS").shouldNotHaveExitValue(0);

// test BOGUS digest algorithm
sign("-digestalg", "BOGUS").shouldNotHaveExitValue(0);

// test incompatible signature algorithm
sign("-sigalg", "SHA1withDSA").shouldNotHaveExitValue(0);

// test compatible signature algorithm
sign("-sigalg", "SHA512withRSA").shouldHaveExitValue(0);
verify();

// test non-default digest algorithm
sign("-digestalg", "SHA-1").shouldHaveExitValue(0);
verify();

// test SHA-512 digest algorithm (creates long lines)
sign("-digestalg", "SHA-512", "-sigalg", "SHA512withRSA")
.shouldHaveExitValue(0);
verify();
}

static OutputAnalyzer sign(String... options) throws Exception {
List<String> args = new ArrayList<>();
args.add("-keystore");
args.add(Path.of(System.getProperty("test.src"), "JarSigning.keystore")
.toString());
args.add("-storepass");
args.add("bbbbbb");
for (String option : options) {
args.add(option);
}
args.add("AlgOptionsTmp.jar");
args.add("c");
return SecurityTools.jarsigner(args);
}

static void verify() throws Exception {
SecurityTools.jarsigner(
"-verify", "AlgOptionsTmp.jar")
.shouldHaveExitValue(0);
}
}

This file was deleted.

Loading

1 comment on commit efef574

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on efef574 Oct 5, 2021

Please sign in to comment.