diff --git a/.editorconfig b/.editorconfig index 8f0de65..be9f8c9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.{yml,yaml}] +[*.{yml,yaml,json}] indent_size = 2 [docker-compose.yml] diff --git a/resources/validation/facts/2022-12.json b/resources/validation/facts/2022-12.json index 5ffeba5..8798733 100644 --- a/resources/validation/facts/2022-12.json +++ b/resources/validation/facts/2022-12.json @@ -71,15 +71,9 @@ "description": "Common information to be fetched per-host.", "type": "object", "required": [ - "version", "distro" ], "properties": { - "version": { - "description": "Version of the software.", - "type": "string", - "pattern": "^\\d+\\.\\d+\\.?\\d*$" - }, "distro": { "description": "Distribution that the host runs on.", "type": "object", @@ -128,7 +122,23 @@ "patternProperties": { ".*": { "type": "object", - "$ref": "#/$defs/host-info" + "allOf": [ + { + "$ref": "#/$defs/host-info" + }, + { + "required": [ + "version" + ], + "properties": { + "version": { + "description": "Version of the software.", + "type": "string", + "pattern": "^\\d+\\.\\d+\\.?\\d*$" + } + } + } + ] } }, "minProperties": 1 diff --git a/tests/Feature/InstallationTest.php b/tests/Feature/InstallationTest.php index cd1ace0..c94c1a3 100644 --- a/tests/Feature/InstallationTest.php +++ b/tests/Feature/InstallationTest.php @@ -145,34 +145,6 @@ '9.a.6', ]); -it('can\'t accept invalid nethsecurity version', function (string $schema, string $version) { - $request = [ - '$schema' => $schema, - 'uuid' => fake()->uuid(), - 'installation' => 'nethsecurity', - 'facts' => [ - 'distro' => [ - 'name' => 'rocky', - 'version' => '9.1', - ], - 'version' => $version, - ], - ]; - $this->postJson('/api/installation', $request) - ->assertUnprocessable() - ->assertInvalid([ - '/facts/version' => 'pattern', - ]); -})->with([ - SCHEMA_2022_12, -])->with([ - '8.0.a', - 'X.Y', - 'X', - '8', - '9.a.6', -]); - it('saves correctly new nethserver installation', function (string $schema) { $installation = Installation::factory()->nethserver()->make(); $request = array_merge($installation->data, [