Add noformat blocks around User.withUsername

Find `User.withUsername` calls and protect them against formatting.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-23 13:05:15 -07:00
committed by Rob Winch
parent 63b5998fad
commit 6979125ccf
8 changed files with 26 additions and 3 deletions

View File

@@ -114,11 +114,13 @@ public class NamespacePasswordEncoderTests {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// @formatter:off
UserDetails user = User.withUsername("user")
.passwordEncoder(encoder::encode)
.password("password")
.roles("USER")
.build();
// @formatter:on
InMemoryUserDetailsManager uds = new InMemoryUserDetailsManager(user);
// @formatter:off
auth

View File

@@ -255,10 +255,12 @@ public class EnableWebFluxSecurityTests {
static class MapReactiveUserDetailsServiceConfig {
@Bean
public MapReactiveUserDetailsService userDetailsService() {
// @formatter:off
return new MapReactiveUserDetailsService(User.withUsername("user")
.password("{noop}password")
.roles("USER")
.build()
// @formatter:on
);
}
}

View File

@@ -92,11 +92,12 @@ public class UserDetailsResourceFactoryBeanTests {
private void assertLoaded() throws Exception {
Collection<UserDetails> users = factory.getObject();
// @formatter:off
UserDetails expectedUser = User.withUsername("user")
.password("password")
.authorities("ROLE_USER")
.build();
// @formatter:on
assertThat(users).containsExactly(expectedUser);
}
}