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

Fix maven repositories http #345

Merged
merged 12 commits into from
Oct 18, 2024

Conversation

gounthar
Copy link
Collaborator

Walkthrough

The changes involve updates to the PreconditionError enum, specifically enhancing the MAVEN_REPOSITORIES_HTTP constant with a remediation function that replaces HTTP URLs with HTTPS in the plugin's pom.xml. A new method replaceHttpWithHttps() has been added to the PomModifier class to facilitate this. Additionally, the MetadataCollectorTest class has been modified to include a test for this new functionality, ensuring that HTTP URLs are correctly converted to HTTPS in the POM file.

Changes

File Change Summary
plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/model/PreconditionError.java Updated MAVEN_REPOSITORIES_HTTP constant with a remediation function for HTTP to HTTPS conversion.
plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/utils/PomModifier.java Added replaceHttpWithHttps() method to replace HTTP URLs with HTTPS in XML documents.

Assessment against linked issues

Objective Addressed Explanation
Implement remediation for HTTP Maven repositories (#342 )

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Fixes #43

Implement the remediation function for `MAVEN_REPOSITORIES_HTTP` to replace 'http' with 'https' in repository URLs.

* Modify `plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/model/PreconditionError.java` to include the remediation function that uses `PomModifier` to replace 'http' with 'https' in repository URLs.
* Add a method `replaceHttpWithHttps` in `plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/utils/PomModifier.java` to replace 'http' with 'https' in repository URLs.
* Add tests in `plugin-modernizer-core/src/test/java/io/jenkins/tools/pluginmodernizer/core/extractor/MetadataCollectorTest.java` to verify the functionality of the remediation function for `MAVEN_REPOSITORIES_HTTP`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/plugin-modernizer-tool/issues/43?shareId=XXXX-XXXX-XXXX-XXXX).
…fierTest.java

Fixes #45

Add a test for the `replaceHttpWithHttps` method in `PomModifierTest.java`.

* Add a new test method `testReplaceHttpWithHttps` to test the `replaceHttpWithHttps` method.
* Initialize `PomModifier` with `OUTPUT_POM_PATH` in the new test method.
* Call `replaceHttpWithHttps` method in the new test method.
* Save the modified POM to `OUTPUT_POM_PATH` in the new test method.
* Parse the modified POM and assert that all `http` URLs are replaced with `https`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/plugin-modernizer-tool/issues/45?shareId=XXXX-XXXX-XXXX-XXXX).
@gounthar gounthar marked this pull request as ready for review October 18, 2024 13:36
@gounthar gounthar requested a review from a team as a code owner October 18, 2024 13:36
@jonesbusy jonesbusy added the enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Oct 18, 2024
@jonesbusy jonesbusy merged commit b747fed into jenkins-infra:main Oct 18, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants