### ----------------------------------------------------
### -- Shodan
### -- Licenses: Artistic-2.0
### -- Authors: Sarah Fuller
### -- File: t/04-alerts.rakutest
### ----------------------------------------------------
use Test;
use Shodan;

plan :skip-all<Author tests not required for installation> unless (%*ENV{'SHODAN_TESTING'});
plan 12;

my $shodan = Shodan.new(api-key => %*ENV{'SHODAN_API_KEY'});
my $alert;

isa-ok($alert = $shodan.alert-create(name => 'test', filters => {ip => ['1.1.1.1', '8.8.8.8']}, expires => 60), Hash, '.alert-create');

isa-ok($shodan.alert-info(id => $alert{'id'}), Hash, '.alert-info');

$alert{'filters'}{'ip'}[0] = '8.8.4.4';
isa-ok($shodan.alert-update(id => $alert{'id'}, filters => $alert{'filters'}), Hash, '.alert-update');

isa-ok($shodan.alert-trigger-create(id => $alert{'id'}, trigger => 'new_service,vulnerable'), Hash, '.alert-trigger-create');

isa-ok($shodan.alert-trigger-service-ignore(id => $alert{'id'}, trigger => 'vulnerable', service => '1.1.1.1:80'), Hash, '.alert-trigger-service-ignore');

isa-ok($shodan.alert-trigger-service-notify(id => $alert{'id'}, trigger => 'vulnerable', service => '1.1.1.1:80'), Hash, '.alert-trigger-service-ignore');

isa-ok($shodan.alert-notifier-create(id => $alert{'id'}, notifier-id => 'default'), Hash, '.alert-notifier-create');

isa-ok($shodan.alert-notifier-delete(id => $alert{'id'}, notifier-id => 'default'), Hash, '.alert-notifier-delete');

isa-ok($shodan.alert-trigger-delete(id => $alert{'id'}, trigger => 'new_service,vulnerable'), Hash, '.alert-trigger-delete');

isa-ok($shodan.alert-delete(id => $alert{'id'}), Hash, '.alert-delete');

isa-ok($shodan.alerts(), Array, '.alerts');

isa-ok($shodan.alert-triggers(), Array, '.alert-triggers');

done-testing;


