Replace Base64Utils with JDK's Base64

See gh-33967
This commit is contained in:
Johnny Lim
2023-01-25 01:44:46 +09:00
committed by Moritz Halbritter
parent b62b88372f
commit bc7fc90550
23 changed files with 73 additions and 67 deletions

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.test.autoconfigure.security;
import java.util.Base64;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +27,6 @@ import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.util.Base64Utils;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -55,8 +56,10 @@ class MockMvcSecurityIntegrationTests {
@Test
void okResponseWithBasicAuthCredentialsForKnownUser() throws Exception {
this.mockMvc.perform(get("/").header(HttpHeaders.AUTHORIZATION,
"Basic " + Base64Utils.encodeToString("user:secret".getBytes()))).andExpect(status().isOk());
this.mockMvc
.perform(get("/").header(HttpHeaders.AUTHORIZATION,
"Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes())))
.andExpect(status().isOk());
}
}