pact-foundation / pact-stub-server

Standalone pact stub server
MIT License
75 stars 19 forks source link

Stub server should support generator MockServerURL #55

Open tienvx opened 1 year ago

tienvx commented 1 year ago

Generator MockServerURL is used like this:

{
      'pact:matcher:type': 'regex',
      'pact:generator:type': 'MockServerURL',
      regex: '.*(\\/example/path)$',
      value: 'http://localhost:8080/example/path',
      example: 'http://localhost:8080/example/path',
    }

Mock Server support this generator (obviously from its name), so Consumer's contract test passed. But Stub Server doesn't support this generator, so Consumer's integration test failed.

I think:

Here are some additional information:

Pact file from the above demo project ### In case you don't want to run the demo project to see the contract file ```json { "consumer": { "name": "MyConsumer" }, "interactions": [ { "description": "a request for all urls", "key": "285dde1d2816ddad", "pending": false, "providerStates": [ { "name": "I have a list of urls" } ], "request": { "headers": { "Accept": [ "application/json" ] }, "method": "GET", "path": "/urls" }, "response": { "body": { "content": { "urls": [ { "url": "http://localhost:8080/example/path" } ] }, "contentType": "application/json", "encoded": false }, "generators": { "body": { "$.urls[*].url": { "example": "http://localhost:8080/example/path", "regex": ".*(\\/example/path)$", "type": "MockServerURL" } } }, "headers": { "Content-Type": [ "application/json" ] }, "matchingRules": { "body": { "$.urls": { "combine": "AND", "matchers": [ { "match": "type", "min": 1 } ] }, "$.urls[*].url": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/example/path)$" } ] } }, "header": {} }, "status": 200 }, "type": "Synchronous/HTTP" }, { "description": "a request the url http://provider.com/example/path", "key": "7824381c6cca0583", "pending": false, "providerStates": [ { "name": "I have a url http://provider.com/example/path" } ], "request": { "headers": { "Accept": [ "application/json" ] }, "method": "GET", "path": "/example/path" }, "response": { "body": { "content": { "key": "value" }, "contentType": "application/json", "encoded": false }, "headers": { "Content-Type": [ "application/json" ] }, "matchingRules": { "body": { "$.key": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "header": {} }, "status": 200 }, "type": "Synchronous/HTTP" } ], "metadata": { "pact-js": { "version": "11.0.2" }, "pactRust": { "ffi": "0.4.0", "models": "1.0.4" }, "pactSpecification": { "version": "4.0" } }, "provider": { "name": "MyProvider" } } ```
rholshausen commented 1 year ago

This may be due to https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v1.1.3

tienvx commented 1 year ago

I follow these steps:

But it doesn't fix the issue. The connection refused error is still there.