Add noformat blocks around User.withUsername
Find `User.withUsername` calls and protect them against formatting. Issue gh-8945
This commit is contained in:
+2
@@ -67,12 +67,14 @@ public class UserDetailsMapFactoryBean implements FactoryBean<Collection<UserDet
|
||||
throw new IllegalStateException("The entry with username '" + name
|
||||
+ "' and value '" + property + "' could not be converted to a UserDetails.");
|
||||
}
|
||||
// @formatter:off
|
||||
UserDetails user = User.withUsername(name)
|
||||
.password(attr.getPassword())
|
||||
.disabled(!attr.isEnabled())
|
||||
.authorities(attr.getAuthorities())
|
||||
.build();
|
||||
users.add(user);
|
||||
// @formatter:on
|
||||
} return users;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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
|
||||
|
||||
+2
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user