Skip to content

Commit

Permalink
Fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
nkonev committed Feb 22, 2024
1 parent e01914f commit 16aea3c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -33,14 +34,16 @@

import static org.springframework.security.config.Customizer.withDefaults;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

public class AutoconfigurationSecurityTest {

@AutoConfigureMockMvc
@SpringBootApplication
@SpringBootConfiguration
@EnableAutoConfiguration
public static class MyConfig {

}
Expand Down Expand Up @@ -112,7 +115,7 @@ public void testWithMockMvc() throws Exception {



mockMvc.perform(
final var asyncMvcResult = mockMvc.perform(
MockMvcRequestBuilders
.multipart("/graphql")
.file(filePart1)
Expand All @@ -122,8 +125,9 @@ public void testWithMockMvc() throws Exception {
.accept(MediaType.APPLICATION_GRAPHQL_RESPONSE_VALUE)
.with(csrf())
.with(SecurityMockMvcRequestPostProcessors.httpBasic("user", "password"))
)
).andReturn();

mockMvc.perform(asyncDispatch(asyncMvcResult))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.multiFileUpload").isNotEmpty())
Expand Down

0 comments on commit 16aea3c

Please sign in to comment.