Apply formatting

This commit is contained in:
Marcus Hert Da Coregio
2024-01-24 10:28:39 -03:00
parent 64eb62026c
commit 923b627eda
35 changed files with 175 additions and 110 deletions

View File

@@ -51,7 +51,7 @@ class AspectJInterceptorTests {
@Test
void securedMethodNotAuthenticated() {
assertThatExceptionOfType(AuthenticationCredentialsNotFoundException.class)
.isThrownBy(() -> this.service.secureMethod());
.isThrownBy(() -> this.service.secureMethod());
}
@Test
@@ -69,7 +69,7 @@ class AspectJInterceptorTests {
@Test
void securedClassNotAuthenticated() {
assertThatExceptionOfType(AuthenticationCredentialsNotFoundException.class)
.isThrownBy(() -> this.securedService.secureMethod());
.isThrownBy(() -> this.securedService.secureMethod());
}
@Test

View File

@@ -35,7 +35,8 @@ public class DataSourceConfiguration {
public DataSource dataSource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
return builder.setType(EmbeddedDatabaseType.HSQL)
.addScript("classpath:org/springframework/security/core/userdetails/jdbc/users.ddl").build();
.addScript("classpath:org/springframework/security/core/userdetails/jdbc/users.ddl")
.build();
}
}

View File

@@ -31,11 +31,16 @@ public class SecurityConfiguration {
@Bean
UserDetailsManager users(DataSource dataSource) {
UserDetails user = User.builder().username("user")
.password("{bcrypt}$2a$10$AiyMWI4UBLozgXq6itzyVuxrtofjcPzn/WS3fOrcqgzdax9jB7Io.").roles("USER").build();
UserDetails admin = User.builder().username("admin")
.password("{bcrypt}$2a$10$AiyMWI4UBLozgXq6itzyVuxrtofjcPzn/WS3fOrcqgzdax9jB7Io.").roles("USER", "ADMIN")
.build();
UserDetails user = User.builder()
.username("user")
.password("{bcrypt}$2a$10$AiyMWI4UBLozgXq6itzyVuxrtofjcPzn/WS3fOrcqgzdax9jB7Io.")
.roles("USER")
.build();
UserDetails admin = User.builder()
.username("admin")
.password("{bcrypt}$2a$10$AiyMWI4UBLozgXq6itzyVuxrtofjcPzn/WS3fOrcqgzdax9jB7Io.")
.roles("USER", "ADMIN")
.build();
JdbcUserDetailsManager users = new JdbcUserDetailsManager(dataSource);
users.createUser(user);
users.createUser(admin);

View File

@@ -55,7 +55,7 @@ public class X509Tests {
void notCertificateThenSslHandshakeException() {
RestTemplate rest = new RestTemplate();
assertThatCode(() -> rest.getForEntity(getServerUrl(), String.class))
.hasCauseInstanceOf(SSLHandshakeException.class);
.hasCauseInstanceOf(SSLHandshakeException.class);
}
@Test

View File

@@ -64,9 +64,11 @@ public class Saml2JavaConfigurationITests {
@BeforeEach
void setup() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext)
.apply(SecurityMockMvcConfigurers.springSecurity()).build();
.apply(SecurityMockMvcConfigurers.springSecurity())
.build();
this.webClient = MockMvcWebClientBuilder.mockMvcSetup(this.mvc)
.withDelegate(new LocalHostWebClient(this.environment)).build();
.withDelegate(new LocalHostWebClient(this.environment))
.build();
this.webClient.getCookieManager().clearCookies();
}
@@ -114,7 +116,7 @@ public class Saml2JavaConfigurationITests {
private HtmlForm findForm(HtmlPage login) {
await().atMost(10, TimeUnit.SECONDS)
.until(() -> login.getForms().stream().map(HtmlForm::getId).anyMatch("form19"::equals));
.until(() -> login.getForms().stream().map(HtmlForm::getId).anyMatch("form19"::equals));
for (HtmlForm form : login.getForms()) {
try {
if (form.getId().equals("form19")) {

View File

@@ -60,16 +60,17 @@ public class SecurityConfiguration {
@Bean
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository() {
RelyingPartyRegistration relyingPartyRegistration = RelyingPartyRegistrations
.fromMetadataLocation("https://dev-05937739.okta.com/app/exk46xofd8NZvFCpS5d7/sso/saml/metadata")
.registrationId("one")
.decryptionX509Credentials(
(c) -> c.add(Saml2X509Credential.decryption(this.privateKey, relyingPartyCertificate())))
.signingX509Credentials(
(c) -> c.add(Saml2X509Credential.signing(this.privateKey, relyingPartyCertificate())))
.singleLogoutServiceLocation(
"https://dev-05937739.okta.com/app/dev-05937739_springgsecuritysaml2idp_1/exk46xofd8NZvFCpS5d7/slo/saml")
.singleLogoutServiceResponseLocation("http://localhost:8080/logout/saml2/slo")
.singleLogoutServiceBinding(Saml2MessageBinding.POST).build();
.fromMetadataLocation("https://dev-05937739.okta.com/app/exk46xofd8NZvFCpS5d7/sso/saml/metadata")
.registrationId("one")
.decryptionX509Credentials(
(c) -> c.add(Saml2X509Credential.decryption(this.privateKey, relyingPartyCertificate())))
.signingX509Credentials(
(c) -> c.add(Saml2X509Credential.signing(this.privateKey, relyingPartyCertificate())))
.singleLogoutServiceLocation(
"https://dev-05937739.okta.com/app/dev-05937739_springgsecuritysaml2idp_1/exk46xofd8NZvFCpS5d7/slo/saml")
.singleLogoutServiceResponseLocation("http://localhost:8080/logout/saml2/slo")
.singleLogoutServiceBinding(Saml2MessageBinding.POST)
.build();
return new InMemoryRelyingPartyRegistrationRepository(relyingPartyRegistration);
}