Improve testing against CE JSON schemas with additional properties in EE

Current situation

When testing JSON against a schema with extra properties in EE, "additionalProperties": false is not set on the schema so that the test passes in EE.

Another test is then created in ee/spec that loads a new schema fixture in ee which references the CE schema in the JSON.

Not setting "additionalProperties": false risks unintended passing of tests when you add the property in the wrong object, JSON returns a different property name, etc..

Possible solution

Discussed in: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8651#note_122757325

We can merge schemas in ee/ to the ones in CE based on filename. An extra test would not be required here since it would already test against the updated schema. We can then keep "additionalProperties": false so that only the properties defined in the schema are allowed.

I tried an initial proof of concept of this idea but a lot of tests failed because some schemas already have files in ee/ with the same name (Mostly those used in the extra test described above). Maybe we can consider something like ee/spec/fixtures/extensions/ instead.

Using "required" to define required properties should also be considered so that tests actually fail when the property is missing. This is even more important when "additionalProperties": false to guard against property name typos or properties renamed to something else.

cc @godfat

Assignee Loading
Time tracking Loading