cstamas commented on code in PR #305:
URL: https://github.com/apache/maven-gpg-plugin/pull/305#discussion_r2569589458
##########
src/test/java/org/apache/maven/plugins/gpg/BcSignerTest.java:
##########
@@ -78,4 +83,83 @@ void testAgent() throws Exception {
signer.setInteractive(false);
signer.prepare();
}
+
+ @Test
+ void testSingleKeyFromConf() throws NoLocalRepositoryManagerException,
MojoFailureException {
+ DefaultRepositorySystemSession session = new
DefaultRepositorySystemSession();
+ session.setLocalRepositoryManager(new
SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer())
+ .newInstance(session, new
LocalRepository("target/local-repo")));
+ BcSigner signer = new BcSigner(
+ session,
+ "unimportant",
+ "unimportant",
+ "undefined",
+ new
File("src/test/resources/signing-key.asc").getAbsolutePath(),
+ "583C18F38D66BE2A3833548F8E3F6C0F255684D1"); // fingerprint
only contained key
+ signer.setPassPhrase("TEST");
+ signer.setUseAgent(false);
+ signer.setInteractive(false);
+ signer.prepare();
+ // check key algorithm, must be ElGamal
+ assertEquals(PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT,
signer.secretKey.getPublicKey().getAlgorithm());
+ }
+
+ @Test
+ void testFirstSubkeyFromAsc() throws NoLocalRepositoryManagerException,
MojoFailureException {
+ DefaultRepositorySystemSession session = new
DefaultRepositorySystemSession();
+ session.setLocalRepositoryManager(new
SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer())
+ .newInstance(session, new
LocalRepository("target/local-repo")));
+ BcSigner signer = new BcSigner(
+ session,
+ "unimportant",
+ "unimportant",
+ "undefined",
+ new
File("src/test/resources/signing-key-with-multiple-subkeys.asc").getAbsolutePath(),
+ "583C18F38D66BE2A3833548F8E3F6C0F255684D1"); // fingerprint
2nd subkey
+ signer.setPassPhrase("TEST");
+ signer.setUseAgent(false);
+ signer.setInteractive(false);
+ signer.prepare();
+ // check key algorithm, must be DSA
+ assertEquals(PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT,
signer.secretKey.getPublicKey().getAlgorithm());
+ }
+
+ @Test
+ void testSecondSubkeyFromAsc() throws NoLocalRepositoryManagerException,
MojoFailureException {
+ DefaultRepositorySystemSession session = new
DefaultRepositorySystemSession();
+ session.setLocalRepositoryManager(new
SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer())
+ .newInstance(session, new
LocalRepository("target/local-repo")));
+ BcSigner signer = new BcSigner(
+ session,
+ "unimportant",
+ "unimportant",
+ "undefined",
+ new
File("src/test/resources/signing-key-with-multiple-subkeys.asc").getAbsolutePath(),
+ "7EB913227724A94C160596926356A7B4E9AF6EFB"); // fingerprint
2nd subkey
+ signer.setPassPhrase("TEST");
+ signer.setUseAgent(false);
+ signer.setInteractive(false);
+ signer.prepare();
+ // check key algorithm, must be DSA
Review Comment:
RSA or DSA?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]