Final changes for splitting SQL WebGoat and lessons
This commit is contained in:
parent
25dae3a4a8
commit
689e3de7a4
@ -2,6 +2,7 @@ package org.owasp.webgoat;
|
||||
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.owasp.webgoat.service.RestartLessonService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
@ -18,16 +19,19 @@ import java.util.Map;
|
||||
public class DatabaseInitialization {
|
||||
|
||||
private final DataSource dataSource;
|
||||
private String driverClassName;
|
||||
|
||||
public DatabaseInitialization(DataSource dataSource) {
|
||||
public DatabaseInitialization(DataSource dataSource,
|
||||
@Value("${spring.datasource.driver-class-name}") String driverClassName) {
|
||||
this.dataSource = dataSource;
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
@Bean(initMethod = "migrate")
|
||||
public Flyway flyWayContainer() {
|
||||
return Flyway
|
||||
.configure().configuration(
|
||||
Map.of("driver", "org.hsqldb.jdbc.JDBCDriver"))
|
||||
.configure()
|
||||
.configuration(Map.of("driver", driverClassName))
|
||||
.dataSource(dataSource)
|
||||
.schemas("container")
|
||||
.locations("db/container")
|
||||
@ -38,8 +42,8 @@ public class DatabaseInitialization {
|
||||
@DependsOn("flyWayContainer")
|
||||
public Flyway flywayLessons() {
|
||||
return Flyway
|
||||
.configure().configuration(
|
||||
Map.of("driver", "org.hsqldb.jdbc.JDBCDriver"))
|
||||
.configure()
|
||||
.configuration(Map.of("driver", driverClassName))
|
||||
.dataSource(dataSource)
|
||||
.load();
|
||||
}
|
||||
|
@ -47,9 +47,10 @@ public class HSQLDBDatabaseConfig {
|
||||
@Bean
|
||||
@DependsOn("hsqlStandalone")
|
||||
@Primary
|
||||
public DataSource dataSource(@Value("${spring.datasource.url}") String url) {
|
||||
public DataSource dataSource(@Value("${spring.datasource.url}") String url,
|
||||
@Value("${spring.datasource.driver-class-name}") String driverClassName) {
|
||||
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(url);
|
||||
driverManagerDataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
|
||||
driverManagerDataSource.setDriverClassName(driverClassName);
|
||||
return driverManagerDataSource;
|
||||
}
|
||||
}
|
||||
|
@ -64,12 +64,4 @@ public class MvcConfiguration implements WebMvcConfigurer {
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DataSource dataSource(@Value("${spring.datasource.url}") String url) {
|
||||
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(url);
|
||||
driverManagerDataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
|
||||
return driverManagerDataSource;
|
||||
}
|
||||
}
|
@ -23,10 +23,14 @@
|
||||
package org.owasp.webwolf;
|
||||
|
||||
import org.owasp.webwolf.requests.WebWolfTraceRepository;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@SpringBootApplication
|
||||
public class WebWolf {
|
||||
@ -40,4 +44,11 @@ public class WebWolf {
|
||||
System.setProperty("spring.config.name", "application-webwolf");
|
||||
SpringApplication.run(WebWolf.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource(@Value("${spring.datasource.url}") String url, @Value("${spring.datasource.driver-class-name}") String driverClassName) {
|
||||
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(url);
|
||||
driverManagerDataSource.setDriverClassName(driverClassName);
|
||||
return driverManagerDataSource;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ server.servlet.session.cookie.name=WEBWOLFSESSION
|
||||
server.servlet.session.timeout=6000
|
||||
|
||||
spring.datasource.url=jdbc:hsqldb:hsql://${WEBGOAT_HOST:127.0.0.1}:${WEBGOAT_HSQLPORT:9001}/webgoat
|
||||
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
|
||||
spring.jpa.properties.hibernate.default_schema=CONTAINER
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
|
@ -35,6 +35,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
@ -49,6 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebMvcTest(MailboxController.class)
|
||||
@ActiveProfiles({"test", "webwolf"})
|
||||
public class MailboxControllerTest {
|
||||
|
||||
@Autowired
|
||||
|
Loading…
x
Reference in New Issue
Block a user