Fix merge request
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
package org.owasp.webgoat;
|
||||
|
||||
import org.hsqldb.jdbc.JDBCDriver;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TestApplication {
|
||||
|
||||
/**
|
||||
* We define our own datasource, otherwise we end up with Hikari one which for some lessons will
|
||||
* throw an error (feature not supported)
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "webgoat.start", name = "hsqldb", havingValue = "false")
|
||||
public DataSource dataSource(@Value("${spring.datasource.url}") String url) throws SQLException {
|
||||
DriverManager.registerDriver(new JDBCDriver());
|
||||
return new DriverManagerDataSource(url);
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import org.junit.Before;
|
||||
import org.owasp.webgoat.i18n.Language;
|
||||
import org.owasp.webgoat.i18n.PluginMessages;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
import org.owasp.webgoat.session.WebgoatContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
@ -34,8 +33,7 @@ public abstract class LessonTest {
|
||||
protected PluginMessages messages;
|
||||
@MockBean
|
||||
protected WebSession webSession;
|
||||
@Autowired
|
||||
private WebgoatContext context;
|
||||
|
||||
@MockBean
|
||||
private Language language;
|
||||
|
||||
@ -43,7 +41,6 @@ public abstract class LessonTest {
|
||||
public void init() {
|
||||
when(webSession.getUserName()).thenReturn("unit-test");
|
||||
when(language.getLocale()).thenReturn(Locale.getDefault());
|
||||
when(webSession.getWebgoatContext()).thenReturn(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@DataJpaTest
|
||||
@RunWith(SpringRunner.class)
|
||||
@ActiveProfiles({"test", "webgoat"})
|
||||
public class UserRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
@ -24,6 +26,4 @@ public class UserRepositoryTest {
|
||||
Assertions.assertThat(user.getUsername()).isEqualTo("test");
|
||||
Assertions.assertThat(user.getPassword()).isEqualTo("password");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,12 +9,14 @@ import org.owasp.webgoat.lessons.Category;
|
||||
import org.owasp.webgoat.lessons.Lesson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@DataJpaTest
|
||||
@RunWith(SpringRunner.class)
|
||||
@ActiveProfiles({"test", "webgoat"})
|
||||
public class UserTrackerRepositoryTest {
|
||||
|
||||
private class TestLesson extends Lesson {
|
||||
@ -44,7 +46,6 @@ public class UserTrackerRepositoryTest {
|
||||
@Autowired
|
||||
private UserTrackerRepository userTrackerRepository;
|
||||
|
||||
|
||||
@Test
|
||||
public void saveUserTracker() {
|
||||
UserTracker userTracker = new UserTracker("test");
|
||||
|
@ -1,4 +1,5 @@
|
||||
webgoat.user.directory=${java.io.tmpdir}
|
||||
|
||||
spring.datasource.url=jdbc:hsqldb:mem:test
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
webgoat.start.hsqldb=false
|
||||
spring.flyway.locations=classpath:/db/container
|
||||
|
Reference in New Issue
Block a user