Lines 45-51
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' );
Link Here
|
45 |
subtest 'token-based tests' => sub { |
45 |
subtest 'token-based tests' => sub { |
46 |
|
46 |
|
47 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
47 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
48 |
plan tests => 15; |
48 |
plan tests => 16; |
49 |
} else { |
49 |
} else { |
50 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
50 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
51 |
} |
51 |
} |
Lines 110-115
subtest 'token-based tests' => sub {
Link Here
|
110 |
ok( defined $embed, 'The embed hashref is generated and stashed' ); |
110 |
ok( defined $embed, 'The embed hashref is generated and stashed' ); |
111 |
is_deeply( $embed, { fund => {} }, 'The embed data structure is correct' ); |
111 |
is_deeply( $embed, { fund => {} }, 'The embed data structure is correct' ); |
112 |
|
112 |
|
|
|
113 |
subtest 'TrackLastPatronActivityTriggers tests for api_oauth2' => sub { |
114 |
|
115 |
plan tests => 6; |
116 |
|
117 |
$patron->lastseen(undef)->store; |
118 |
|
119 |
my $tx = $t->ua->build_tx( GET => '/api/v1/patrons' ); |
120 |
$tx->req->headers->authorization("Bearer $access_token"); |
121 |
$t->request_ok($tx); |
122 |
|
123 |
is( |
124 |
$patron->lastseen, undef, |
125 |
"'lastseen' is undefined" |
126 |
); |
127 |
|
128 |
#set login in TrackLastPatronActivity_Triggers |
129 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login' ); |
130 |
|
131 |
$patron->lastseen(undef)->store; |
132 |
$tx = $t->ua->build_tx( GET => '/api/v1/patrons' ); |
133 |
$tx->req->headers->authorization("Bearer $access_token"); |
134 |
$t->request_ok($tx); |
135 |
|
136 |
$patron->discard_changes(); |
137 |
is( |
138 |
$patron->lastseen, undef, |
139 |
"'lastseen' untouched if 'api_oauth2' is not enabled in TrackLastPatronActivityTriggers" |
140 |
); |
141 |
|
142 |
#set api_oauth2 in in TrackLastPatronActivity_Triggers |
143 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'api_oauth2' ); |
144 |
|
145 |
$patron->lastseen(undef)->store; |
146 |
$tx = $t->ua->build_tx( GET => '/api/v1/patrons' ); |
147 |
$tx->req->headers->authorization("Bearer $access_token"); |
148 |
$t->request_ok($tx); |
149 |
|
150 |
$patron->discard_changes(); |
151 |
ok( |
152 |
$patron->lastseen, |
153 |
"'lastseen' flag updated TrackLastPatronActivityTriggers includes 'api_oauth2'" |
154 |
); |
155 |
|
156 |
}; |
157 |
|
113 |
$schema->storage->txn_rollback; |
158 |
$schema->storage->txn_rollback; |
114 |
}; |
159 |
}; |
115 |
|
160 |
|