From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 422861FF187 for ; Fri, 19 Dec 2025 20:47:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4FCE914EE2; Fri, 19 Dec 2025 20:46:18 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Date: Fri, 19 Dec 2025 20:44:51 +0100 Message-ID: <20251219194511.840583-17-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219194511.840583-1-m.carrara@proxmox.com> References: <20251219194511.840583-1-m.carrara@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1766173531831 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.084 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH pve-common v1 16/23] tests: sectionconfig: add case for differing req. default prop uses X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Add a PVE::SectionConfig isolated mode test case where a required default property (i.e. it's defined in `private()->{propertyList}`) is marked as required by one plugin, but as optional by the other. In the create schema, such a property uses a `oneOf` schema to differ between the cases of both plugins. In other words, if a plugin marked it as optional, it is marked as optional in the create schema too, and vice versa. In the update schema, such a property is marked as optional for both plugins. Signed-off-by: Max R. Carrara --- test/SectionConfig/schema_isolated_test.pl | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/test/SectionConfig/schema_isolated_test.pl b/test/SectionConfig/schema_isolated_test.pl index 202e039..95980de 100755 --- a/test/SectionConfig/schema_isolated_test.pl +++ b/test/SectionConfig/schema_isolated_test.pl @@ -591,6 +591,174 @@ package OptionalCommonRequiredAndOptional { } } +package RequiredCommonRequiredAndOptional { + use base qw(TestPackage); + + sub desc($class) { + return "when a required default property is marked as both optional and required" + . " by different plugins, 'oneOf' is used in createSchema"; + } + + package RequiredCommonRequiredAndOptional::PluginBase { + use base qw(PVE::SectionConfig); + + my $DEFAULT_DATA = { + propertyList => { + common => { + type => 'string', + optional => 0, + }, + }, + }; + + sub private($class) { + return $DEFAULT_DATA; + } + }; + + package RequiredCommonRequiredAndOptional::PluginOne { + use base qw(RequiredCommonRequiredAndOptional::PluginBase); + + sub type($class) { + return 'one'; + } + + sub properties($class) { + return { + 'prop-one' => { + type => 'string', + optional => 1, + }, + }; + } + + sub options($class) { + return { + common => { + optional => 0, + }, + 'prop-one' => { + optional => 1, + }, + }; + } + }; + + package RequiredCommonRequiredAndOptional::PluginTwo { + use base qw(RequiredCommonRequiredAndOptional::PluginBase); + + sub type($class) { + return 'two'; + } + + sub properties($class) { + return { + 'prop-two' => { + type => 'string', + optional => 1, + }, + }; + } + + sub options($class) { + return { + common => { + optional => 1, + }, + 'prop-two' => { + optional => 1, + }, + }; + } + }; + + sub expected_isolated_createSchema($class) { + return { + type => 'object', + additionalProperties => 0, + properties => { + type => { + type => 'string', + enum => [ + "one", "two", + ], + }, + 'prop-one' => { + 'instance-types' => [ + "one", + ], + 'type-property' => 'type', + type => 'string', + optional => 1, + }, + 'prop-two' => { + 'instance-types' => [ + "two", + ], + 'type-property' => 'type', + type => 'string', + optional => 1, + }, + 'common' => { + oneOf => [ + { + 'instance-types' => [ + "one", + ], + optional => 0, + type => 'string', + }, + { + 'instance-types' => [ + "two", + ], + optional => 1, + type => 'string', + }, + ], + 'type-property' => 'type', + }, + }, + }; + } + + sub expected_isolated_updateSchema($class) { + return { + type => 'object', + additionalProperties => 0, + properties => { + type => { + type => 'string', + enum => [ + "one", "two", + ], + }, + 'prop-one' => { + 'instance-types' => [ + "one", + ], + 'type-property' => 'type', + type => 'string', + optional => 1, + }, + 'prop-two' => { + 'instance-types' => [ + "two", + ], + 'type-property' => 'type', + type => 'string', + optional => 1, + }, + common => { + type => 'string', + optional => 1, + }, + $SectionConfig::Helpers::UPDATE_SCHEMA_DEFAULT_PROPERTIES->%*, + }, + }; + } +} + sub test_compare_deeply($got, $expected, $test_name, $test_package) { $test_name = "$test_package - $test_name"; my $description = $test_package->desc(); -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel