Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(test): remove trailing slash from mock url template with spr…
…ing boot upgrade to 3.x With spring boot upgrade, spring framework also upgrades from 5.x to 6.x. In spring framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to false. https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.0-Release-Notes#web-applications Due to this change, encountered the below test failure: ``` Condition failed with Exception: mockMvc.perform(get("/authorize/")) .andExpect(status().isOk()) .andExpect(content().json(expected)) | | | | | | | | | | | <org.springframework.test.web.servlet.result.StatusResultMatchers$$Lambda$1833/0x0000000801998000@1cadc7c1 arg$1=200 OK> | | | | <org.springframework.test.web.servlet.result.StatusResultMatchers@34106ddc> | | | java.lang.AssertionError: Status expected:<200> but was:<404> | | | at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:59) | | | at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:122) | | | at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:637) | | | at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:214) | | | at com.netflix.spinnaker.fiat.controllers.AuthorizeControllerSpec.should get user from repo via endpoint(AuthorizeControllerSpec.groovy:180) | | <org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder@4c5c8926 method=GET url=/authorize/ contextPath= servletPath= pathInfo=/authorize/ secure=null principal=null session=null remoteAddress=null characterEncoding=null content=[] contentType=application/json headers=[:] parameters=[:] queryParams=[:] cookies=[] locales=[] requestAttributes=[:] sessionAttributes=[:] flashAttributes=[:] postProcessors=[]> | <org.springframework.test.web.servlet.MockMvc$1@6a230707 val$mvcResult=org.springframework.test.web.servlet.DefaultMvcResult@5ed59e7f this$0=org.springframework.test.web.servlet.MockMvc@27477eb7> <org.springframework.test.web.servlet.MockMvc@27477eb7 servlet=org.springframework.test.web.servlet.TestDispatcherServlet@512efef4 filters=[] servletContext=org.springframework.boot.test.mock.web.SpringBootMockServletContext@1cf516fa defaultRequestBuilder=org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder@5b96272e defaultResponseCharacterEncoding=null defaultResultMatchers=[] defaultResultHandlers=[]> Condition failed with Exception: mockMvc.perform(get("/authorize/")) .andExpect(status().isOk()) .andExpect(content().json(expected)) | | | | | | | | | | | <org.springframework.test.web.servlet.result.StatusResultMatchers$$Lambda$1833/0x0000000801998000@1cadc7c1 arg$1=200 OK> | | | | <org.springframework.test.web.servlet.result.StatusResultMatchers@34106ddc> | | | java.lang.AssertionError: Status expected:<200> but was:<404> | | | at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:59) | | | at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:122) | | | at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:637) | | | at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:214) | | | at com.netflix.spinnaker.fiat.controllers.AuthorizeControllerSpec.should get user from repo via endpoint(AuthorizeControllerSpec.groovy:180) | | <org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder@4c5c8926 method=GET url=/authorize/ contextPath= servletPath= pathInfo=/authorize/ secure=null principal=null session=null remoteAddress=null characterEncoding=null content=[] contentType=application/json headers=[:] parameters=[:] queryParams=[:] cookies=[] locales=[] requestAttributes=[:] sessionAttributes=[:] flashAttributes=[:] postProcessors=[]> | <org.springframework.test.web.servlet.MockMvc$1@6a230707 val$mvcResult=org.springframework.test.web.servlet.DefaultMvcResult@5ed59e7f this$0=org.springframework.test.web.servlet.MockMvc@27477eb7> <org.springframework.test.web.servlet.MockMvc@27477eb7 servlet=org.springframework.test.web.servlet.TestDispatcherServlet@512efef4 filters=[] servletContext=org.springframework.boot.test.mock.web.SpringBootMockServletContext@1cf516fa defaultRequestBuilder=org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder@5b96272e defaultResponseCharacterEncoding=null defaultResultMatchers=[] defaultResultHandlers=[]> at com.netflix.spinnaker.fiat.controllers.AuthorizeControllerSpec.should get user from repo via endpoint(AuthorizeControllerSpec.groovy:181) Caused by: java.lang.AssertionError: Status expected:<200> but was:<404> at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:59) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:122) at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:637) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:214) at com.netflix.spinnaker.fiat.controllers.AuthorizeControllerSpec.should get user from repo via endpoint(AuthorizeControllerSpec.groovy:180) ``` In order to fix this issue, removed the trailing slash from the mock url `/authorize`.
- Loading branch information