mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.62k stars 1.08k forks source link

mockerserver netty and client-java upgrade from 5.11.2 to 5.13.0 and higher fails to load json expectations #1893

Open vbhosle opened 3 months ago

vbhosle commented 3 months ago

Describe the issue Description of the issue upgraded mockserver-client-java and mockserver-netty from 5.11.2 to 5.13.0. Then Json initialization fails with 403

Logs o.m.l.MockServerEventLog : loading JSON initialization file: c.n.s.JsonSchemaFactory : Failed to load json schema!

java.io.IOException: Server returned HTTP response code: 403 for URL: http://json-schema.org/draft-07/schema at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1902) ~[?:1.8.0_402] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1500) ~[?:1.8.0_402] at com.networknt.schema.uri.URLFetcher.openConnectionCheckRedirects(URLFetcher.java:57) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.uri.URLFetcher.fetch(URLFetcher.java:43) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.uri.URISchemeFetcher.fetch(URISchemeFetcher.java:50) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:325) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.(RefValidator.java:41) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.PropertiesValidator.(PropertiesValidator.java:36) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.OneOfValidator.(OneOfValidator.java:118) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:94) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.(RefValidator.java:41) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.PropertiesValidator.(PropertiesValidator.java:36) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:94) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.(RefValidator.java:41) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.AnyOfValidator.(AnyOfValidator.java:35) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:94) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.RefValidator.(RefValidator.java:41) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.PropertiesValidator.(PropertiesValidator.java:36) ~[json-schema-validator-1.0.42.jar:?] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_402] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_402] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_402] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_402] at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:130) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:342) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:53) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.read(JsonSchema.java:198) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchema.initialize(JsonSchema.java:76) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:254) ~[json-schema-validator-1.0.42.jar:?] at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:370) ~[json-schema-validator-1.0.42.jar:?] at org.mockserver.validator.jsonschema.JsonSchemaValidator.(JsonSchemaValidator.java:94) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.validator.jsonschema.JsonSchemaExpectationValidator.(JsonSchemaExpectationValidator.java:12) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.validator.jsonschema.JsonSchemaExpectationValidator.jsonSchemaExpectationValidator(JsonSchemaExpectationValidator.java:44) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.serialization.ExpectationSerializer.getValidator(ExpectationSerializer.java:59) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.serialization.ExpectationSerializer.deserialize(ExpectationSerializer.java:119) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.serialization.ExpectationSerializer.deserializeArray(ExpectationSerializer.java:183) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.server.initialize.ExpectationInitializerLoader.lambda$retrieveExpectationsFromJson$0(ExpectationInitializerLoader.java:131) ~[mockserver-core-5.13.0.jar:5.13.0] at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269) ~[?:1.8.0_402] at java.util.Collections$2.tryAdvance(Collections.java:4719) ~[?:1.8.0_402] at java.util.Collections$2.forEachRemaining(Collections.java:4727) ~[?:1.8.0_402] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_402] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_402] at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_402] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_402] at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_402] at org.mockserver.server.initialize.ExpectationInitializerLoader.retrieveExpectationsFromJson(ExpectationInitializerLoader.java:159) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.server.initialize.ExpectationInitializerLoader.addExpectationsFromInitializer(ExpectationInitializerLoader.java:56) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.server.initialize.ExpectationInitializerLoader.(ExpectationInitializerLoader.java:43) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.mock.HttpState.(HttpState.java:128) ~[mockserver-core-5.13.0.jar:5.13.0] at org.mockserver.lifecycle.LifeCycle.(LifeCycle.java:55) ~[mockserver-netty-5.13.0.jar:5.13.0] at org.mockserver.netty.MockServer.(MockServer.java:77) ~[mockserver-netty-5.13.0.jar:5.13.0] at org.mockserver.netty.MockServer.(MockServer.java:57) ~[mockserver-netty-5.13.0.jar:5.13.0] at org.mockserver.integration.ClientAndServer.(ClientAndServer.java:58) ~[mockserver-netty-5.13.0.jar:5.13.0] at org.mockserver.integration.ClientAndServer.startClientAndServer(ClientAndServer.java:38) ~[mockserver-netty-5.13.0.jar:5.13.0] at org.mockserver.integration.ClientAndServer.startClientAndServer(ClientAndServer.java:34) ~[mockserver-netty-5.13.0.jar:5.13.0]

What you are trying to do Very basic test that loads expectations from json. It was working with 5.11.2 ConfigurationProperties.logLevel("TRACE"); ConfigurationProperties.initializationJsonPath("src/test/resources/mockserver/test-name-initializer.json"); mockServer = startClientAndServer(MOCK_SERVER_PORT); //fails here with 403

MockServer version The version you are using

To Reproduce Steps to reproduce the issue:

  1. How you are running MockServer (i.e maven plugin, docker, etc)
  2. Code you used to create expectations
  3. What error you saw

Expected behaviour What you expected to happen

MockServer Log Log output, as INFO level (or lower)