]> git.proxmox.com Git - proxmox-acme.git/commitdiff
add basic test so schema is in sync with available plugins
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 11 Dec 2020 17:50:22 +0000 (18:50 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 11 Dec 2020 17:54:53 +0000 (18:54 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/Makefile
src/test/Makefile [new file with mode: 0644]
src/test/verify-dnsapi-plugins-in-schema.pl [new file with mode: 0755]

index 9bf2e7041895a7f59ebaf033cf1edd86e0a21929..c308cc78f2d33da022ca22720a2513b6a73b0ec3 100644 (file)
@@ -119,6 +119,10 @@ install:
        install -d -m 0755 ${DESTDIR}${PERLDIR}/PVE/ACME
        for f in ${LIB_SOURCES}; do install -D -m 0644 PVE/$$f ${DESTDIR}${PERLDIR}/PVE/$$f; done
 
+.PHONY: test
+test:
+       $(MAKE) -C test test
+
 .PHONY: clean
 clean:
        rm -rf *~
diff --git a/src/test/Makefile b/src/test/Makefile
new file mode 100644 (file)
index 0000000..982f698
--- /dev/null
@@ -0,0 +1,6 @@
+
+.PHONY: test
+test: verify-dnsapi-plugins-in-schema.pl.t
+
+%.t: %
+       ./$<
diff --git a/src/test/verify-dnsapi-plugins-in-schema.pl b/src/test/verify-dnsapi-plugins-in-schema.pl
new file mode 100755 (executable)
index 0000000..3f1377e
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib '../';
+
+use PVE::Tools qw(dir_glob_foreach);
+use PVE::ACME::DNSChallenge;
+
+my $dnsapi_path = '../acme.sh/dnsapi';
+
+die "cannot find dnsapi path '$dnsapi_path'!\n" if ! -d $dnsapi_path;
+
+my $acmesh_plugins = [];
+dir_glob_foreach($dnsapi_path, qr/dns_(\S+)\.sh/, sub {
+    my ($file, $provider) = @_;
+    push @$acmesh_plugins, $provider;
+});
+
+my $ok = 1;
+my $defined_plugins = PVE::ACME::DNSChallenge::get_supported_plugins();
+
+# first check for missing ones, delete from hash so we can easily see if a plug got removed/renamed
+my $printed_missing = 0;
+for my $provider (sort @$acmesh_plugins) {
+    my $schema = delete $defined_plugins->{$provider};
+    if (!defined($schema)) {
+       print STDERR "missing (also adapt makefile!):\n" if !$printed_missing;
+       print STDERR "    '$provider' => {},\n";
+       $printed_missing = 1;
+       $ok = 0;
+    }
+}
+
+my $printed_extra = 0;
+for my $provider (sort keys %$defined_plugins) {
+    print STDERR "extra:\n" if !$printed_extra;
+    print STDERR "    $provider\n";
+    $printed_extra = 1;
+    $ok = 0;
+}
+
+die "schema not in sync with available plugins!\n" if !$ok;
+
+print STDERR "OK: DNS challenge schema in sync with available plugins.\n";
+exit(0);