Polish gh-10911

This commit is contained in:
Steve Riesenberg 2022-03-17 12:32:48 -05:00
parent 1b29c43a11
commit 987ee2e67a
No known key found for this signature in database
GPG Key ID: 5F311AB48A55D521
2 changed files with 16 additions and 6 deletions

View File

@ -74,11 +74,14 @@ public class ServerHttpBasicAuthenticationConverter implements Function<ServerWe
} }
} }
public Charset getCredentialsCharset() { /**
return this.credentialsCharset; * Sets the {@link Charset} used to decode the Base64-encoded bytes of the basic
} * authentication credentials. The default is <code>UTF_8</code>.
* @param credentialsCharset the {@link Charset} used to decode the Base64-encoded
public void setCredentialsCharset(Charset credentialsCharset) { * bytes of the basic authentication credentials
* @since 5.7
*/
public final void setCredentialsCharset(Charset credentialsCharset) {
Assert.notNull(credentialsCharset, "credentialsCharset cannot be null"); Assert.notNull(credentialsCharset, "credentialsCharset cannot be null");
this.credentialsCharset = credentialsCharset; this.credentialsCharset = credentialsCharset;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,6 +28,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/** /**
* @author Rob Winch * @author Rob Winch
@ -39,6 +40,12 @@ public class ServerHttpBasicAuthenticationConverterTests {
MockServerHttpRequest.BaseBuilder<?> request = MockServerHttpRequest.get("/"); MockServerHttpRequest.BaseBuilder<?> request = MockServerHttpRequest.get("/");
@Test
public void setCredentialsCharsetWhenNullThenThrowsIllegalArgumentException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.converter.setCredentialsCharset(null))
.withMessage("credentialsCharset cannot be null");
}
@Test @Test
public void applyWhenNoAuthorizationHeaderThenEmpty() { public void applyWhenNoAuthorizationHeaderThenEmpty() {
Mono<Authentication> result = apply(this.request); Mono<Authentication> result = apply(this.request);