Use parenthesis with single-arg lambdas
Use regular expression search/replace to ensure all single-arg lambdas have parenthesis. This aligns with the style used in Spring Boot and ensure that single-arg and multi-arg lambdas are consistent. Issue gh-8945
This commit is contained in:
@@ -204,7 +204,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
|
||||
if (filterTarget instanceof Stream) {
|
||||
final Stream<?> original = (Stream<?>) filterTarget;
|
||||
|
||||
return original.filter(filterObject -> {
|
||||
return original.filter((filterObject) -> {
|
||||
rootObject.setFilterObject(filterObject);
|
||||
return ExpressionUtils.evaluateAsBoolean(filterExpression, ctx);
|
||||
}).onClose(original::close);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethod
|
||||
|
||||
if ((regMethodName == null) || (!regMethodName.equals(name) && (regMethodName.length() <= name.length()))) {
|
||||
// no already registered method name, or more specific
|
||||
// method name specification now -> (re-)register method
|
||||
// method name specification (now) -> (re-)register method
|
||||
if (regMethodName != null) {
|
||||
this.logger.debug("Replacing attributes for secure method [" + method + "]: current name [" + name
|
||||
+ "] is more specific than [" + regMethodName + "]");
|
||||
|
||||
@@ -86,24 +86,24 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
|
||||
PreInvocationAttribute preAttr = findPreInvocationAttribute(attributes);
|
||||
Mono<Authentication> toInvoke = ReactiveSecurityContextHolder.getContext()
|
||||
.map(SecurityContext::getAuthentication).defaultIfEmpty(this.anonymous)
|
||||
.filter(auth -> this.preInvocationAdvice.before(auth, invocation, preAttr))
|
||||
.filter((auth) -> this.preInvocationAdvice.before(auth, invocation, preAttr))
|
||||
.switchIfEmpty(Mono.defer(() -> Mono.error(new AccessDeniedException("Denied"))));
|
||||
|
||||
PostInvocationAttribute attr = findPostInvocationAttribute(attributes);
|
||||
|
||||
if (Mono.class.isAssignableFrom(returnType)) {
|
||||
return toInvoke.flatMap(auth -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
|
||||
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
return toInvoke.flatMap((auth) -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
|
||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
}
|
||||
|
||||
if (Flux.class.isAssignableFrom(returnType)) {
|
||||
return toInvoke.flatMapMany(auth -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
|
||||
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
return toInvoke.flatMapMany((auth) -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
|
||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
}
|
||||
|
||||
return toInvoke
|
||||
.flatMapMany(auth -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
||||
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
return toInvoke.flatMapMany(
|
||||
(auth) -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
||||
}
|
||||
|
||||
private static <T extends Publisher<?>> T proceed(final MethodInvocation invocation) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager implement
|
||||
|
||||
private Scheduler scheduler = Schedulers.boundedElastic();
|
||||
|
||||
private UserDetailsChecker preAuthenticationChecks = user -> {
|
||||
private UserDetailsChecker preAuthenticationChecks = (user) -> {
|
||||
if (!user.isAccountNonLocked()) {
|
||||
this.logger.debug("User account is locked");
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager implement
|
||||
}
|
||||
};
|
||||
|
||||
private UserDetailsChecker postAuthenticationChecks = user -> {
|
||||
private UserDetailsChecker postAuthenticationChecks = (user) -> {
|
||||
if (!user.isCredentialsNonExpired()) {
|
||||
this.logger.debug("User account credentials have expired");
|
||||
|
||||
@@ -94,9 +94,9 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager implement
|
||||
final String username = authentication.getName();
|
||||
final String presentedPassword = (String) authentication.getCredentials();
|
||||
return retrieveUser(username).doOnNext(this.preAuthenticationChecks::check).publishOn(this.scheduler)
|
||||
.filter(u -> this.passwordEncoder.matches(presentedPassword, u.getPassword()))
|
||||
.filter((u) -> this.passwordEncoder.matches(presentedPassword, u.getPassword()))
|
||||
.switchIfEmpty(Mono.defer(() -> Mono.error(new BadCredentialsException("Invalid Credentials"))))
|
||||
.flatMap(u -> {
|
||||
.flatMap((u) -> {
|
||||
boolean upgradeEncoding = this.userDetailsPasswordService != null
|
||||
&& this.passwordEncoder.upgradeEncoding(u.getPassword());
|
||||
if (upgradeEncoding) {
|
||||
@@ -105,7 +105,7 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager implement
|
||||
}
|
||||
return Mono.just(u);
|
||||
}).doOnNext(this.postAuthenticationChecks::check)
|
||||
.map(u -> new UsernamePasswordAuthenticationToken(u, u.getPassword(), u.getAuthorities()));
|
||||
.map((u) -> new UsernamePasswordAuthenticationToken(u, u.getPassword(), u.getAuthorities()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DelegatingReactiveAuthenticationManager implements ReactiveAuthenti
|
||||
|
||||
@Override
|
||||
public Mono<Authentication> authenticate(Authentication authentication) {
|
||||
return Flux.fromIterable(this.delegates).concatMap(m -> m.authenticate(authentication)).next();
|
||||
return Flux.fromIterable(this.delegates).concatMap((m) -> m.authenticate(authentication)).next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ public class ReactiveAuthenticationManagerAdapter implements ReactiveAuthenticat
|
||||
|
||||
@Override
|
||||
public Mono<Authentication> authenticate(Authentication token) {
|
||||
return Mono.just(token).publishOn(this.scheduler).flatMap(t -> {
|
||||
return Mono.just(token).publishOn(this.scheduler).flatMap((t) -> {
|
||||
try {
|
||||
return Mono.just(this.authenticationManager.authenticate(t));
|
||||
}
|
||||
catch (Throwable error) {
|
||||
return Mono.error(error);
|
||||
}
|
||||
}).filter(a -> a.isAuthenticated());
|
||||
}).filter((a) -> a.isAuthenticated());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ public class AuthenticatedReactiveAuthorizationManager<T> implements ReactiveAut
|
||||
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T object) {
|
||||
return authentication.filter(this::isNotAnonymous).map(a -> new AuthorizationDecision(a.isAuthenticated()))
|
||||
return authentication.filter(this::isNotAnonymous).map((a) -> new AuthorizationDecision(a.isAuthenticated()))
|
||||
.defaultIfEmpty(new AuthorizationDecision(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ public class AuthorityReactiveAuthorizationManager<T> implements ReactiveAuthori
|
||||
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T object) {
|
||||
return authentication.filter(a -> a.isAuthenticated()).flatMapIterable(a -> a.getAuthorities())
|
||||
.map(g -> g.getAuthority()).any(a -> this.authorities.contains(a))
|
||||
.map(hasAuthority -> new AuthorizationDecision(hasAuthority))
|
||||
return authentication.filter((a) -> a.isAuthenticated()).flatMapIterable((a) -> a.getAuthorities())
|
||||
.map((g) -> g.getAuthority()).any((a) -> this.authorities.contains(a))
|
||||
.map((hasAuthority) -> new AuthorizationDecision(hasAuthority))
|
||||
.defaultIfEmpty(new AuthorizationDecision(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ public interface ReactiveAuthorizationManager<T> {
|
||||
* denied
|
||||
*/
|
||||
default Mono<Void> verify(Mono<Authentication> authentication, T object) {
|
||||
return check(authentication, object).filter(d -> d.isGranted())
|
||||
return check(authentication, object).filter((d) -> d.isGranted())
|
||||
.switchIfEmpty(Mono.defer(() -> Mono.error(new AccessDeniedException("Access Denied"))))
|
||||
.flatMap(d -> Mono.empty());
|
||||
.flatMap((d) -> Mono.empty());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class RsaKeyConverters {
|
||||
*/
|
||||
public static Converter<InputStream, RSAPrivateKey> pkcs8() {
|
||||
KeyFactory keyFactory = rsaFactory();
|
||||
return source -> {
|
||||
return (source) -> {
|
||||
List<String> lines = readAllLines(source);
|
||||
Assert.isTrue(!lines.isEmpty() && lines.get(0).startsWith(PKCS8_PEM_HEADER),
|
||||
"Key is not in PEM-encoded PKCS#8 format, " + "please check that the header begins with -----"
|
||||
@@ -102,7 +102,7 @@ public final class RsaKeyConverters {
|
||||
*/
|
||||
public static Converter<InputStream, RSAPublicKey> x509() {
|
||||
KeyFactory keyFactory = rsaFactory();
|
||||
return source -> {
|
||||
return (source) -> {
|
||||
List<String> lines = readAllLines(source);
|
||||
Assert.isTrue(!lines.isEmpty() && lines.get(0).startsWith(X509_PEM_HEADER),
|
||||
"Key is not in PEM-encoded X.509 format, " + "please check that the header begins with -----"
|
||||
|
||||
@@ -41,8 +41,8 @@ public final class ReactiveSecurityContextHolder {
|
||||
* @return the {@code Mono<SecurityContext>}
|
||||
*/
|
||||
public static Mono<SecurityContext> getContext() {
|
||||
return Mono.subscriberContext().filter(c -> c.hasKey(SECURITY_CONTEXT_KEY))
|
||||
.flatMap(c -> c.<Mono<SecurityContext>>get(SECURITY_CONTEXT_KEY));
|
||||
return Mono.subscriberContext().filter((c) -> c.hasKey(SECURITY_CONTEXT_KEY))
|
||||
.flatMap((c) -> c.<Mono<SecurityContext>>get(SECURITY_CONTEXT_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public final class ReactiveSecurityContextHolder {
|
||||
* from clearing the context.
|
||||
*/
|
||||
public static Function<Context, Context> clearContext() {
|
||||
return context -> context.delete(SECURITY_CONTEXT_KEY);
|
||||
return (context) -> context.delete(SECURITY_CONTEXT_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -162,10 +162,10 @@ public class AnnotationParameterNameDiscoverer implements ParameterNameDiscovere
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final ParameterNameFactory<Constructor<?>> CONSTRUCTOR_METHODPARAM_FACTORY = constructor -> constructor
|
||||
.getParameterAnnotations();
|
||||
private static final ParameterNameFactory<Constructor<?>> CONSTRUCTOR_METHODPARAM_FACTORY = (
|
||||
constructor) -> constructor.getParameterAnnotations();
|
||||
|
||||
private static final ParameterNameFactory<Method> METHOD_METHODPARAM_FACTORY = method -> method
|
||||
private static final ParameterNameFactory<Method> METHOD_METHODPARAM_FACTORY = (method) -> method
|
||||
.getParameterAnnotations();
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MapReactiveUserDetailsService implements ReactiveUserDetailsService
|
||||
|
||||
@Override
|
||||
public Mono<UserDetails> updatePassword(UserDetails user, String newPassword) {
|
||||
return Mono.just(user).map(u -> User.withUserDetails(u).password(newPassword).build()).doOnNext(u -> {
|
||||
return Mono.just(user).map((u) -> User.withUserDetails(u).password(newPassword).build()).doOnNext((u) -> {
|
||||
String key = getKey(user.getUsername());
|
||||
this.users.put(key, u);
|
||||
});
|
||||
|
||||
@@ -359,7 +359,7 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
|
||||
private boolean disabled;
|
||||
|
||||
private Function<String, String> passwordEncoder = password -> password;
|
||||
private Function<String, String> passwordEncoder = (password) -> password;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
|
||||
@@ -198,7 +198,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
public void createUser(final UserDetails user) {
|
||||
validateUserDetails(user);
|
||||
|
||||
getJdbcTemplate().update(this.createUserSql, ps -> {
|
||||
getJdbcTemplate().update(this.createUserSql, (ps) -> {
|
||||
ps.setString(1, user.getUsername());
|
||||
ps.setString(2, user.getPassword());
|
||||
ps.setBoolean(3, user.isEnabled());
|
||||
@@ -221,7 +221,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
public void updateUser(final UserDetails user) {
|
||||
validateUserDetails(user);
|
||||
|
||||
getJdbcTemplate().update(this.updateUserSql, ps -> {
|
||||
getJdbcTemplate().update(this.updateUserSql, (ps) -> {
|
||||
ps.setString(1, user.getPassword());
|
||||
ps.setBoolean(2, user.isEnabled());
|
||||
|
||||
@@ -347,7 +347,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
|
||||
for (GrantedAuthority a : authorities) {
|
||||
final String authority = a.getAuthority();
|
||||
getJdbcTemplate().update(this.insertGroupAuthoritySql, ps -> {
|
||||
getJdbcTemplate().update(this.insertGroupAuthoritySql, (ps) -> {
|
||||
ps.setInt(1, groupId);
|
||||
ps.setString(2, authority);
|
||||
});
|
||||
@@ -360,7 +360,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
Assert.hasText(groupName, "groupName should have text");
|
||||
|
||||
final int id = findGroupId(groupName);
|
||||
PreparedStatementSetter groupIdPSS = ps -> ps.setInt(1, id);
|
||||
PreparedStatementSetter groupIdPSS = (ps) -> ps.setInt(1, id);
|
||||
getJdbcTemplate().update(this.deleteGroupMembersSql, groupIdPSS);
|
||||
getJdbcTemplate().update(this.deleteGroupAuthoritiesSql, groupIdPSS);
|
||||
getJdbcTemplate().update(this.deleteGroupSql, groupIdPSS);
|
||||
@@ -382,7 +382,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
Assert.hasText(groupName, "groupName should have text");
|
||||
|
||||
final int id = findGroupId(groupName);
|
||||
getJdbcTemplate().update(this.insertGroupMemberSql, ps -> {
|
||||
getJdbcTemplate().update(this.insertGroupMemberSql, (ps) -> {
|
||||
ps.setInt(1, id);
|
||||
ps.setString(2, username);
|
||||
});
|
||||
@@ -398,7 +398,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
|
||||
final int id = findGroupId(groupName);
|
||||
|
||||
getJdbcTemplate().update(this.deleteGroupMemberSql, ps -> {
|
||||
getJdbcTemplate().update(this.deleteGroupMemberSql, (ps) -> {
|
||||
ps.setInt(1, id);
|
||||
ps.setString(2, username);
|
||||
});
|
||||
@@ -426,7 +426,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
|
||||
final int id = findGroupId(groupName);
|
||||
|
||||
getJdbcTemplate().update(this.deleteGroupAuthoritySql, ps -> {
|
||||
getJdbcTemplate().update(this.deleteGroupAuthoritySql, (ps) -> {
|
||||
ps.setInt(1, id);
|
||||
ps.setString(2, authority.getAuthority());
|
||||
});
|
||||
@@ -439,7 +439,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
Assert.notNull(authority, "authority cannot be null");
|
||||
|
||||
final int id = findGroupId(groupName);
|
||||
getJdbcTemplate().update(this.insertGroupAuthoritySql, ps -> {
|
||||
getJdbcTemplate().update(this.insertGroupAuthoritySql, (ps) -> {
|
||||
ps.setInt(1, id);
|
||||
ps.setString(2, authority.getAuthority());
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SecurityExpressionRootTests {
|
||||
|
||||
@Test
|
||||
public void roleHierarchySupportIsCorrectlyUsedInEvaluatingRoles() {
|
||||
this.root.setRoleHierarchy(authorities -> AuthorityUtils.createAuthorityList("ROLE_C"));
|
||||
this.root.setRoleHierarchy((authorities) -> AuthorityUtils.createAuthorityList("ROLE_C"));
|
||||
|
||||
assertThat(this.root.hasRole("C")).isTrue();
|
||||
assertThat(this.root.hasAuthority("ROLE_C")).isTrue();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
this.manager = new UserDetailsRepositoryReactiveAuthenticationManager(this.userDetailsService);
|
||||
given(this.scheduler.schedule(any())).willAnswer(a -> {
|
||||
given(this.scheduler.schedule(any())).willAnswer((a) -> {
|
||||
Runnable r = a.getArgument(0);
|
||||
return Schedulers.immediate().schedule(r);
|
||||
});
|
||||
|
||||
@@ -236,7 +236,7 @@ public class JaasAuthenticationProviderTests {
|
||||
@Test
|
||||
public void testLoginExceptionResolver() {
|
||||
assertThat(this.jaasProvider.getLoginExceptionResolver()).isNotNull();
|
||||
this.jaasProvider.setLoginExceptionResolver(e -> new LockedException("This is just a test!"));
|
||||
this.jaasProvider.setLoginExceptionResolver((e) -> new LockedException("This is just a test!"));
|
||||
|
||||
try {
|
||||
this.jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DelegatingSecurityContextRunnableTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.originalSecurityContext = SecurityContextHolder.createEmptyContext();
|
||||
willAnswer((Answer<Object>) invocation -> {
|
||||
willAnswer((Answer<Object>) (invocation) -> {
|
||||
assertThat(SecurityContextHolder.getContext()).isEqualTo(this.securityContext);
|
||||
return null;
|
||||
}).given(this.delegate).run();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ReactiveSecurityContextHolderTests {
|
||||
new TestingAuthenticationToken("user", "password", "ROLE_USER"));
|
||||
|
||||
Mono<SecurityContext> context = Mono.subscriberContext()
|
||||
.flatMap(c -> ReactiveSecurityContextHolder.getContext())
|
||||
.flatMap((c) -> ReactiveSecurityContextHolder.getContext())
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withSecurityContext(Mono.just(expectedContext)));
|
||||
|
||||
StepVerifier.create(context).expectNext(expectedContext).verifyComplete();
|
||||
@@ -70,7 +70,7 @@ public class ReactiveSecurityContextHolderTests {
|
||||
new TestingAuthenticationToken("user", "password", "ROLE_USER"));
|
||||
|
||||
Mono<SecurityContext> context = Mono.subscriberContext()
|
||||
.flatMap(c -> ReactiveSecurityContextHolder.getContext())
|
||||
.flatMap((c) -> ReactiveSecurityContextHolder.getContext())
|
||||
.subscriberContext(ReactiveSecurityContextHolder.clearContext())
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withSecurityContext(Mono.just(expectedContext)));
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ReactiveSecurityContextHolderTests {
|
||||
Authentication expectedAuthentication = new TestingAuthenticationToken("user", "password", "ROLE_USER");
|
||||
|
||||
Mono<Authentication> authentication = Mono.subscriberContext()
|
||||
.flatMap(c -> ReactiveSecurityContextHolder.getContext()).map(SecurityContext::getAuthentication)
|
||||
.flatMap((c) -> ReactiveSecurityContextHolder.getContext()).map(SecurityContext::getAuthentication)
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(expectedAuthentication));
|
||||
|
||||
StepVerifier.create(authentication).expectNext(expectedAuthentication).verifyComplete();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PasswordEncodedUser {
|
||||
}
|
||||
|
||||
private static Function<String, String> passwordEncoder() {
|
||||
return rawPassword -> "{noop}" + rawPassword;
|
||||
return (rawPassword) -> "{noop}" + rawPassword;
|
||||
}
|
||||
|
||||
protected PasswordEncodedUser() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class UserDetailsByNameServiceWrapperTests {
|
||||
public final void testGetUserDetails() throws Exception {
|
||||
UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper();
|
||||
final User user = new User("dummy", "dummy", true, true, true, true, AuthorityUtils.NO_AUTHORITIES);
|
||||
svc.setUserDetailsService(name -> {
|
||||
svc.setUserDetailsService((name) -> {
|
||||
if (user != null && user.getUsername().equals(name)) {
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,8 @@ public class UserTests {
|
||||
public void withUserWhenDetailsPasswordEncoderThenEncodes() {
|
||||
UserDetails userDetails = User.withUsername("user").password("password").roles("USER").build();
|
||||
|
||||
UserDetails withEncodedPassword = User.withUserDetails(userDetails).passwordEncoder(p -> p + "encoded").build();
|
||||
UserDetails withEncodedPassword = User.withUserDetails(userDetails).passwordEncoder((p) -> p + "encoded")
|
||||
.build();
|
||||
|
||||
assertThat(withEncodedPassword.getPassword()).isEqualTo("passwordencoded");
|
||||
}
|
||||
@@ -184,7 +185,7 @@ public class UserTests {
|
||||
@Test
|
||||
public void withUsernameWhenPasswordEncoderAndPasswordThenEncodes() {
|
||||
UserDetails withEncodedPassword = User.withUsername("user").password("password")
|
||||
.passwordEncoder(p -> p + "encoded").roles("USER").build();
|
||||
.passwordEncoder((p) -> p + "encoded").roles("USER").build();
|
||||
|
||||
assertThat(withEncodedPassword.getPassword()).isEqualTo("passwordencoded");
|
||||
}
|
||||
@@ -193,7 +194,7 @@ public class UserTests {
|
||||
public void withUsernameWhenPasswordAndPasswordEncoderThenEncodes() {
|
||||
// @formatter:off
|
||||
UserDetails withEncodedPassword = User.withUsername("user")
|
||||
.passwordEncoder(p -> p + "encoded")
|
||||
.passwordEncoder((p) -> p + "encoded")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
@@ -204,7 +205,7 @@ public class UserTests {
|
||||
|
||||
@Test
|
||||
public void withUsernameWhenPasswordAndPasswordEncoderTwiceThenEncodesOnce() {
|
||||
Function<String, String> encoder = p -> p + "encoded";
|
||||
Function<String, String> encoder = (p) -> p + "encoded";
|
||||
// @formatter:off
|
||||
UserDetails withEncodedPassword = User.withUsername("user")
|
||||
.passwordEncoder(encoder)
|
||||
|
||||
Reference in New Issue
Block a user