Skip to content

Commit

Permalink
Merge pull request #553 from johnoliver/fix-typo
Browse files Browse the repository at this point in the history
Fix sha265 typo
  • Loading branch information
karianna authored Nov 15, 2024
2 parents 279d61f + e69e104 commit 3001f27
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@

public class DeserializationTest {

@Test
public void canDeserializeDocsWithTypo() throws IOException {
ReleaseList deserialized = MarketplaceMapper.repositoryObjectMapper.readValue(DeserializationTest.class.getResourceAsStream("example.json"), ReleaseList.class);

ReleaseList deserializedWithTypo = MarketplaceMapper.repositoryObjectMapper.readValue(DeserializationTest.class.getResourceAsStream("example_with_typo.json"), ReleaseList.class);

Assertions.assertEquals(
deserialized.getReleases().get(0).getBinaries().get(0).getPackage().getSha256sum(),
deserializedWithTypo.getReleases().get(0).getBinaries().get(0).getPackage().getSha256sum());

Assertions.assertEquals(
deserialized.getReleases().get(0).getBinaries().get(0).getPackage().getSha265sum(),
deserializedWithTypo.getReleases().get(0).getBinaries().get(0).getPackage().getSha265sum());

Assertions.assertNotNull(deserialized.getReleases().get(0).getBinaries().get(0).getPackage().getSha265sum());
Assertions.assertNotNull(deserialized.getReleases().get(0).getBinaries().get(0).getPackage().getSha256sum());
Assertions.assertNotNull(deserializedWithTypo.getReleases().get(0).getBinaries().get(0).getPackage().getSha265sum());
Assertions.assertNotNull(deserializedWithTypo.getReleases().get(0).getBinaries().get(0).getPackage().getSha256sum());
}

@Test
public void canDeserializeExampleDoc() throws IOException {
ReleaseList deserialized = MarketplaceMapper.repositoryObjectMapper.readValue(DeserializationTest.class.getResourceAsStream("example.json"), ReleaseList.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static ReleaseList generate(String releaseName) {
"OpenJDK17U-jre_x64_mac_hotspot_17.0.1_12.tar.gz",
"https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jre_x64_mac_hotspot_17.0.1_12.tar.gz",
"d7eefa08d893d1ae263dc4ba427baa67b3cb9d48e1151654e423007fb2801358",
"d7eefa08d893d1ae263dc4ba427baa67b3cb9d48e1151654e423007fb2801358",
"https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jre_x64_mac_hotspot_17.0.1_12.tar.gz.sha256.txt",
null
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"package": {
"name": "OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz",
"link": "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz",
"sha265sum": "cc13f274becf9dd5517b6be583632819dfd4dd81e524b5c1b4f406bdaf0e063a",
"sha256sum": "cc13f274becf9dd5517b6be583632819dfd4dd81e524b5c1b4f406bdaf0e063a",
"sha256sum_link": "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz.sha256.txt"
},
"timestamp": "2021-07-29T19:22:53Z",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"releases": [
{
"release_link": "https://github.com/adoptium/temurin8-binaries/releases/tag/jdk8u302-b08",
"release_name": "jdk8u302-b08",
"last_updated_timestamp": "2021-07-29T19:22:38Z",
"binaries": [
{
"os": "linux",
"architecture": "x64",
"image_type": "jdk",
"jvm_impl": "hotspot",
"package": {
"name": "OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz",
"link": "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz",
"sha265sum": "cc13f274becf9dd5517b6be583632819dfd4dd81e524b5c1b4f406bdaf0e063a",
"sha256sum_link": "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz.sha256.txt"
},
"timestamp": "2021-07-29T19:22:53Z",
"scm_ref": "jdk8u302-b08",
"openjdk_scm_ref": "jdk8u302-b08",
"distribution": "temurin",
"aqavit_results_link": "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tap.zip",
"tck_affidavit_link": "https://adoptium.net/temurin/tck-affidavit/"
}
],
"vendor": "adoptium",
"openjdk_version_data": {
"major": 8,
"minor": 0,
"security": 302,
"patch": null,
"pre": null,
"build": 8,
"optional": null,
"openjdk_version": "1.8.0_302-b08"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public class Asset {

public static final String SHA_256_SUM_LINK_NAME = "sha256sum_link";
public static final String SIGNATURE_LINK_NAME = "signature_link";
public static final String SHA256SUM_NAME = "sha265sum";


public static final String SHA256SUM_NAME = "sha256sum";

// Name of previous typo to be removed when vendors update their code to fix the typo
public static final String SHA265SUM_NAME = "sha265sum";

@Schema(example = "OpenJDK8U-jre_x86-32_windows_hotspot_8u212b04.msi", required = true)
private final String name;

Expand All @@ -19,27 +25,46 @@ public class Asset {
private final String sha256sum;

@Schema(
example = "https://github.com/AdoptOpenJDK/openjdk8-openj9-releases/ga/download/jdk8u162-b12_openj9-0.8.0/OpenJDK8-OPENJ9_x64_Linux_jdk8u162-b12_openj9-0.8.0.tar.gz.sha256.txt",
name = SHA_256_SUM_LINK_NAME
example = "dd28d6d2cde2b931caf94ac2422a2ad082ea62f0beee3bf7057317c53093de93",
description = "This value is present to avoid an API breaking change from a previous typo for sha256sum in the API. DO NOT USE THIS, it is deprecated and will be removed.",
deprecated = true)
private final String sha265sum;

@Schema(
example = "https://github.com/AdoptOpenJDK/openjdk8-openj9-releases/ga/download/jdk8u162-b12_openj9-0.8.0/OpenJDK8-OPENJ9_x64_Linux_jdk8u162-b12_openj9-0.8.0.tar.gz.sha256.txt",
name = SHA_256_SUM_LINK_NAME
)
private final String sha256sumLink;

@Schema(
example = "https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.5%2B10/OpenJDK11U-jdk_x64_linux_11.0.5_10.tar.gz.sign",
name = SIGNATURE_LINK_NAME
example = "https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.5%2B10/OpenJDK11U-jdk_x64_linux_11.0.5_10.tar.gz.sign",
name = SIGNATURE_LINK_NAME
)
private final String signatureLink;

@JsonCreator
public Asset(
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(SHA256SUM_NAME) String sha256sum,
@JsonProperty(SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(SIGNATURE_LINK_NAME) String signatureLink) {
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(SHA256SUM_NAME) String sha256sum,

// TODO: Remove this when vendors update their code to fix the typo
@JsonProperty(SHA265SUM_NAME) String sha265sum,

@JsonProperty(SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(SIGNATURE_LINK_NAME) String signatureLink) {
this.name = name;
this.link = link;
this.sha256sum = sha256sum;

// TODO: Remove this when vendors update their code to fix the typo
if (sha256sum != null) {
this.sha256sum = sha256sum;
this.sha265sum = sha256sum;
} else {
this.sha256sum = sha265sum;
this.sha265sum = sha265sum;
}

this.sha256sumLink = sha256sumLink;
this.signatureLink = signatureLink;
}
Expand All @@ -57,6 +82,11 @@ public String getSha256sum() {
return sha256sum;
}

@JsonProperty(SHA265SUM_NAME)
public String getSha265sum() {
return sha265sum;
}

@JsonProperty(SHA_256_SUM_LINK_NAME)
public String getSha256sumLink() {
return sha256sumLink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,29 @@ public class Installer extends Asset {
@Schema(example = "msi", description = "Type of the installer, i.e exe, msi, deb, dmg")
private final String installerType;

public Installer(
String name,
String link,
String sha256sum,
String sha256sumLink,
String signatureLink,
String installerType
) {
super(name, link, sha256sum, sha256sum, sha256sumLink, signatureLink);
this.installerType = installerType;
}

@JsonCreator
public Installer(
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(Asset.SHA256SUM_NAME) String sha256sum,
@JsonProperty(Asset.SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(Asset.SIGNATURE_LINK_NAME) String signatureLink,
@JsonProperty(INSTALLER_TYPE_NAME) String installerType
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(Asset.SHA256SUM_NAME) String sha256sum,
@JsonProperty(Asset.SHA265SUM_NAME) String sha265sum,
@JsonProperty(Asset.SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(Asset.SIGNATURE_LINK_NAME) String signatureLink,
@JsonProperty(INSTALLER_TYPE_NAME) String installerType
) {
super(name, link, sha256sum, sha256sumLink, signatureLink);
super(name, link, sha256sum, sha265sum, sha256sumLink, signatureLink);
this.installerType = installerType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@

public class Package extends Asset {

public Package(
String name,
String link,
String sha256sum,
String sha256sumLink,
String signatureLink
) {
super(name, link, sha256sum, sha256sum, sha256sumLink, signatureLink);
}

@JsonCreator
public Package(
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(Asset.SHA256SUM_NAME) String sha256sum,
@JsonProperty(Asset.SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(Asset.SIGNATURE_LINK_NAME) String signatureLink
@JsonProperty("name") String name,
@JsonProperty("link") String link,
@JsonProperty(Asset.SHA256SUM_NAME) String sha256sum,
@JsonProperty(Asset.SHA265SUM_NAME) String sha265sum,
@JsonProperty(Asset.SHA_256_SUM_LINK_NAME) String sha256sumLink,
@JsonProperty(Asset.SIGNATURE_LINK_NAME) String signatureLink
) {
super(name, link, sha256sum, sha256sumLink, signatureLink);
super(name, link, sha256sum, sha265sum, sha256sumLink, signatureLink);
}
}

0 comments on commit 3001f27

Please sign in to comment.