У нас есть простое веб-приложение на основе Spring-boot 2.0.4 с включенным Spring Security 5 для аутентификации OAuth2 (поставщик OpenID). Безопасность работает, как и ожидалось, но теперь случаи модульного тестирования не проходят, и я не могу убедить Spring игнорировать безопасность при выполнении цели теста в maven. Я следовал предложениям в этой теме , но безрезультатно. Кажется, ничего не работает - все мои тесты на локальном хосте продолжают проваливаться с ошибками 401.
Вот что в журнале ошибок:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests
11:26:42,821 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
11:26:42,822 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
11:26:42,822 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/BlueCostSpreadsheetUploadWeb/backend/target/classes/logback.xml]
11:26:42,825 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
11:26:42,825 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/C:/BlueCostSpreadsheetUploadWeb/backend/target/classes/logback.xml]
11:26:42,825 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/C:/Users/JamesDePaul/.m2/repository/net/sourceforge/cobertura/cobertura/2.1.1/cobertura-2.1.1.jar!/logback.xml]
11:26:43,168 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
11:26:43,170 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
11:26:43,210 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
11:26:43,381 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
11:26:43,381 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
11:26:43,381 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
11:26:43,385 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.jdbc] to ERROR
11:26:43,386 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.jdbc] to true
11:26:43,386 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.springframework.jdbc]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.web] to INFO
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.web] to true
11:26:43,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.springframework.web]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.ibm.cio.cloud.cost.spreadsheet.upload] to INFO
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.ibm.cio.cloud.cost.spreadsheet.upload] to true
11:26:43,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.ibm.cio.cloud.cost.spreadsheet.upload]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.ibm.cio.cloud.cost.spreadsheet.security] to DEBUG
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.ibm.cio.cloud.cost.spreadsheet.security] to true
11:26:43,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.ibm.cio.cloud.cost.spreadsheet.security]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.security.oauth2] to DEBUG
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.security.oauth2] to true
11:26:43,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.springframework.security.oauth2]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [springfox.documentation] to INFO
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [springfox.documentation] to true
11:26:43,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[springfox.documentation]
11:26:43,388 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.flywaydb] to INFO
11:26:43,389 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.flywaydb]
11:26:43,389 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
11:26:43,389 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
11:26:43,389 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
11:26:43,389 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
11:26:43,389 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
11:26:43,389 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
11:26:43,389 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
11:26:43,392 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@4930539b - Registering current configuration as safe fallback point
2018-09-13 11:26:44 INFO o.s.b.t.a.w.s.WebMvcTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests], using SpringBootContextLoader
2018-09-13 11:26:44 INFO o.s.t.c.s.AbstractContextLoader - Could not detect default resource locations for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests]: no resource found for suffixes {-context.xml, Context.groovy}.
2018-09-13 11:26:44 INFO o.s.t.c.s.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests]: UTBlueCostRestControllerTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2018-09-13 11:26:45 INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.ibm.cio.cloud.cost.spreadsheet.BlueCostSpreadsheetUploadWebApplication for test class com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests
2018-09-13 11:26:45 INFO o.s.b.t.a.w.s.WebMvcTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener, org.springframework.security.test.context.support.ReactorContextTestExecutionListener]
2018-09-13 11:26:45 INFO o.s.b.t.a.w.s.WebMvcTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@18c820d2, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3d3930fe, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@5e51ec2e, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@15f2a43f, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4c65d8e3, org.springframework.test.context.transaction.TransactionalTestExecutionListener@382faf51, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@69ce14e6, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener@699d96bc, org.springframework.security.test.context.support.ReactorContextTestExecutionListener@b5de9ac, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4ecd8ab1, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@57bdceaa, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@52909a97, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@36e409e0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@145e958f]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-09-13 11:26:47 INFO c.i.c.c.c.s.c.UTBlueCostRestControllerTests - Starting UTBlueCostRestControllerTests on LAPTOP-9SJV4DGJ with PID 42192 (started by JamesDePaul in C:\BlueCostSpreadsheetUploadWeb\backend)
2018-09-13 11:26:47 INFO c.i.c.c.c.s.c.UTBlueCostRestControllerTests - No active profile set, falling back to default profiles: default
2018-09-13 11:26:48 INFO o.s.w.c.s.GenericWebApplicationContext - Refreshing org.springframework.web.context.support.GenericWebApplicationContext@1802f60c: startup date [Thu Sep 13 11:26:47 MDT 2018]; root of context hierarchy
2018-09-13 11:26:48 INFO o.s.w.c.s.GenericWebApplicationContext - Refreshing org.springframework.web.context.support.GenericWebApplicationContext@1802f60c: startup date [Thu Sep 13 11:26:47 MDT 2018]; root of context hierarchy
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/{uploader}],methods=[GET]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.findSSCDataByUploader(java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/{uploader}],methods=[GET]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.findSSCDataByUploader(java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ibm.cio.cloud.cost.spreadsheet.domain.BluecostSSCData>> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.getAllBluecostSSCData()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ibm.cio.cloud.cost.spreadsheet.domain.BluecostSSCData>> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.getAllBluecostSSCData()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/{uploader}],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ibm.cio.cloud.cost.spreadsheet.domain.CostSpreadsheet>> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.getCostSpreadsheetByUploader(java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/{uploader}],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ibm.cio.cloud.cost.spreadsheet.domain.CostSpreadsheet>> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.getCostSpreadsheetByUploader(java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/upload/{uploader}/{filename}],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.uploadSpreadsheet(org.springframework.web.multipart.MultipartFile,java.lang.String,java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/upload/{uploader}/{filename}],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.uploadSpreadsheet(org.springframework.web.multipart.MultipartFile,java.lang.String,java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.createBluecostSSCData(com.ibm.cio.cloud.cost.spreadsheet.domain.BluecostSSCData)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/sscdata/],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.createBluecostSSCData(com.ibm.cio.cloud.cost.spreadsheet.domain.BluecostSSCData)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/{uploader}/{filename}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.deleteUploadedSpreadsheet(java.lang.String,java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/bluecost/spreadsheet/{uploader}/{filename}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<?> com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.deleteUploadedSpreadsheet(java.lang.String,java.lang.String)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources/configuration/security]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.SecurityConfiguration> springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources/configuration/security]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.SecurityConfiguration> springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources]}" onto public org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources]}" onto public org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources/configuration/ui]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.UiConfiguration> springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/swagger-resources/configuration/ui]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.UiConfiguration> springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-13 11:26:57 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
>>>>>>>>>>>>>> Stateless = FALSE! >>>>>>>>>>>>>
2018-09-13 11:26:58 DEBUG c.i.c.c.c.s.s.OpenIdConnectFilter - Instantiating the OpenIdConnectFilter filter
2018-09-13 11:26:58 DEBUG c.i.c.c.c.s.s.OpenIdConnectFilter - Instantiating the OpenIdConnectFilter filter
2018-09-13 11:26:58 INFO o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: Ant [pattern='/resources/**'], []
2018-09-13 11:26:59 INFO o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5244b461, org.springframework.security.web.context.SecurityContextPersistenceFilter@4246aa06, org.springframework.security.web.header.HeaderWriterFilter@28f95943, org.springframework.security.web.authentication.logout.LogoutFilter@39e27166, org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter@144a7ad5, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@50bd37f, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@466b4a28, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@50fef73f, org.springframework.security.web.session.SessionManagementFilter@20fe60ea, org.springframework.security.web.access.ExceptionTranslationFilter@5bca3ba6, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3c9e7377]
2018-09-13 11:27:00 INFO o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@50d4b0eb, org.springframework.security.web.context.SecurityContextPersistenceFilter@5eb8dfd0, org.springframework.security.web.header.HeaderWriterFilter@28be98fc, org.springframework.security.web.csrf.CsrfFilter@4ed03796, org.springframework.security.web.authentication.logout.LogoutFilter@6525968a, org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter@5d408b09, com.ibm.cio.cloud.cost.spreadsheet.security.OpenIdConnectFilter@47dff7db, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@31d26296, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@653408dc, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@391115fe, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@66c937dd, org.springframework.security.web.session.SessionManagementFilter@679d66fa, org.springframework.security.web.access.ExceptionTranslationFilter@486e6b30, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5acf7f12]
2018-09-13 11:27:00 INFO s.d.s.w.PropertySourcedRequestMappingHandlerMapping - Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2018-09-13 11:27:00 INFO s.d.s.w.PropertySourcedRequestMappingHandlerMapping - Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2018-09-13 11:27:00 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:00 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:01 INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.web.context.support.GenericWebApplicationContext@1802f60c: startup date [Thu Sep 13 11:26:47 MDT 2018]; root of context hierarchy
2018-09-13 11:27:01 INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.web.context.support.GenericWebApplicationContext@1802f60c: startup date [Thu Sep 13 11:26:47 MDT 2018]; root of context hierarchy
2018-09-13 11:27:01 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:01 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:01 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:01 INFO o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-13 11:27:01 INFO o.s.b.a.w.s.WelcomePageHandlerMapping - Adding welcome page: class path resource [META-INF/resources/index.html]
2018-09-13 11:27:02 INFO o.s.b.t.m.w.SpringBootMockServletContext - Initializing Spring FrameworkServlet ''
2018-09-13 11:27:02 INFO o.s.t.w.s.TestDispatcherServlet - FrameworkServlet '': initialization started
2018-09-13 11:27:02 INFO o.s.t.w.s.TestDispatcherServlet - FrameworkServlet '': initialization completed in 143 ms
2018-09-13 11:27:02 INFO o.s.c.s.DefaultLifecycleProcessor - Starting beans in phase 2147483647
2018-09-13 11:27:02 INFO s.d.s.w.p.DocumentationPluginsBootstrapper - Context refreshed
2018-09-13 11:27:02 INFO s.d.s.w.p.DocumentationPluginsBootstrapper - Context refreshed
2018-09-13 11:27:02 INFO s.d.s.w.p.DocumentationPluginsBootstrapper - Found 1 custom documentation plugin(s)
2018-09-13 11:27:02 INFO s.d.s.w.p.DocumentationPluginsBootstrapper - Found 1 custom documentation plugin(s)
2018-09-13 11:27:03 INFO s.d.s.w.s.ApiListingReferenceScanner - Scanning for api listing references
2018-09-13 11:27:03 INFO s.d.s.w.s.ApiListingReferenceScanner - Scanning for api listing references
2018-09-13 11:27:03 INFO c.i.c.c.c.s.c.UTBlueCostRestControllerTests - Started UTBlueCostRestControllerTests in 17.502 seconds (JVM running for 23.699)
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in headers. Trying request parameters.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in headers. Trying request parameters.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in request parameters. Not an OAuth2 request.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in request parameters. Not an OAuth2 request.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.OAuth2AuthenticationProcessingFilter - No token in request, will continue chain.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.OAuth2AuthenticationProcessingFilter - No token in request, will continue chain.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.e.DefaultOAuth2ExceptionRenderer - Written [error="unauthorized", error_description="Full authentication is required to access this resource"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6b94238f]
2018-09-13 11:27:04 DEBUG o.s.s.o.p.e.DefaultOAuth2ExceptionRenderer - Written [error="unauthorized", error_description="Full authentication is required to access this resource"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6b94238f]
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in headers. Trying request parameters.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in headers. Trying request parameters.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in request parameters. Not an OAuth2 request.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.BearerTokenExtractor - Token not found in request parameters. Not an OAuth2 request.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.OAuth2AuthenticationProcessingFilter - No token in request, will continue chain.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.a.OAuth2AuthenticationProcessingFilter - No token in request, will continue chain.
2018-09-13 11:27:04 DEBUG o.s.s.o.p.e.DefaultOAuth2ExceptionRenderer - Written [error="unauthorized", error_description="Full authentication is required to access this resource"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6b94238f]
2018-09-13 11:27:04 DEBUG o.s.s.o.p.e.DefaultOAuth2ExceptionRenderer - Written [error="unauthorized", error_description="Full authentication is required to access this resource"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6b94238f]
Вот мои текущие настройки:
Приложение настроено так:
@SpringBootApplication
@ComponentScan({"com.ibm.cio.cloud.cost.spreadsheet","com.ibm.cio.cloud.cost.spreadsheet.rest.controller","com.ibm.cio.cloud.cost.spreadsheet.dao", "com.ibm.cio.cloud.cost.spreadsheet.service"})
public class BlueCostSpreadsheetUploadWebApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(BlueCostSpreadsheetUploadWebApplication.class, args);
}
}
Мой тестовый набор настроен так:
@RunWith(SpringRunner.class)
@WithAnonymousUser //Also tried @WithMockUser
@WebMvcTest(value = com.ibm.cio.cloud.cost.spreadsheet.rest.controller.BlueCostRestController.class, secure = false)
public class UTBlueCostRestControllerTests extends UTBlueCostRestControllerParent {
Я добавил этот класс конфигурации, чтобы попытаться переопределить статическое поведение OAuth2Filter
package com.ibm.cio.cloud.cost.spreadsheet;
...
@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Override
public void configure(ResourceServerSecurityConfigurer security) throws Exception {
System.out.println(">>>>>>>>>>>>>> Stateless = FALSE! >>>>>>>>>>>>>");
security.stateless(false);
}
}