diff --git a/bin/check-endpoints b/bin/check-endpoints new file mode 100755 index 000000000..389addda8 --- /dev/null +++ b/bin/check-endpoints @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use v5.14; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + +use Getopt::Long; +use Open311::Endpoint::Integration::UK; + +my ($verbose); +GetOptions ( + 'verbose|v' => \$verbose, +); + +my $uk = Open311::Endpoint::Integration::UK->new; + +$uk->check_endpoints($verbose); diff --git a/perllib/Integrations/Surrey/Boomi.pm b/perllib/Integrations/Surrey/Boomi.pm index a25307c55..80fa55c07 100644 --- a/perllib/Integrations/Surrey/Boomi.pm +++ b/perllib/Integrations/Surrey/Boomi.pm @@ -38,7 +38,9 @@ has ua => ( timeout => 3 * 60, # Boomi can take longer than the default 60s when handling large/multiple photos. ); $ua->ssl_opts(SSL_cipher_list => 'DEFAULT:!DH'); # Disable DH ciphers, server's key is too small apparently - my $hash = encode_base64($self->config->{username} . ':' . $self->config->{password}, ""); + my $un = $self->config->{username} || ''; + my $pw = $self->config->{password} || ''; + my $hash = encode_base64("$un:$pw", ""); $ua->default_header('Authorization' => "Basic $hash"); $ua->default_header('Content-Type' => "application/json"); return $ua; diff --git a/perllib/Open311/Endpoint/Integration/Boomi.pm b/perllib/Open311/Endpoint/Integration/Boomi.pm index b4562cdeb..50323bf4d 100644 --- a/perllib/Open311/Endpoint/Integration/Boomi.pm +++ b/perllib/Open311/Endpoint/Integration/Boomi.pm @@ -44,7 +44,7 @@ has integration_class => ( default => 'Integrations::Surrey::Boomi', ); - +sub get_integration { $_[0]->boomi } sub service { my ($self, $id, $args) = @_; diff --git a/perllib/Open311/Endpoint/Integration/UK.pm b/perllib/Open311/Endpoint/Integration/UK.pm index dccf1cf2c..d818646b1 100644 --- a/perllib/Open311/Endpoint/Integration/UK.pm +++ b/perllib/Open311/Endpoint/Integration/UK.pm @@ -12,6 +12,7 @@ use Module::Pluggable instantiate => 'new'; use JSON::MaybeXS; use Path::Tiny; +use URI; use Open311::Endpoint::Schema; @@ -141,4 +142,39 @@ sub confirm_upload { } } +sub check_endpoints { + my ($self, $verbose) = @_; + my @plugins = (); + foreach ($self->plugins) { + if ($_->isa('Open311::Endpoint::Integration::Multi')) { + push @plugins, $_ foreach $_->plugins; + } else { + push @plugins, $_; + } + } + my @urls = (); + foreach (@plugins) { + if ($_->can('get_integration')) { + my $config = $_->get_integration->config; + push @urls, $config->{api_url} # Abavus, ATAK, Alloy, Boomi + || $config->{endpoint_url} # Confirm, Ezytreev, Symology, Uniform, WDM + || $config->{endpoint} # Salesforce + || $config->{url} # Echo, Whitespace + || $config->{jadu_api_base_url} # Jadu + || $config->{collective_endpoint}; # Bartec + } elsif ($_->can('endpoint')) { + push @urls, $_->endpoint; + } + } + my %hosts; + foreach (grep { $_ } @urls) { + $hosts{URI->new($_)->host} = 1; + } + foreach (sort keys %hosts) { + my $check = `openssl s_client -connect $_:443 < /dev/null 2>/dev/null| openssl x509 -checkend 604800 -noout`; + next if $check =~ /will not expire/ && !$verbose; + print "$_: $check"; + } +} + __PACKAGE__->run_if_script; diff --git a/t/open311/endpoint/uk.t b/t/open311/endpoint/uk.t index 114789dba..60e083cd0 100644 --- a/t/open311/endpoint/uk.t +++ b/t/open311/endpoint/uk.t @@ -18,6 +18,7 @@ test_multi(0, 'Open311::Endpoint::Integration::UK', 'Open311::Endpoint::Integration::UK::Rutland' => 'rutland', 'Open311::Endpoint::Integration::UK::Shropshire' => 'shropshire_confirm', 'Open311::Endpoint::Integration::UK::Southwark' => 'southwark_confirm', + 'Open311::Endpoint::Integration::UK::Surrey' => 'surrey_boomi', 'Open311::Endpoint::Integration::UK::Sutton' => 'sutton_echo', 'Open311::Endpoint::Integration::UK::Hampshire' => 'hampshire_confirm', );