This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-configuration-processor</artifactId> | |
<version>2.2.2.RELEASE</version> | |
<optional>true</optional> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-autoconfigure</artifactId> | |
<version>2.2.2.RELEASE</version> | |
<scope>compile</scope> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.my.developer</groupId> | |
<artifactId>my-org-starter-security</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | |
com.ibm.developer.security.SecurityConfig,\ | |
com.ibm.developer.security.WebSecurityConfig,\ | |
com.ibm.developer.security.NonWebSecurityConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableConfigurationProperties({ CommandLineSecurityConfigurer.class }) | |
@ConditionalOnNotWebApplication | |
public class NonWebSecurityConfig { | |
@Bean | |
public GrantedAuthority createGrantedAuthority(CommandLineSecurityConfigurer cliSecurityConfigurer) { | |
return new SimpleGrantedAuthority("ROLE_" + cliSecurityConfigurer.getRequiredRole()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | |
org.my.developer.security.SecurityConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class SecurityConfig { | |
@Bean | |
public PasswordEncoder passwordEncoder() { | |
return PasswordEncoderFactories.createDelegatingPasswordEncoder(); | |
} | |
@Bean | |
public UserDetailsService users(PasswordEncoder encoder) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Timeout(3) // Sets timeout limit for each test in class to five seconds | |
@TestMethodOrder(OrderAnnotation.class) | |
public class TimeoutTest { | |
static int testCounter = 0; | |
@BeforeAll | |
@Timeout(2) // If this timeout is exceeded, all tests are failed | |
public static void classSetupWithTimeout() throws InterruptedException { | |
// ...complex setup code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Timeout(3) // Sets timeout limit for each test in class to three seconds | |
@TestMethodOrder(OrderAnnotation.class) | |
public class TimeoutTest { | |
static int testCounter = 0; | |
@BeforeAll | |
@Timeout(2) // If this timeout is exceeded, all tests are failed | |
public static void classSetupWithTimeout() throws InterruptedException { | |
// ...complex setup code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Testcontainers | |
@SpringJUnitConfig | |
@ContextConfiguration(classes = { | |
StormTrackerApplication.class }, initializers = ITStormRepoAlternate.Initializer.class) | |
@TestPropertySource("classpath:application.properties") | |
@TestMethodOrder(OrderAnnotation.class) | |
public class ITStormRepoAlternate { | |
@Container | |
private static PostgreSQLContainer container = new PostgreSQLContainer("postgres:11.2");//Can be an arbitrary image name and tag |