-
Notifications
You must be signed in to change notification settings - Fork 197
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
Fix and test cases for #2930 #3221
Conversation
@kevloral thnaks for working on this, if I understand correctly from your example you have the case that there is one (not authenticated) p2 site that is mirrored but the mirror is password protected. I would suggest that your copy the |
Not exactly: the p2-repo that is accessed through the mirror is always password protected (test-user/test-password). It is the mirror that may be protected or not:
Anyway, these test cases pass even though I expected them not to. Therefore, I am going to add some logging to the MavenAuthenticator class to see if the problem is actually in there (and, also, to try to find out why those tests pass). Once I know more, I will change those tests if needed or add others that manage to reproduce the bug. |
Two more test cases added. The second one (testTargetDefinitionAuthMirror) successfully reproduces the bug:
|
Fixed. When MavenAuthenticator tried to get the credentials for a given URI (method getServerCredentials), it asked DefaultRepositoryIdManager for the list of known maven locations (method getKnownMavenRepositoryLocations) so it could compare the URIs of those locations with the one credentials are being requested for (method uriPrefixMatch). That list of known locations did not include mirrors, even though methods getEffectiveLocation and getEffectiveLocationAndPrepareLoad do return mirrors when needed. Therefore, credentials were never returned by method method getServerCredentials when the URI belonged to a mirror because the URIs never matched. Now, whenever a new mapping is added to DefaultRepositoryIdManager (method addMapping), the corresponding mirror, if any, is stored. When the list of known locations is requested, method getKnownMavenRepositoryLocations returns both repos and mirrors and, therefore, method getServerCredentials now return the credentials because the URIs do match. |
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.
Many thanks for the test-case and working on a fix, it looks good in general but could maybe be improved a bit.
Beside that it would be good if you
- target the main branch, the change can then be backported automatically to tycho-4 branch
- squash your commits into one with a combined commit message that includes what was changed.
tycho-its/src/test/java/org/eclipse/tycho/test/target/PasswordProtectedP2RepositoryTest.java
Outdated
Show resolved
Hide resolved
...en-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java
Outdated
Show resolved
Hide resolved
Test Results 576 files ± 0 576 suites ±0 3h 38m 41s ⏱️ - 14m 15s For more details on these failures, see this check. Results for commit 48c008c. ± Comparison against base commit 64b3ccf. This pull request skips 1 test.
♻️ This comment has been updated with latest results. |
I will follow your suggestions and prepare a new PR targeting main instead. Thanks a lot for your comments. |
If you squash all your commits into one and then rebase on |
We should just keep them, even though they do not show the bug behavior they prove these cases already work. |
1945b64
to
5349c28
Compare
5349c28
to
df34368
Compare
@kevloral can you rebase and adjust it to use the |
Of course. I will make that change as well as the others you suggested in the next few days. |
tycho-api/src/main/java/org/eclipse/tycho/MavenRepositorySettings.java
Outdated
Show resolved
Hide resolved
...lugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultMavenRepositorySettings.java
Outdated
Show resolved
Hide resolved
...lugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultMavenRepositorySettings.java
Outdated
Show resolved
Hide resolved
@kevloral thanks for the changes, just one more adjustment and I think its fine, beside that, can you please squash + rebase the changes into one commit so we can easier backport the changes? |
Sure. I will replace that Iterable with a Stream and squash the commits into one. By the way, it is already rebased on main even though my branch is still called kevloral:tycho-4.0.x. |
@kevloral I plan to do a bugfix release soon and your change seems important enough to include to you think you can finish it? |
Mirrors are now included in the returned list of known repo locations. Also, these test cases have been added: - testMirror: the test server is accessed over a mirror without authentication. - testAuthMirror: the test server is accessed over a mirror with authentication. - testTargetDefinitionMirror: this one tries to resolve a target definition from a p2 repo accessed over a mirror with no authentication. - testTargetDefinitionAuthMirror: this one tries to resolve a target definition from a p2 repo accessed over an authenticated mirror. This is the one that actually reproduced the bug that has been fixed here.
Sorry for the delay. Other commitments got in the way. As you requested, I have replaced the Iterable with a Stream and squashed the commits into one. I guess it is ready to be merged now. Thanks a lot for your help. |
@kevloral thanks for the testcase and bugfix! |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Two test cases added to class PasswordProtectedP2RepositoryTest for trying to reproduce the bug:
As things stand, they both pass, so they need improving.