From 22623e7c2f495441663a359fc1ee5fb98ff9010b Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 30 Jul 2026 13:48:24 +0200 Subject: [PATCH] MT#65618 require contract/subscriber sections in prov templates Validate that dependent template sections only appear together with their parent contract or subscriber section. Change-Id: I3150ca1844b633ab80ffd501fcf587d08f9ebdf8 --- lib/NGCP/Panel/Utils/ProvisioningTemplates.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm b/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm index 6fad611eb8..5bc4f0a43d 100644 --- a/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm +++ b/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm @@ -151,12 +151,13 @@ sub validate_template { my ($data,$prefix) = @_; $prefix //= 'template: '; die($prefix . "not a hash\n") unless 'HASH' eq ref $data; - # todo: validate fields - #foreach my $section (qw/subscriber/) { - # die($prefix . "section '$section' required\n") unless exists $data->{$section}; - # die($prefix . "section '$section' is not a hash\n") unless 'HASH' eq ref $data->{$section}; - #} + if (grep { exists $data->{$_} } qw(contract_balance fraud_preferences contract_preferences)) { + die($prefix . "section 'contract' required\n") unless exists $data->{contract}; + } + if (grep { exists $data->{$_} } qw(subscriber_preferences registrations trusted_sources cf_mappings)) { + die($prefix . "section 'subscriber' required\n") unless exists $data->{subscriber}; + } }