pact-foundation / pact-specification

Describes the pact format and verification specifications
MIT License
291 stars 28 forks source link

Response body is []. This is with "newJsonArrayMinLike(0, ...)" #108

Open sergtk opened 2 months ago

sergtk commented 2 months ago

When I specify newJsonArrayMinLike(0,...) in Java (zero min elements), then response body in pact-file is empty array "[]". How such body is interpreted? Provider test passed even with the body, which should not be matched.

How is body "[]" interpreted? It seems that body is considered as absent, because it seems considered as "the body contents are not important" according to the spec 3. But I want to be sure, specification does not describe this, or this is a bug is in pact-jvm-consumer-java8.

This is when working with pact-jvm-consumer-java8, v4.0.6

Could somebody please clarify this? Thanks.

rholshausen commented 2 months ago

Firstly, pact-jvm-consumer-java8 is very old and no longer supported. It has been replaced with au.com.dius.pact:consumer.

How is body "[]" interpreted?

It is an empty JSON array.

When I specify newJsonArrayMinLike(0,...)

This is stating that any number of items are acceptable in the array, including none. Thus the Provider test will pass with any number of items in the array.

sergtk commented 2 months ago

It is an empty JSON array

Is empty JSON array is considered just like "empty JSON"? "empty JSON" is stated in the pact spec, but it is not clear conserning "empty JSON array" if it is considered as "empty JSON" or not.

This is stating that any number of items are acceptable in the array, including none. Thus the Provider test will pass with any number of items in the array.

The problem is that elements of array which are not matched to the rules, just ignored. And provider tests passed, while provider tests should faild because of wrong data. Anyway, this is already more about specific implementation of pact, not about pact spec. Thanks.

rholshausen commented 2 months ago

An empty JSON array is not "empty JSON", it contains two characters [].