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

Hotfix/align with fdo #45

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/.trivyignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Date: Mar 5, 2024
# Notes: Issue with libexpat, parsing large tokens can trigger a denial of service
# Needs to be fixed in Docker Image.
CVE-2023-52425
CVE-2023-52425

# Date: March 21, 2024
# Issue: Vulnerability in spring-web
# Solution: Spring boot needs to update its version of spring
CVE-2024-22259
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<mockito-inline.version>5.2.0</mockito-inline.version>
<testcontainers.version>1.19.5</testcontainers.version>
<springdoc.version>2.3.0</springdoc.version>
<spring-security.version>6.2.3</spring-security.version> <!-- 21/03/24: CVE-2024-22257-->
<sonar.organization>dissco</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.jacoco.xmlReportPaths>../app-it/target/site/jacoco-aggregate/jacoco.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ private void addOptionalAttributes(DigitalSpecimenWrapper specimen, ObjectNode a
if (specimen.attributes().getOdsMarkedAsType() != null) {
attributes.put(MARKED_AS_TYPE.getAttribute(), specimen.attributes().getOdsMarkedAsType());
}
if (specimen.attributes().getIdentifiers() != null && !specimen.attributes().getIdentifiers().isEmpty()){
var idNodeArr = mapper.createArrayNode();
for (var id: specimen.attributes().getIdentifiers()){
idNodeArr.add(mapper.createObjectNode()
.put("identifierType", id.getIdentifierType())
.put("identifierValue", id.getIdentifierValue()));
}
attributes.set("otherSpecimenIds", idNodeArr);
}
}

public boolean handleNeedsUpdate(DigitalSpecimenWrapper currentDigitalSpecimenWrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.TYPE;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.generateSpecimenOriginalData;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.givenAttributes;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.givenAttributesPlusIdentifier;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.givenDigitalSpecimenEvent;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.givenDigitalSpecimenWrapper;
import static eu.dissco.core.digitalspecimenprocessor.utils.TestUtils.givenDigitalSpecimenRecord;
Expand Down Expand Up @@ -202,6 +203,49 @@ void testGenRequestFull(boolean markedAsType) throws Exception {
assertThat(response).isEqualTo(expected);
}

@Test
void testGenRequestIdentifiers() throws Exception {
// Given
var markedAsType = false;
var specimen = new DigitalSpecimenWrapper(PHYSICAL_SPECIMEN_ID, TYPE,
givenAttributesPlusIdentifier(SPECIMEN_NAME, ORGANISATION_ID, markedAsType),
givenDigitalSpecimenAttributesFull(markedAsType));
var expectedJson = MAPPER.readTree(
"""
{
"data": {
"type": "digitalSpecimen",
"attributes": {
"fdoProfile": "https://hdl.handle.net/21.T11148/d8de0819e144e4096645",
"digitalObjectType": "https://hdl.handle.net/21.T11148/894b1e6cad57e921764e",
"issuedForAgent": "https://ror.org/0566bfb96",
"primarySpecimenObjectId": "https://geocollections.info/specimen/23602",
"normalisedPrimarySpecimenObjectId":"https://geocollections.info/specimen/23602",
"primarySpecimenObjectIdType": "Global",
"specimenHost": "https://ror.org/0443cwa12",
"specimenHostName": "National Museum of Natural History",
"topicDiscipline": "Botany",
"referentName": "Biota",
"livingOrPreserved": "Preserved",
"markedAsType": false,
"otherSpecimenIds": [{
"identifierType": "Specimen label",
"identifierValue": "20.5000.1025/V1Z-176-LL4"
}]
}
}
}
"""
);
var expected = new ArrayList<>(List.of(expectedJson));

// When
var response = builder.buildPostHandleRequest(List.of(specimen));

// Then
assertThat(response).isEqualTo(expected);
}

@Test
void testGenRequestFullTypeIsNull() throws Exception {
// Given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import eu.dissco.core.digitalspecimenprocessor.schema.DigitalSpecimen.OdsPhysicalSpecimenIdType;
import eu.dissco.core.digitalspecimenprocessor.schema.DigitalSpecimen.OdsTopicDiscipline;
import eu.dissco.core.digitalspecimenprocessor.schema.EntityRelationships;
import eu.dissco.core.digitalspecimenprocessor.schema.Identifiers;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -340,4 +341,9 @@ public static DigitalSpecimen givenAttributes(
.withDctermsModified("2017-09-26T12:27:21.000+00:00");
}

public static DigitalSpecimen givenAttributesPlusIdentifier(String specimenName, String organisation, Boolean markedAsType){
return givenAttributes(specimenName, organisation, markedAsType)
.withIdentifiers(List.of(new Identifiers("Specimen label", HANDLE, false, null, true)));
}

}
Loading