使用REST模板的Spock E2E测试

问题描述 投票:0回答:2

我无法使用安全性配置我的Spring Boot服务器的“自检”。这意味着我使用this tutorial创建了自签名证书。当我打开https://localhost:8080来自浏览器没有问题,我有一个安全的加密连接。

但是当我想设置一个REST模板来调用https://localhost:8080时,出现此错误:

nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed:

完整堆栈跟踪:

Testing started at 23:45 ...
Gradle Daemon started in 1 s 262 ms
> Task :cleanTest
> Task :compileJava UP-TO-DATE
> Task :compileGroovy NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :compileTestJava NO-SOURCE
> Task :compileTestGroovy
> Task :processTestResources
> Task :testClasses
> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/home/pawel/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.5.7/99907efe4b69f800c42584386f5d668e4d952bd5/groovy-2.5.7.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
23:45:30.283 [Test worker] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [integrationTests.IntegrationE2ETests]
23:45:30.292 [Test worker] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [integrationTests.IntegrationE2ETests]
23:45:30.299 [Test worker] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [integrationTests.IntegrationE2ETests]
23:45:30.300 [Test worker] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [integrationTests.IntegrationE2ETests]
23:45:30.341 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
23:45:30.355 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
23:45:30.366 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [integrationTests.IntegrationE2ETests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
23:45:30.401 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [integrationTests.IntegrationE2ETests]: class path resource [integrationTests/IntegrationE2ETests-context.xml] does not exist
23:45:30.403 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [integrationTests.IntegrationE2ETests]: class path resource [integrationTests/IntegrationE2ETestsContext.groovy] does not exist
23:45:30.404 [Test worker] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [integrationTests.IntegrationE2ETests]: no resource found for suffixes {-context.xml, Context.groovy}.
23:45:30.686 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [integrationTests.IntegrationE2ETests]: using defaults.
23:45:30.686 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.spockframework.spring.SpringMockTestExecutionListener, 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.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, 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]
23:45:30.733 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@43027667, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@70c063f, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@400381eb, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2afc7d1f, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7a1d9769, org.springframework.test.context.transaction.TransactionalTestExecutionListener@1d474beb, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@41178d71, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@84a04c9, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@1efa6c76, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@39457451, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@44440a0d, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@1cf02200, org.spockframework.spring.SpringMockTestExecutionListener@51247434]
23:45:31.156 [Test worker] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@12f3d1af testClass = IntegrationE2ETests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@b18bea0 testClass = IntegrationE2ETests, locations = '{}', classes = '{class pl.mazur.pawel.Family.FamilyApplication}', contextInitializerClasses = '[]', activeProfiles = '{dev}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.spockframework.spring.mock.SpockContextCustomizer@0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4e15caec, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@2e43f120, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@5af379e7, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@54423ac8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]], class annotated with @DirtiesContext [false] with mode [null].
23:45:31.178 [Test worker] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@12f3d1af testClass = IntegrationE2ETests, testInstance = integrationTests.IntegrationE2ETests@321a3e93, testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@b18bea0 testClass = IntegrationE2ETests, locations = '{}', classes = '{class pl.mazur.pawel.Family.FamilyApplication}', contextInitializerClasses = '[]', activeProfiles = '{dev}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.spockframework.spring.mock.SpockContextCustomizer@0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4e15caec, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@2e43f120, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@5af379e7, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@54423ac8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]]].
23:45:31.227 [Test worker] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)

2020-01-05 23:45:32.451 INFO 9516 --- [ Test worker] integrationTests.IntegrationE2ETests : Starting IntegrationE2ETests on pawel-Inspiron-5558 with PID 9516 (/home/pawel/Dokumenty/Projekty/Family/build/classes/groovy/test started by pawel in /home/pawel/Dokumenty/Projekty/Family)
2020-01-05 23:45:32.452 INFO 9516 --- [ Test worker] integrationTests.IntegrationE2ETests : The following profiles are active: dev
2020-01-05 23:45:34.450 INFO 9516 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-01-05 23:45:34.610 INFO 9516 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 134ms. Found 4 repository interfaces.
2020-01-05 23:45:35.437 INFO 9516 --- [ Test worker] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e917cd83] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-05 23:45:35.501 INFO 9516 --- [ Test worker] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$68981ab5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-05 23:45:36.251 INFO 9516 --- [ Test worker] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 0 (https)
2020-01-05 23:45:36.323 INFO 9516 --- [ Test worker] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-01-05 23:45:36.326 INFO 9516 --- [ Test worker] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2020-01-05 23:45:36.522 INFO 9516 --- [ Test worker] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-01-05 23:45:36.522 INFO 9516 --- [ Test worker] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4026 ms
2020-01-05 23:45:37.017 INFO 9516 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-01-05 23:45:37.317 INFO 9516 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-01-05 23:45:37.456 INFO 9516 --- [ Test worker] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2020-01-05 23:45:37.589 INFO 9516 --- [ Test worker] org.hibernate.Version : HHH000412: Hibernate Core {5.3.10.Final}
2020-01-05 23:45:37.594 INFO 9516 --- [ Test worker] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-01-05 23:45:37.988 INFO 9516 --- [ Test worker] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2020-01-05 23:45:38.210 INFO 9516 --- [ Test worker] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table child if exists
Hibernate: drop table family if exists
Hibernate: drop table father if exists
Hibernate: drop table mother if exists
Hibernate: drop sequence if exists hibernate_sequence
Hibernate: create sequence hibernate_sequence start with 1 increment by 1
Hibernate: create table child (id bigint not null, birth_date date not null, first_name varchar(255) not null, pesel varchar(255) not null, sex varchar(255) not null, sur_name varchar(255) not null, family_id bigint, primary key (id))
Hibernate: create table family (id bigint not null, father_id bigint, mother_id bigint, primary key (id))
Hibernate: create table father (id bigint not null, birth_date date not null, first_name varchar(255) not null, pesel varchar(255) not null, sur_name varchar(255) not null, family_id bigint, primary key (id))
Hibernate: create table mother (id bigint not null, birth_date date not null, first_name varchar(255) not null, pesel varchar(255) not null, sur_name varchar(255) not null, family_id bigint, primary key (id))
Hibernate: alter table child add constraint UK_q9v1ogh011liq0u0hdp4t3q63 unique (pesel)
Hibernate: alter table father add constraint UK_iqs08tbv5crk4816q89odbm4g unique (pesel)
Hibernate: alter table mother add constraint UK_88axw5moqy5wi4636k36l31m3 unique (pesel)
Hibernate: alter table child add constraint FKhj2xmiglh5fr64tvotyhjb61p foreign key (family_id) references family
Hibernate: alter table family add constraint FKp8unxl9i7iewr8wronod7arjc foreign key (father_id) references father
Hibernate: alter table family add constraint FKbxs2svee13oxyxx1bx8gdhy7g foreign key (mother_id) references mother
Hibernate: alter table father add constraint FK9wsh8dwpsy38hpdxkly22pu96 foreign key (family_id) references family
Hibernate: alter table mother add constraint FK4ebc98bboc1csv95bt6qklsso foreign key (family_id) references family
2020-01-05 23:45:39.630 INFO 9516 --- [ Test worker] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@64c0b2e1'
2020-01-05 23:45:39.634 INFO 9516 --- [ Test worker] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-01-05 23:45:40.404 INFO 9516 --- [ Test worker] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2020-01-05 23:45:41.376 WARN 9516 --- [ Test worker] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-01-05 23:45:42.055 INFO 9516 --- [ Test worker] pertySourcedRequestMappingHandlerMapping : 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)]
2020-01-05 23:45:42.388 INFO 9516 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-01-05 23:45:42.897 WARN 9516 --- [ Test worker] .b.a.g.t.GroovyTemplateAutoConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Groovy configuration, or set spring.groovy.template.check-template-location=false)
2020-01-05 23:45:43.557 INFO 9516 --- [ Test worker] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2020-01-05 23:45:43.583 INFO 9516 --- [ Test worker] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2020-01-05 23:45:43.622 INFO 9516 --- [ Test worker] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2020-01-05 23:45:45.269 INFO 9516 --- [ Test worker] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 41435 (https) with context path ''
2020-01-05 23:45:45.275 INFO 9516 --- [ Test worker] integrationTests.IntegrationE2ETests : Started IntegrationE2ETests in 14.043 seconds (JVM running for 16.095)

I/O error on GET request for "https://localhost:41435/family/create": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://localhost:41435/family/create": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670)
at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:338)
at integrationTests.IntegrationE2ETests.adding flow (IntegrationE2ETests.groovy:39)
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:320)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:258)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1324)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1199)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1146)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:443)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:421)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:177)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:735)
... 3 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:290)
at java.base/sun.security.validator.Validator.validate(Validator.java:264)
at java.base/sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:313)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:222)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:129)
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1308)
... 20 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 26 more

2020-01-05 23:45:45.916 INFO 9516 --- [ Thread-6] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-01-05 23:45:45.924 INFO 9516 --- [ Thread-6] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-01-05 23:45:45.925 INFO 9516 --- [ Thread-6] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
Hibernate: drop table child if exists
integrationTests.IntegrationE2ETests > adding flow FAILED
org.springframework.web.client.ResourceAccessException at IntegrationE2ETests.groovy:39
Caused by: javax.net.ssl.SSLHandshakeException at IntegrationE2ETests.groovy:39
Caused by: sun.security.validator.ValidatorException at IntegrationE2ETests.groovy:39
Caused by: sun.security.provider.certpath.SunCertPathBuilderException at IntegrationE2ETests.groovy:39
Hibernate: drop table family if exists
Hibernate: drop table father if exists
Hibernate: drop table mother if exists
Hibernate: drop sequence if exists hibernate_sequence
2020-01-05 23:45:45.988 INFO 9516 --- [ Thread-6] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-01-05 23:45:46.006 INFO 9516 --- [ Thread-6] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
1 test completed, 1 failed
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/pawel/Dokumenty/Projekty/Family/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 33s
6 actionable tasks: 4 executed, 2 up-to-date

[我在整个互联网上搜索了有关如何从磁盘加载x.509证书然后用于“自调用”的文章,但我希望它能像浏览器一样工作。

测试类和项目:https://github.com/mpawel1993/Family/blob/master/src/test/groovy/integrationTests/IntegrationE2ETests.groovy

java spring-boot security spock
2个回答
0
投票

此测试在JVM中运行。一开始我使用MockMvc,但我读到MockMvc在HTTP上不起作用,这就是为什么我想使用RestTemplete的原因。 RestTemplete(Autowired)将对我的服务器进行REST调用,并且最接近实际用户对应用程序的调用。从根本上讲,我想通过SSL / HTTPS连接将浏览器“更改”为RestTemplete,但由于SSLHandshakeException而无法配置它]


0
投票

通常,您只是禁用SSL进行测试,因为它不必要地增加了复杂性,如您所见。我建议添加一个test配置文件并通过@ActiveProfiles(['dev', 'test'])激活它。

© www.soinside.com 2019 - 2024. All rights reserved.