From 1f6ef18e92d1841f32f95d6b4e5d44c78c3d016f Mon Sep 17 00:00:00 2001 From: nscuro Date: Tue, 13 Feb 2024 19:11:13 +0100 Subject: [PATCH] Address remaining test failures Signed-off-by: nscuro --- .../org/dependencytrack/persistence/QueryManager.java | 4 ++-- .../dependencytrack/resources/v1/ProjectResourceTest.java | 1 + .../resources/v1/VulnerabilityResourceTest.java | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/dependencytrack/persistence/QueryManager.java b/src/main/java/org/dependencytrack/persistence/QueryManager.java index 36914b51d..098a39cfd 100644 --- a/src/main/java/org/dependencytrack/persistence/QueryManager.java +++ b/src/main/java/org/dependencytrack/persistence/QueryManager.java @@ -1525,9 +1525,9 @@ public void recursivelyDeleteTeam(Team team) { pm.currentTransaction().begin(); pm.deletePersistentAll(team.getApiKeys()); String aclDeleteQuery = """ - DELETE FROM PROJECT_ACCESS_TEAMS WHERE \"PROJECT_ACCESS_TEAMS\".\"TEAM_ID\" = ? + DELETE FROM "PROJECT_ACCESS_TEAMS" WHERE "TEAM_ID" = ? """; - final Query query = pm.newQuery(JDOQuery.SQL_QUERY_LANGUAGE, aclDeleteQuery); + final Query query = pm.newQuery(JDOQuery.SQL_QUERY_LANGUAGE, aclDeleteQuery); query.executeWithArray(team.getId()); pm.deletePersistent(team); pm.currentTransaction().commit(); diff --git a/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java b/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java index db344f2be..3d64759a5 100644 --- a/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java +++ b/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java @@ -501,6 +501,7 @@ public void updateProjectEmptyNameTest() { public void updateProjectDuplicateTest() { qm.createProject("ABC", null, "1.0", null, null, null, true, false); Project project = qm.createProject("DEF", null, "1.0", null, null, null, true, false); + project = qm.detach(Project.class, project.getId()); project.setName("ABC"); Response response = target(V1_PROJECT) .request() diff --git a/src/test/java/org/dependencytrack/resources/v1/VulnerabilityResourceTest.java b/src/test/java/org/dependencytrack/resources/v1/VulnerabilityResourceTest.java index 73ad9d594..b3766ca11 100644 --- a/src/test/java/org/dependencytrack/resources/v1/VulnerabilityResourceTest.java +++ b/src/test/java/org/dependencytrack/resources/v1/VulnerabilityResourceTest.java @@ -400,8 +400,8 @@ public void createVulnerabilityTest() throws Exception { Assert.assertEquals(2.8, json.getJsonNumber("cvssV3ExploitabilitySubScore").doubleValue(), 0); Assert.assertEquals("CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", json.getString("cvssV3Vector")); Assert.assertEquals(1.0, json.getJsonNumber("owaspRRLikelihoodScore").doubleValue(), 0); - Assert.assertEquals(1.3, json.getJsonNumber("owaspRRTechnicalImpactScore").doubleValue(), 0); - Assert.assertEquals(1.8, json.getJsonNumber("owaspRRBusinessImpactScore").doubleValue(), 0); + Assert.assertEquals(1.25, json.getJsonNumber("owaspRRTechnicalImpactScore").doubleValue(), 0); + Assert.assertEquals(1.75, json.getJsonNumber("owaspRRBusinessImpactScore").doubleValue(), 0); Assert.assertEquals("SL:1/M:1/O:0/S:2/ED:1/EE:1/A:1/ID:1/LC:2/LI:1/LAV:1/LAC:1/FD:1/RD:1/NC:2/PV:3", json.getString("owaspRRVector")); Assert.assertEquals("MEDIUM", json.getString("severity")); Assert.assertNotNull(json.getJsonObject("cwe")); @@ -531,8 +531,8 @@ public void updateVulnerabilityTest() throws Exception { Assert.assertEquals(3.4, json.getJsonNumber("cvssV3ImpactSubScore").doubleValue(), 0); Assert.assertEquals(2.8, json.getJsonNumber("cvssV3ExploitabilitySubScore").doubleValue(), 0); Assert.assertEquals(1.0, json.getJsonNumber("owaspRRLikelihoodScore").doubleValue(), 0); - Assert.assertEquals(1.3, json.getJsonNumber("owaspRRTechnicalImpactScore").doubleValue(), 0); - Assert.assertEquals(1.8, json.getJsonNumber("owaspRRBusinessImpactScore").doubleValue(), 0); + Assert.assertEquals(1.25, json.getJsonNumber("owaspRRTechnicalImpactScore").doubleValue(), 0); + Assert.assertEquals(1.75, json.getJsonNumber("owaspRRBusinessImpactScore").doubleValue(), 0); Assert.assertEquals("CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", json.getString("cvssV3Vector")); Assert.assertEquals("SL:1/M:1/O:0/S:2/ED:1/EE:1/A:1/ID:1/LC:2/LI:1/LAV:1/LAC:1/FD:1/RD:1/NC:2/PV:3", json.getString("owaspRRVector")); Assert.assertEquals("MEDIUM", json.getString("severity"));