]> git.proxmox.com Git - proxmox-acme.git/blame - src/test/verify-dnsapi-plugins-in-schema.pl
add basic test so schema is in sync with available plugins
[proxmox-acme.git] / src / test / verify-dnsapi-plugins-in-schema.pl
CommitLineData
895b703e
TL
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use lib '../';
7
8use PVE::Tools qw(dir_glob_foreach);
9use PVE::ACME::DNSChallenge;
10
11my $dnsapi_path = '../acme.sh/dnsapi';
12
13die "cannot find dnsapi path '$dnsapi_path'!\n" if ! -d $dnsapi_path;
14
15my $acmesh_plugins = [];
16dir_glob_foreach($dnsapi_path, qr/dns_(\S+)\.sh/, sub {
17 my ($file, $provider) = @_;
18 push @$acmesh_plugins, $provider;
19});
20
21my $ok = 1;
22my $defined_plugins = PVE::ACME::DNSChallenge::get_supported_plugins();
23
24# first check for missing ones, delete from hash so we can easily see if a plug got removed/renamed
25my $printed_missing = 0;
26for my $provider (sort @$acmesh_plugins) {
27 my $schema = delete $defined_plugins->{$provider};
28 if (!defined($schema)) {
29 print STDERR "missing (also adapt makefile!):\n" if !$printed_missing;
30 print STDERR " '$provider' => {},\n";
31 $printed_missing = 1;
32 $ok = 0;
33 }
34}
35
36my $printed_extra = 0;
37for my $provider (sort keys %$defined_plugins) {
38 print STDERR "extra:\n" if !$printed_extra;
39 print STDERR " $provider\n";
40 $printed_extra = 1;
41 $ok = 0;
42}
43
44die "schema not in sync with available plugins!\n" if !$ok;
45
46print STDERR "OK: DNS challenge schema in sync with available plugins.\n";
47exit(0);