-
Notifications
You must be signed in to change notification settings - Fork 22
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
[MGPG-79] fix handling of external pinentry programs in case the passphrase is not given #9
Conversation
Unfortunately I am not able to provide a proper test for this scenario, because the bug only occurs if Maven is being run in "interactive" mode and the maven-invoker-plugin always activates the Maven batch mode. Does someone else have an idea how to implement a test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you could test this by extracting the generation of the command line to a separate package protected method that is visible for testing. You can test that the command line is as expected without actually executing it.
running through jenkins: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-gpg-plugin/job/MGPG-79/ |
My problem is that I only know that it behaves correctly now, because I did a lot of manual testing. I am thinking of implementing a JUnit based maven-invoker test (without maven-invoker-plugin) so I can set Maven to "interactive". |
Fix confirmed locally on my Windows box. Thanks! My 2 cents on the test: Although I'm all for "test first" and high code coverage, sometimes it doesn't make sense to try to test everything automatically. |
I added an integration test for the Maven interactive mode use case via a JUnit-based maven-invoker test. I think it is important to have such a behavioral test so the next one who wants to fix a bug or even refactor the code has a clearly defined expected behavior and does not have to figure out on his own how the plugin should behave (as I had to). |
@elharo it would be great if you could review this PR again / trigger a new Jenkins build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me push it to jenkins
GpgSignAttachedMojoIT.testInteractiveWithoutPassphrase appears to be failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GpgSignAttachedMojoIT.testInteractiveWithoutPassphrase
I was able to reproduce the issue with GpgSignAttachedMojoIT.testInteractiveWithoutPassphrase locally on Linux by unsetting the environment variable "GPG_TTY". I pushed a new commit, which sets an invalid pinentry program for gpg-agent (instead of letting an actual one time out). Sorry for that. I did not take Jenkins into account. |
While the previous commit failed, the latest one 8171fa1 also works on macOS 11.2.3 (Apple Silicon, gpg (GnuPG/MacGPG2) 2.2.24). Java reports as: |
let's see what Jenkins says: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-gpg-plugin/job/MGPG-79B/ |
Jenkins is not well designed so it's hard to find the output, but there seem to still be test failures. |
This time it seems that there was an issue in the JUnit maven-invoker test while connecting to Maven Central. Do you know if I am correct? |
No, I don't know. You could ask on the dev mailing list. Jenkins is not well designed from a UI perspective. I'll try just rerunning and see what happens. |
The log of the failing test can be found here.
I pushed a new commit which aligns the JUnit-based maven-invoker tests with the maven-invoker-plugin ITs by utilizing the local Maven repository as remote repository. If that does not help I will ask on the dev mailing list. Thank's for the pointer. |
Haven't tried the latest commit, but now I see this. Maven 3.2.5 is quite old, as is jdk1.7.0_80. It's possible it's having SSL problems connecting to Maven Central.
|
That is correct. TLS 1.2 (and even 1.3!) was backported to Java 8, but Java 7 can only connect to TLS 1.0 endpoints iirc. |
Should not be an issue on Jenkins @ a.o , INFRA fixed this with https://issues.apache.org/jira/browse/INFRA-19861 |
Thanks to your comments I was able to reproduce the issue locally with Oracle JDK 7. Apparently the maven-invoker-plugin sets the system property I am not sure whether my testing approach with a JUnit-based maven-invoker test is still viable. |
I pushed a new commit, which sets I could verify that it works on Windows and Linux with Oracle JDK 7. |
Checking now. Meanwhile it might help if you can merge master and squash your commits. The git log is getting complex, and I'm not sure I'm testing what you're sending. |
The build looks good :) |
…phrase is not given.
Checking again: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-gpg-plugin/job/MGPG-79C/ In general, just squash everything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jenkins passed
Fixes MGPG-79 by using the default "pinentry-mode" if no passphrase for the GPG key is given.
Only in case a passphrase for the GPG key is given and shall be passed to GPG via stdin, the "pinentry-mode" is set to "loopback".
Additionally the "--batch" option is set as long as Maven is running in "non-interactive" mode to prevent other GPG input prompts (e.g. prompting to overwrite an already existing signature file), which would cause the command to hang indefinitely.