Use headers instead of WithMockUser
This ensures that we don't get false positives when the Reactor return types are not continuous.
This commit is contained in:
@@ -6,15 +6,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
|
||||
|
||||
@SpringBootTest()
|
||||
class EmployeeServiceApplicationTest {
|
||||
|
||||
@@ -78,7 +75,6 @@ class EmployeeServiceApplicationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser("hasRole('ADMIN')")
|
||||
void canQuerySalaryAsAdmin() {
|
||||
String query = "{" +
|
||||
" employees{ " +
|
||||
@@ -89,6 +85,7 @@ class EmployeeServiceApplicationTest {
|
||||
|
||||
|
||||
client.post().uri("")
|
||||
.headers(h -> h.setBasicAuth("admin", "admin"))
|
||||
.bodyValue("{ \"query\": \"" + query + "\"}")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
|
||||
Reference in New Issue
Block a user