Commit 2f9c4743 authored by Xavier Guimard's avatar Xavier Guimard

Change sub names to private ones

parent 5dedd384
package Lemonldap::NG::Manager::Cli::Lib;
use JSON::MaybeXS;
use 5.10.0;
use Mouse;
use Lemonldap::NG::Manager;
......@@ -20,7 +19,7 @@ has app => (
}
);
sub get {
sub _get {
my ( $self, $path, $query ) = splice @_;
$query //= '';
return $self->app->(
......@@ -45,7 +44,7 @@ sub get {
);
}
sub post {
sub _post {
my ( $self, $path, $query, $body, $type, $len ) = splice @_;
die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') );
......@@ -75,7 +74,7 @@ sub post {
);
}
sub put {
sub _put {
my ( $self, $path, $query, $body, $type, $len ) = splice @_;
die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') );
......@@ -105,7 +104,7 @@ sub put {
);
}
sub del {
sub _del {
my ( $self, $path, $query ) = splice @_;
return $self->app->(
{
......@@ -131,7 +130,7 @@ sub del {
sub jsonResponse {
my ( $self, $path, $query ) = splice @_;
my $res = $self->get( $path, $query )
my $res = $self->_get( $path, $query )
or die "Manager lib has refused my get, aborting";
die "Manager lib does not return a 200 code, aborting"
unless ( $res->[0] == 200 );
......@@ -141,7 +140,7 @@ sub jsonResponse {
sub jsonPostResponse {
my ( $self, $path, $query, $body, $type, $len ) = splice @_;
my $res = $self->post( $path, $query, $body, $type, $len )
my $res = $self->_post( $path, $query, $body, $type, $len )
or die "Manager lib has refused my post, aborting";
die "Manager lib does not return a 200 code, aborting"
unless ( $res->[0] == 200 );
......@@ -151,7 +150,7 @@ sub jsonPostResponse {
sub jsonPutResponse {
my ( $self, $path, $query, $body, $type, $len ) = splice @_;
my $res = $self->put( $path, $query, $body, $type, $len )
my $res = $self->_put( $path, $query, $body, $type, $len )
or die "Manager lib has refused my put, aborting";
die "Manager lib does not return a 200 code, aborting"
unless ( $res->[0] == 200 );
......
......@@ -7,7 +7,7 @@ require 't/test-lib.pm';
my $res;
ok( $res = &client->get('/'), 'Succeed to get /' );
ok( $res = &client->_get('/'), 'Succeed to get /' );
my %hdrs = @{ $res->[1] };
ok( $res->[0] == 200, 'Return a 200 code' )
or print STDERR "Received" . Dumper($res);
......
......@@ -38,7 +38,7 @@ foreach my $query (@good) {
}
foreach my $query (@bad) {
my $res = &client->get( $query, '' );
my $res = &client->_get( $query, '' );
ok( $res->[0] == 400, "Request reject for $query" )
or print STDERR "# Receive a $res->[0] code";
my $href;
......
......@@ -8,7 +8,7 @@ require 't/test-lib.pm';
my $res;
ok(
$res = &client->post(
$res = &client->_post(
'/confs/newRSAKey', '', IO::String->new(''), 'application/json', 0,
),
"Request succeed"
......@@ -19,7 +19,7 @@ ok( $key = decode_json( $res->[2]->[0] ), 'Response is JSON' );
count(3);
ok(
$res = &client->post(
$res = &client->_post(
'/confs/newRSAKey', '', IO::String->new('{"password":"hello"}'),
'application/json', 20,
),
......
......@@ -26,7 +26,7 @@ while ( my $body = &body() ) {
my ( $res, $resBody );
ok(
$res =
&client->post( '/confs/', 'cfgNum=1', $body, 'application/json' ),
&client->_post( '/confs/', 'cfgNum=1', $body, 'application/json' ),
"$desc: positive result"
);
ok( $res->[0] == 200, "$desc: result code is 200" );
......
......@@ -17,7 +17,7 @@ sub body {
eval { unlink $confFiles->[1]; };
my ( $res, $resBody );
ok( $res = &client->post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
ok( $res = &client->_post( '/confs/', 'cfgNum=1', &body, 'application/json' ),
"Request succeed" );
ok( $res->[0] == 200, "Result code is 200" );
ok( $resBody = decode_json( $res->[2]->[0] ),
......
......@@ -143,7 +143,7 @@ count(5);
# Delete sessions
foreach (@ids) {
my $res;
ok( $res = &client->del("/sessions/global/$_"), "Delete $_" );
ok( $res = &client->_del("/sessions/global/$_"), "Delete $_" );
ok( $res->[0] == 200, 'Result code is 200' );
ok( decode_json( $res->[2]->[0] )->{result} == 1,
'Body is JSON and result==1' );
......
......@@ -42,7 +42,7 @@ count(3);
displayTests('done');
# Delete notification
$res = &client->del('notifications/done/20150503_dwho_VGVzdA==.done');
$res = &client->_del('notifications/done/20150503_dwho_VGVzdA==.done');
$res = &client->jsonResponse( 'notifications/done', 'groupBy=substr(uid,1)' );
ok( $res->{result} == 1, 'Result = 1' );
ok( $res->{count} == 0, 'Count = 0' );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment