-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
authors
column failing to be mapped for `/api/v1/component/proj…
…ect/{uuid}` endpoint This is just a simple fix to resolve the issue. But really this logic should be moved to a JDBI DAO, which is where we maintain our SQL queries now. Fixes DependencyTrack/hyades#1536 Signed-off-by: nscuro <[email protected]>
- Loading branch information
Showing
3 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import org.dependencytrack.JerseyTestRule; | ||
import org.dependencytrack.ResourceTest; | ||
import org.dependencytrack.model.Component; | ||
import org.dependencytrack.model.OrganizationalContact; | ||
import org.dependencytrack.model.Project; | ||
import org.dependencytrack.model.RepositoryMetaComponent; | ||
import org.dependencytrack.model.RepositoryType; | ||
|
@@ -42,7 +43,9 @@ | |
import java.util.Date; | ||
import java.util.List; | ||
|
||
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ComponentResourcePostgresTest extends ResourceTest { | ||
|
||
|
@@ -65,6 +68,37 @@ public void getAllComponentsTest() throws MalformedPackageURLException { | |
|
||
final JsonArray json = parseJsonArray(response); | ||
assertThat(json).hasSize(100); // Default page size is 100 | ||
assertThatJson(json.getFirst().toString()) | ||
.withMatcher("projectUuid", equalTo(project.getUuid().toString())) | ||
.isEqualTo(""" | ||
{ | ||
"authors": [ | ||
{ | ||
"name": "author-0" | ||
} | ||
], | ||
"group": "component-group", | ||
"name": "component-name-0", | ||
"version": "0.0", | ||
"purl": "pkg:maven/component-group/[email protected]", | ||
"project": { | ||
"name": "Acme Application", | ||
"directDependencies": "${json-unit.any-string}", | ||
"uuid": "${json-unit.matches:projectUuid}", | ||
"active": true | ||
}, | ||
"uuid": "${json-unit.any-string}", | ||
"repositoryMeta": { | ||
"repositoryType": "MAVEN", | ||
"namespace": "component-group", | ||
"name": "component-name-0", | ||
"latestVersion": "0.0", | ||
"lastCheck": "${json-unit.any-number}" | ||
}, | ||
"expandDependencyGraph": false, | ||
"isInternal": false | ||
} | ||
"""); | ||
} | ||
|
||
@Test | ||
|
@@ -188,8 +222,12 @@ private Project prepareProject() throws MalformedPackageURLException { | |
final List<String> directDepencencies = new ArrayList<>(); | ||
// Generate 1000 dependencies | ||
for (int i = 0; i < 1000; i++) { | ||
final var author = new OrganizationalContact(); | ||
author.setName("author-" + i); | ||
|
||
Component component = new Component(); | ||
component.setProject(project); | ||
component.setAuthors(List.of(author)); | ||
component.setGroup("component-group"); | ||
component.setName("component-name-" + i); | ||
component.setVersion(String.valueOf(i) + ".0"); | ||
|