From 9a75a1d998f53d6ad933766e1cc737d9aa8643fc Mon Sep 17 00:00:00 2001 From: Paul Weber Date: Thu, 14 Sep 2023 11:22:00 +0200 Subject: [PATCH] Move setup to top of tests --- ...UnionBasedSQLInjectionVulnerabilityTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/sasanlabs/service/vulnerability/sqlInjection/UnionBasedSQLInjectionVulnerabilityTest.java b/src/test/java/org/sasanlabs/service/vulnerability/sqlInjection/UnionBasedSQLInjectionVulnerabilityTest.java index c0dea511..5d73d7a9 100644 --- a/src/test/java/org/sasanlabs/service/vulnerability/sqlInjection/UnionBasedSQLInjectionVulnerabilityTest.java +++ b/src/test/java/org/sasanlabs/service/vulnerability/sqlInjection/UnionBasedSQLInjectionVulnerabilityTest.java @@ -29,6 +29,12 @@ void setUp() throws IOException { doReturn(null) .when(template) .query(anyString(), (ResultSetExtractor) any()); + doReturn(null) + .when(template) + .query( + anyString(), + (PreparedStatementSetter) any(), + (ResultSetExtractor) any()); unionBasedSQLInjectionVulnerability = new UnionBasedSQLInjectionVulnerability(template); } @@ -77,17 +83,6 @@ void getCarInformationLevel3_ExpectParamEscaped() throws IOException { @Test void getCarInformationLevel4_ExpecParamEscaped() throws IOException { - // Setup - template = Mockito.spy(new JdbcTemplate()); - doReturn(null) - .when(template) - .query( - anyString(), - (PreparedStatementSetter) any(), - (ResultSetExtractor) any()); - - unionBasedSQLInjectionVulnerability = new UnionBasedSQLInjectionVulnerability(template); - // Act final Map params = Collections.singletonMap("id", "1' UNION SELECT * FROM cars; --");