2016-01-07 12:40:24 +01:00
|
|
|
# Test RSA key generation
|
2015-05-14 08:44:38 +02:00
|
|
|
|
|
|
|
use Test::More;
|
|
|
|
use strict;
|
2016-01-13 20:47:56 +01:00
|
|
|
use JSON;
|
2015-05-14 08:44:38 +02:00
|
|
|
use IO::String;
|
2015-05-14 08:45:03 +02:00
|
|
|
require 't/test-lib.pm';
|
2015-05-14 08:44:38 +02:00
|
|
|
|
2020-09-22 17:02:18 +02:00
|
|
|
sub checkResult {
|
2021-01-20 09:15:52 +01:00
|
|
|
my $res = shift;
|
|
|
|
my $expecthash = shift;
|
2020-09-22 17:02:18 +02:00
|
|
|
ok( $res->[0] == 200, "Result code is 200" );
|
|
|
|
my $key;
|
|
|
|
ok( $key = from_json( $res->[2]->[0] ), 'Response is JSON' );
|
|
|
|
like( $key->{private}, qr/BEGIN/, "is PEM formatted" );
|
|
|
|
like( $key->{public}, qr/BEGIN/, "is PEM formatted" );
|
2021-01-20 09:15:52 +01:00
|
|
|
ok( $key->{hash}, "hash is non empty" ) if $expecthash;
|
|
|
|
count(1) if $expecthash;
|
2020-09-22 17:02:18 +02:00
|
|
|
count(4);
|
|
|
|
}
|
|
|
|
|
2015-05-14 08:44:38 +02:00
|
|
|
my $res;
|
|
|
|
ok(
|
2016-01-01 20:55:35 +01:00
|
|
|
$res = &client->_post(
|
2016-01-01 20:55:29 +01:00
|
|
|
'/confs/newRSAKey', '', IO::String->new(''), 'application/json', 0,
|
|
|
|
),
|
2015-05-14 08:44:38 +02:00
|
|
|
"Request succeed"
|
|
|
|
);
|
2020-09-22 17:02:18 +02:00
|
|
|
count(1);
|
2021-01-20 09:15:52 +01:00
|
|
|
checkResult( $res, 1 );
|
2015-05-14 08:44:38 +02:00
|
|
|
|
|
|
|
ok(
|
2016-01-01 20:55:35 +01:00
|
|
|
$res = &client->_post(
|
2015-05-14 08:44:38 +02:00
|
|
|
'/confs/newRSAKey', '', IO::String->new('{"password":"hello"}'),
|
|
|
|
'application/json', 20,
|
|
|
|
),
|
|
|
|
"Request succeed"
|
|
|
|
);
|
2020-09-22 17:02:18 +02:00
|
|
|
count(1);
|
2021-01-20 09:15:52 +01:00
|
|
|
checkResult( $res, 1 );
|
2020-09-22 17:02:18 +02:00
|
|
|
|
|
|
|
ok(
|
|
|
|
$res = &client->_post(
|
|
|
|
'/confs/newCertificate', '',
|
|
|
|
IO::String->new(''), 'application/json',
|
|
|
|
0,
|
|
|
|
),
|
|
|
|
"Request succeed"
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
checkResult($res);
|
|
|
|
|
|
|
|
ok(
|
|
|
|
$res = &client->_post(
|
|
|
|
'/confs/newCertificate', '', IO::String->new('{"password":"hello"}'),
|
|
|
|
'application/json', 20,
|
|
|
|
),
|
|
|
|
"Request succeed"
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
checkResult($res);
|
2015-10-22 10:40:12 +02:00
|
|
|
|
2015-05-14 08:44:38 +02:00
|
|
|
done_testing( count() );
|