remove the company bit requirements... not actually used also now works

This commit is contained in:
Zane C. B-H 2020-12-02 01:35:11 -06:00
parent d108e2fe5e
commit 7fe95d5194
3 changed files with 10 additions and 12 deletions

View File

@ -17,7 +17,6 @@ sub help{
}
my $required_args = {
'Logicmonitor_company' => 1,
'Logicmonitor_accessKey' => 1,
'Logicmonitor_accessID' => 1,
};

View File

@ -4,7 +4,8 @@ use 5.006;
use strict;
use warnings;
use Time::HiRes qw( gettimeofday );
use Crypt::Mac::HMAC qw( hmac_b64 );
use Crypt::Mac::HMAC qw( hmac_hex );
use MIME::Base64;
=head1 NAME
@ -95,7 +96,6 @@ Milliseconds since epoc.
This requires a hash ref with the following three variables.
company
accessID
accessKey
@ -105,7 +105,6 @@ Example...
eval {
$lmsig_helper = LogicMonitor::REST::Signature->new(
{
company => $company,
accessID => $accessID,
accessKey => $accessKey,
}
@ -124,7 +123,7 @@ sub new {
# list of required keys
my $args_valid_keys = {
company => 1,
# company => 1,
accessID => 1,
accessKey => 1,
};
@ -137,7 +136,7 @@ sub new {
}
my $self = {
company => $args->{company},
# company => $args->{company},
accessID => $args->{accessID},
accessKey => $args->{accessKey},
};
@ -209,7 +208,8 @@ sub signature {
# create the signature and return it
my $sig;
eval {
$sig = hmac_b64( 'SHA256', $self->{accessKey}, $string );
$sig = encode_base64( hmac_hex( 'SHA256', $self->{accessKey}, $string ) );
$sig =~ s/\n//g;
if ( !defined($sig) ) {
die('hmac_b64 returned undef');
}

View File

@ -26,7 +26,6 @@ ok( $worked eq '0', 'init') or diag("Iinitated with missing values");
$worked=0;
eval{
$lmsig_helper=LogicMonitor::REST::Signature->new({
company=>$company,
accessKey=>$accessKey,
accessID=>$accessID,
});
@ -43,8 +42,8 @@ eval{
data=>'',
timestamp=>'1',
});
if ( $sig ne 'e0bb5OESDeQdMvtJy1Nr6Nju7Nd9axVXHUhMQjjA3f4=' ){
die 'Got "'.$sig.'" but was expecting "e0bb5OESDeQdMvtJy1Nr6Nju7Nd9axVXHUhMQjjA3f4="';
if ( $sig ne 'N2I0NmRiZTRlMTEyMGRlNDFkMzJmYjQ5Y2I1MzZiZThkOGVlZWNkNzdkNmIxNTU3MWQ0ODRjNDIzOGMwZGRmZQ==' ){
die 'Got "'.$sig.'" but was expecting "N2I0NmRiZTRlMTEyMGRlNDFkMzJmYjQ5Y2I1MzZiZThkOGVlZWNkNzdkNmIxNTU3MWQ0ODRjNDIzOGMwZGRmZQ=="';
}
$worked=1
};
@ -58,8 +57,8 @@ eval{
path=>'/foo',
timestamp=>'1',
});
if ( $sig ne 'e0bb5OESDeQdMvtJy1Nr6Nju7Nd9axVXHUhMQjjA3f4=' ){
die 'Got "'.$sig.'" but was expecting "e0bb5OESDeQdMvtJy1Nr6Nju7Nd9axVXHUhMQjjA3f4="';
if ( $sig ne 'N2I0NmRiZTRlMTEyMGRlNDFkMzJmYjQ5Y2I1MzZiZThkOGVlZWNkNzdkNmIxNTU3MWQ0ODRjNDIzOGMwZGRmZQ==' ){
die 'Got "'.$sig.'" but was expecting "N2I0NmRiZTRlMTEyMGRlNDFkMzJmYjQ5Y2I1MzZiZThkOGVlZWNkNzdkNmIxNTU3MWQ0ODRjNDIzOGMwZGRmZQ=="';
}
$worked=1
};