Skip to content

Commit

Permalink
Move setup to top of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
000panther committed Sep 14, 2023
1 parent b2e8e05 commit 9a75a1d
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ void setUp() throws IOException {
doReturn(null)
.when(template)
.query(anyString(), (ResultSetExtractor<? extends Object>) any());
doReturn(null)
.when(template)
.query(
anyString(),
(PreparedStatementSetter) any(),
(ResultSetExtractor<? extends Object>) any());

unionBasedSQLInjectionVulnerability = new UnionBasedSQLInjectionVulnerability(template);
}
Expand Down Expand Up @@ -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<? extends Object>) any());

unionBasedSQLInjectionVulnerability = new UnionBasedSQLInjectionVulnerability(template);

// Act
final Map<String, String> params =
Collections.singletonMap("id", "1' UNION SELECT * FROM cars; --");
Expand Down

0 comments on commit 9a75a1d

Please sign in to comment.