-
Notifications
You must be signed in to change notification settings - Fork 65
#1881 implement cdk url updater #1883
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
Closed
AdemZarrouki
wants to merge
4
commits into
devonfw:main
from
AdemZarrouki:feature/1881-cdk-url-updater
+124
−4
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
21a51e8
#1881: Add CdkUrlUpdater for AWS CDK
AdemZarrouki a05620f
#1881: Add mock and tests for CdkUrlUpdater integration
AdemZarrouki 790bf3f
#1881: Add CdkUrlUpdater to UpdateManager
AdemZarrouki 5edd076
Merge branch 'main' into feature/1881-cdk-url-updater
AdemZarrouki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
url-updater/src/main/java/com/devonfw/tools/ide/url/tool/cdk/CdkUrlUpdater.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.devonfw.tools.ide.url.tool.cdk; | ||
|
|
||
| import com.devonfw.tools.ide.url.updater.NpmBasedUrlUpdater; | ||
|
|
||
| /** | ||
| * {@link NpmBasedUrlUpdater} for nest. | ||
| */ | ||
| public class CdkUrlUpdater extends NpmBasedUrlUpdater { | ||
|
|
||
| @Override | ||
| public String getTool() { | ||
| return "cdk"; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPackageName() { | ||
| return "aws-cdk"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCpeVendor() { | ||
| return "cdk"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCpeProduct() { | ||
| return "cdk"; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
url-updater/src/test/java/com/devonfw/tools/ide/url/tool/cdk/CdkUrlUpdaterMock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.devonfw.tools.ide.url.tool.cdk; | ||
|
|
||
| import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
|
|
||
| /** | ||
| * Mock of {@link CdkUrlUpdater} to allow integration testing with wiremock. | ||
| */ | ||
| public class CdkUrlUpdaterMock extends CdkUrlUpdater { | ||
|
|
||
| private final String baseUrl; | ||
|
|
||
| CdkUrlUpdaterMock(WireMockRuntimeInfo wireMockRuntimeInfo) { | ||
| super(); | ||
| this.baseUrl = wireMockRuntimeInfo.getHttpBaseUrl() + "/"; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getDownloadBaseUrl() { | ||
|
|
||
| return this.baseUrl; | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
url-updater/src/test/java/com/devonfw/tools/ide/url/tool/cdk/CdkUrlUpdaterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package com.devonfw.tools.ide.url.tool.cdk; | ||
|
|
||
| import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.any; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Path; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import com.devonfw.tools.ide.url.model.folder.UrlRepository; | ||
| import com.devonfw.tools.ide.url.updater.AbstractUrlUpdaterTest; | ||
| import com.devonfw.tools.ide.url.updater.JsonUrlUpdater; | ||
| import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; | ||
| import com.github.tomakehurst.wiremock.junit5.WireMockTest; | ||
|
|
||
|
|
||
| /** | ||
| * Test of {@link CdkUrlUpdater} | ||
| */ | ||
| @WireMockTest | ||
| class CdkUrlUpdaterTest extends AbstractUrlUpdaterTest { | ||
|
|
||
| /** | ||
| * Test of {@link JsonUrlUpdater} for the creation of {@link CdkUrlUpdater} download URLs and checksums. | ||
| * | ||
| * @param tempDir Path to a temporary directory | ||
| * @param wmRuntimeInfo the {@link WireMockRuntimeInfo}. | ||
| * @throws IOException test fails | ||
| */ | ||
| @Test | ||
| void testCdkJsonUrlUpdaterCreatesDownloadUrlsAndChecksums(@TempDir Path tempDir, WireMockRuntimeInfo wmRuntimeInfo) throws IOException { | ||
|
|
||
| // arrange | ||
| stubFor(get(urlMatching("/aws-cdk")).willReturn( | ||
| aResponse().withStatus(200).withBody(getJsonBody(wmRuntimeInfo)))); | ||
|
|
||
| stubFor(any(urlMatching("/aws-cdk/-/aws-cdk-[0-9.].*.tgz")).willReturn(aResponse().withStatus(200).withBody(DOWNLOAD_CONTENT))); | ||
|
|
||
| UrlRepository urlRepository = UrlRepository.load(tempDir); | ||
| CdkUrlUpdaterMock updater = new CdkUrlUpdaterMock(wmRuntimeInfo); | ||
|
|
||
| // act | ||
| updater.update(urlRepository); | ||
|
|
||
| // assert | ||
| assertUrlVersionAgnostic(tempDir.resolve("cdk").resolve("cdk").resolve("2.1120.0")); | ||
| } | ||
|
|
||
| private static String getJsonBody(WireMockRuntimeInfo wmRuntimeInfo) throws IOException { | ||
| return readAndResolve(PATH_INTEGRATION_TEST.resolve("CdkUrlUpdater").resolve("cdk-version.json"), wmRuntimeInfo); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
url-updater/src/test/resources/integrationtest/CdkUrlUpdater/cdk-version.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "versions": { | ||
| "2.1120.0": { | ||
| "version": "2.1120.0", | ||
| "dist": { | ||
| "tarball": "${testbaseurl}/aws-cdk/-/aws-cdk-2.1120.0.tgz" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It seems like the cdk:cdk (vendor:product) doesn't exist. I've found this CVE which is related to the aws-cdk-cli tool but mapped to the CPE: cpe:2.3:a:amazon:aws_cloud_development_kit::::::::. I couldn't find any direct match for a cpe. We should discuss if we should leave the two CPE related methods empty.
https://nvd.nist.gov/vuln/detail/CVE-2025-2598