TT#28472 Revert changed for t/lib/Test/Collection.pm committed in 012686ab0

Those changes brakes REST API test and we cannot fix them for a day while
Sipwise have to release 2 new releases tomorrow. We need stable test tonight.

Change-Id: Id0a666e7762bcd8c1109d4ed4f0760daa988fe17
changes/01/17901/3
Alexander Lutay 8 years ago
parent 9fad59d99f
commit 148b119824

@ -3,8 +3,6 @@ package Test::Collection;
#testcollection will keep object of the apiclient #testcollection will keep object of the apiclient
use strict; use strict;
use threads qw();
use threads::shared qw();
use Test::More; use Test::More;
use Moose; use Moose;
use JSON; use JSON;
@ -22,9 +20,13 @@ use File::Slurp qw/write_file/;
use Storable; use Storable;
use Carp qw(cluck longmess shortmess); use Carp qw(cluck longmess shortmess);
use IO::Uncompress::Unzip; use IO::Uncompress::Unzip;
use File::Temp qw();
my $tmpfilename : shared; has 'crt_path' => (
is => 'ro',
isa => 'Str',
lazy => 1,
default => sub {'/tmp/apicert.pem';},
);
has 'data_cache_file' => ( has 'data_cache_file' => (
is => 'ro', is => 'ro',
@ -265,8 +267,7 @@ sub init_ua {
} }
sub init_ssl_cert { sub init_ssl_cert {
my ($self, $ua) = @_; my ($self, $ua) = @_;
lock $tmpfilename; unless(-f $self->crt_path) {
unless ($tmpfilename) {
my $res = $ua->post( my $res = $ua->post(
$self->base_uri . '/api/admincerts/', $self->base_uri . '/api/admincerts/',
Content_Type => 'application/json', Content_Type => 'application/json',
@ -293,13 +294,13 @@ sub init_ssl_cert {
unless($data) { unless($data) {
die "failed to find PEM file in client certificate zip file\n"; die "failed to find PEM file in client certificate zip file\n";
} }
(my $tmpfh,$tmpfilename) = File::Temp::tempfile('apicert_XXXX', DIR => '/tmp', SUFFIX => '.pem', UNLINK => 0); open my $fh, ">:raw", $self->crt_path or die "failed to open " . $self->crt_path . ": $!\n";
print $tmpfh $data; print $fh $data;
close $tmpfh; close $fh;
} }
$ua->ssl_opts( $ua->ssl_opts(
SSL_cert_file => $tmpfilename, SSL_cert_file => $self->crt_path,
SSL_key_file => $tmpfilename, SSL_key_file => $self->crt_path,
); );
} }
sub runas { sub runas {

Loading…
Cancel
Save