2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-05-19 10:00:25 +00:00
Files
xcat-core/xCAT-test/unit/ddns_omapi_policy.t
T
Vinícius Ferrão ab86139959 Support configurable ISC OMAPI TSIG policy
Add a shared OMAPI policy helper for ISC DHCP and DDNS so administrators can select the key name, signing algorithm, and omshell path from the site table while preserving the existing xcat_key hmac-md5 default.

Keep local ISC updates from hanging indefinitely when omshell does not exit, and use a static host-declaration fallback for local Ubuntu ISC releases where omshell is unstable for xCAT host updates.

Co-authored-by: gskouson <1507929+gskouson@users.noreply.github.com>
2026-05-07 03:57:10 -03:00

65 lines
1.5 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../xCAT-server/lib";
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
use lib "$FindBin::Bin/../../perl-xCAT";
use Test::More;
$ENV{XCATCFG} ||= 'SQLite:/tmp';
$ENV{XCATROOT} ||= "$FindBin::Bin/../../xCAT-server";
my $source_ddns_plugin =
"$FindBin::Bin/../../xCAT-server/lib/xcat/plugins/ddns.pm";
if ( -f $source_ddns_plugin ) {
require $source_ddns_plugin;
}
else {
require xCAT_plugin::ddns;
}
my $defaults = xCAT::DHCP::OmapiPolicy->settings( site_values => {} );
is(
xCAT_plugin::ddns::ddns_key_contents(
{
omapi_settings => $defaults,
privkey => 'legacy-secret',
}
),
"key \"xcat_key\" {\n\talgorithm hmac-md5;\n\tsecret \"legacy-secret\";\n};\n\n",
'default DDNS key remains xcat_key with hmac-md5'
);
my $sha512 = xCAT::DHCP::OmapiPolicy->settings(
site_values => {
dhcpomapialgorithm => 'hmac-sha512',
dhcpomapikeyname => 'provider.key',
}
);
is(
xCAT_plugin::ddns::ddns_tsig_algorithm(
{
omapi_settings => $sha512,
}
),
'hmac-sha512',
'explicit non-MD5 DDNS algorithm is honored'
);
is(
xCAT_plugin::ddns::ddns_key_contents(
{
omapi_settings => $sha512,
privkey => 'provider-secret',
}
),
"key \"provider.key\" {\n\talgorithm hmac-sha512;\n\tsecret \"provider-secret\";\n};\n\n",
'custom DDNS key name and algorithm are rendered'
);
done_testing();