-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbasic.t
61 lines (44 loc) · 1.23 KB
/
basic.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use FindBin;
use lib $FindBin::Bin.'/../thirdparty/lib/perl5';
use lib $FindBin::Bin.'/../lib';
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
$ENV{CALLBACKERY_CONF} = $FindBin::Bin.'/callbackery.cfg';
my $t = Test::Mojo->new('CallBackery');
$t->app->log->on(message => sub {
my ($log, $level, @lines) = @_;
if ($ENV{CALLBACKERY_RPC_LOG}){
if ($lines[0] =~ /CALL|RETURN/){
like($lines[0],qr{UNKNOWN});
}
}
});
for (1..2){
$t->post_ok('/QX-JSON-RPC' => json => { id => 1, service => 'default', method => 'ping'} )
->status_is(200)
->content_type_is('application/json; charset=utf-8')
->json_is({id => 1,result => "pong"});
$t->get_ok('/doc')
->content_like('/CallBackery::Index/')
->status_is(200);
$ENV{CALLBACKERY_RPC_LOG}=1;
}
$ENV{CALLBACKERY_RPC_LOG}=0;
my $c = p1->new(app => $t->app);
my $data = {
k => { lalala => '123' }
};
$c->dataCleaner($data);
is ($data->{k}{lalala},'xxx','pass clean check');
my $login = ['tobi','secret'];
$c->dataCleaner($login,'login');
is ($login->[1],'xxx','pass special login check');
done_testing();
1;
package p1;
use Mojo::Base qw(CallBackery::Controller::RpcService);
sub passMatch {
qr{lalala};
};
1;