Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Immalla-Chen <[email protected]>
  • Loading branch information
immalla committed Oct 30, 2024
1 parent 0194fe6 commit 60e7d0f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.http.HttpStatus;
import org.dependencytrack.JerseyTestRule;
import org.dependencytrack.ResourceTest;
import org.dependencytrack.model.Classifier;
import org.dependencytrack.model.Component;
import org.dependencytrack.model.ConfigPropertyConstants;
import org.dependencytrack.model.ExternalReference;
Expand Down Expand Up @@ -508,6 +509,7 @@ public void createComponentTest() {
component.setName("My Component");
component.setVersion("1.0");
component.setAuthor("SampleAuthor");
component.setClassifier(Classifier.APPLICATION);
Response response = jersey.target(V1_COMPONENT + "/project/" + project.getUuid().toString()).request()
.header(X_API_KEY, apiKey)
.put(Entity.entity(component, MediaType.APPLICATION_JSON));
Expand All @@ -518,6 +520,7 @@ public void createComponentTest() {
Assert.assertEquals("SampleAuthor" ,json.getJsonArray("authors").getJsonObject(0).getString("name"));
Assert.assertEquals("SampleAuthor", json.getString("author"));
Assert.assertEquals("1.0", json.getString("version"));
Assert.assertEquals("APPLICATION", json.getString("classifier"));
Assert.assertTrue(UuidUtil.isValidUUID(json.getString("uuid")));
}

Expand All @@ -528,6 +531,7 @@ public void createComponentUpperCaseHashTest() {
component.setProject(project);
component.setName("My Component");
component.setVersion("1.0");
component.setClassifier(Classifier.APPLICATION);
component.setSha1("640ab2bae07bedc4c163f679a746f7ab7fb5d1fa".toUpperCase());
component.setSha256("532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25".toUpperCase());
component.setSha3_256("c0a5cca43b8aa79eb50e3464bc839dd6fd414fae0ddf928ca23dcebf8a8b8dd0".toUpperCase());
Expand All @@ -544,6 +548,7 @@ public void createComponentUpperCaseHashTest() {
Assert.assertNotNull(json);
Assert.assertEquals("My Component", json.getString("name"));
Assert.assertEquals("1.0", json.getString("version"));
Assert.assertEquals("APPLICATION", json.getString("classifier"));
Assert.assertTrue(UuidUtil.isValidUUID(json.getString("uuid")));
Assert.assertEquals(component.getSha1(), json.getString("sha1"));
Assert.assertEquals(component.getSha256(), json.getString("sha256"));
Expand Down Expand Up @@ -574,6 +579,7 @@ public void updateComponentTest() {
externalReference.setType(org.cyclonedx.model.ExternalReference.Type.WEBSITE);
externalReference.setUrl("test.com");
jsonComponent.setExternalReferences(List.of(externalReference));
jsonComponent.setClassifier(Classifier.APPLICATION);

Response response = jersey.target(V1_COMPONENT).request()
.header(X_API_KEY, apiKey)
Expand Down Expand Up @@ -626,6 +632,7 @@ public void updateComponentInvalidLicenseExpressionTest() {
"uuid": "%s",
"name": "acme-lib",
"version": "1.0.0",
"classifier":"APPLICATION",
"licenseExpression": "(invalid"
}
""".formatted(component.getUuid()), MediaType.APPLICATION_JSON_TYPE));
Expand Down

0 comments on commit 60e7d0f

Please sign in to comment.