Skip to content

Commit

Permalink
#139 add workaround for bug in DT
Browse files Browse the repository at this point in the history
  • Loading branch information
sephiroth-j committed Feb 2, 2023
1 parent b67a387 commit c1fc0bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ public void updateProjectProperties(@NonNull final String projectUuid, @NonNull
JSONObject newParent = new JSONObject().elementOpt("uuid", properties.getParentId());
rawProject.element("parent", newParent);
}
// remove parentUuid wich may be present but can not be consumed by Dependency-Track (https://github.com/DependencyTrack/dependency-track/issues/2439)
rawProject.remove("parentUuid");
// 3. update project
updateProject(projectUuid, rawProject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public void updateProjectPropertiesTest() throws ApiClientException, Interrupted
.get(ApiClient.PROJECT_URL + "/uuid-3", (request, response) -> {
assertThat(request.requestHeaders().contains(ApiClient.API_KEY_HEADER, API_KEY, false)).isTrue();
assertThat(request.requestHeaders().contains(HttpHeaderNames.ACCEPT, HttpHeaderValues.APPLICATION_JSON, true)).isTrue();
return response.sendString(Mono.just("{\"name\":\"test-project\",\"uuid\":\"uuid-3\",\"version\":\"1.2.3\",\"tags\":[{\"name\":\"tag1\"},{\"name\":\"tag2\"}],\"parent\":{\"uuid\":\"old-parent\"}}"));
return response.sendString(Mono.just("{\"name\":\"test-project\",\"uuid\":\"uuid-3\",\"version\":\"1.2.3\",\"tags\":[{\"name\":\"tag1\"},{\"name\":\"tag2\"}],\"parent\":{\"uuid\":\"old-parent\"},\"parentUuid\":\"old-parent\"}"));
})
.post(ApiClient.PROJECT_URL, (request, response) -> {
assertThat(request.requestHeaders().contains(ApiClient.API_KEY_HEADER, API_KEY, false)).isTrue();
Expand All @@ -384,12 +384,14 @@ public void updateProjectPropertiesTest() throws ApiClientException, Interrupted

assertThatCode(() -> uut.updateProjectProperties("uuid-3", props)).doesNotThrowAnyException();
completionSignal.await(5, TimeUnit.SECONDS);
final Project project = ProjectParser.parse(JSONObject.fromObject(requestBody.get()));
final JSONObject updatedProject = JSONObject.fromObject(requestBody.get());
final Project project = ProjectParser.parse(updatedProject);
assertThat(project.getTags()).containsExactlyInAnyOrder("tag1", "tag2", "tag4");
assertThat(project.getSwidTagId()).isEqualTo(props.getSwidTagId());
assertThat(project.getGroup()).isEqualTo(props.getGroup());
assertThat(project.getDescription()).isEqualTo(props.getDescription());
assertThat(project.getParent()).hasFieldOrPropertyWithValue("uuid", props.getParentId());
assertThat(updatedProject.has("parentUuid")).isFalse();
}

@Test
Expand Down

0 comments on commit c1fc0bc

Please sign in to comment.