Lines 50-69
subtest "monthly_report" => sub {
Link Here
|
50 |
|
50 |
|
51 |
$schema->storage->txn_begin; |
51 |
$schema->storage->txn_begin; |
52 |
|
52 |
|
53 |
# Run a harvest to populate the database with data |
|
|
54 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
55 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
56 |
|
57 |
$usage_data_provider->counter_files( |
58 |
[ |
59 |
{ |
60 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
61 |
file_content => $counter_file, |
62 |
filename => "Test_TR_J1", |
63 |
} |
64 |
] |
65 |
); |
66 |
|
67 |
my $librarian = $builder->build_object( |
53 |
my $librarian = $builder->build_object( |
68 |
{ |
54 |
{ |
69 |
class => 'Koha::Patrons', |
55 |
class => 'Koha::Patrons', |
Lines 73-78
subtest "monthly_report" => sub {
Link Here
|
73 |
my $password = 'thePassword123'; |
59 |
my $password = 'thePassword123'; |
74 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
60 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
75 |
my $userid = $librarian->userid; |
61 |
my $userid = $librarian->userid; |
|
|
62 |
t::lib::Mocks::mock_userenv( { number => $userid } ); |
76 |
|
63 |
|
77 |
my $patron = $builder->build_object( |
64 |
my $patron = $builder->build_object( |
78 |
{ |
65 |
{ |
Lines 84-89
subtest "monthly_report" => sub {
Link Here
|
84 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
71 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
85 |
my $unauth_userid = $patron->userid; |
72 |
my $unauth_userid = $patron->userid; |
86 |
|
73 |
|
|
|
74 |
# Run a harvest to populate the database with data |
75 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
76 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
77 |
|
78 |
$usage_data_provider->counter_files( |
79 |
[ |
80 |
{ |
81 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
82 |
file_content => $counter_file, |
83 |
filename => "Test_TR_J1", |
84 |
} |
85 |
] |
86 |
); |
87 |
|
87 |
# Unauthorized access |
88 |
# Unauthorized access |
88 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/monthly_report/title")->status_is(403); |
89 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/monthly_report/title")->status_is(403); |
89 |
|
90 |
|
Lines 148-167
subtest "yearly_report" => sub {
Link Here
|
148 |
|
149 |
|
149 |
$schema->storage->txn_begin; |
150 |
$schema->storage->txn_begin; |
150 |
|
151 |
|
151 |
# Run a harvest to populate the database with data |
|
|
152 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
153 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
154 |
|
155 |
$usage_data_provider->counter_files( |
156 |
[ |
157 |
{ |
158 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
159 |
file_content => $counter_file, |
160 |
filename => "Test_TR_J1", |
161 |
} |
162 |
] |
163 |
); |
164 |
|
165 |
my $librarian = $builder->build_object( |
152 |
my $librarian = $builder->build_object( |
166 |
{ |
153 |
{ |
167 |
class => 'Koha::Patrons', |
154 |
class => 'Koha::Patrons', |
Lines 171-176
subtest "yearly_report" => sub {
Link Here
|
171 |
my $password = 'thePassword123'; |
158 |
my $password = 'thePassword123'; |
172 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
159 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
173 |
my $userid = $librarian->userid; |
160 |
my $userid = $librarian->userid; |
|
|
161 |
t::lib::Mocks::mock_userenv( { number => $userid } ); |
174 |
|
162 |
|
175 |
my $patron = $builder->build_object( |
163 |
my $patron = $builder->build_object( |
176 |
{ |
164 |
{ |
Lines 182-187
subtest "yearly_report" => sub {
Link Here
|
182 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
170 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
183 |
my $unauth_userid = $patron->userid; |
171 |
my $unauth_userid = $patron->userid; |
184 |
|
172 |
|
|
|
173 |
# Run a harvest to populate the database with data |
174 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
175 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
176 |
|
177 |
$usage_data_provider->counter_files( |
178 |
[ |
179 |
{ |
180 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
181 |
file_content => $counter_file, |
182 |
filename => "Test_TR_J1", |
183 |
} |
184 |
] |
185 |
); |
186 |
|
185 |
# Unauthorized access |
187 |
# Unauthorized access |
186 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/yearly_report/title")->status_is(403); |
188 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/yearly_report/title")->status_is(403); |
187 |
|
189 |
|
Lines 237-256
subtest "metric_types_report" => sub {
Link Here
|
237 |
|
239 |
|
238 |
$schema->storage->txn_begin; |
240 |
$schema->storage->txn_begin; |
239 |
|
241 |
|
240 |
# Run a harvest to populate the database with data |
|
|
241 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
242 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
243 |
|
244 |
$usage_data_provider->counter_files( |
245 |
[ |
246 |
{ |
247 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
248 |
file_content => $counter_file, |
249 |
filename => "Test_TR_J1", |
250 |
} |
251 |
] |
252 |
); |
253 |
|
254 |
my $librarian = $builder->build_object( |
242 |
my $librarian = $builder->build_object( |
255 |
{ |
243 |
{ |
256 |
class => 'Koha::Patrons', |
244 |
class => 'Koha::Patrons', |
Lines 260-265
subtest "metric_types_report" => sub {
Link Here
|
260 |
my $password = 'thePassword123'; |
248 |
my $password = 'thePassword123'; |
261 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
249 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
262 |
my $userid = $librarian->userid; |
250 |
my $userid = $librarian->userid; |
|
|
251 |
t::lib::Mocks::mock_userenv( { number => $userid } ); |
263 |
|
252 |
|
264 |
my $patron = $builder->build_object( |
253 |
my $patron = $builder->build_object( |
265 |
{ |
254 |
{ |
Lines 271-276
subtest "metric_types_report" => sub {
Link Here
|
271 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
260 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
272 |
my $unauth_userid = $patron->userid; |
261 |
my $unauth_userid = $patron->userid; |
273 |
|
262 |
|
|
|
263 |
# Run a harvest to populate the database with data |
264 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
265 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
266 |
|
267 |
$usage_data_provider->counter_files( |
268 |
[ |
269 |
{ |
270 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
271 |
file_content => $counter_file, |
272 |
filename => "Test_TR_J1", |
273 |
} |
274 |
] |
275 |
); |
276 |
|
274 |
# Unauthorized access |
277 |
# Unauthorized access |
275 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/metric_types_report/title")->status_is(403); |
278 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/metric_types_report/title")->status_is(403); |
276 |
|
279 |
|
Lines 332-351
subtest "provider_rollup_report" => sub {
Link Here
|
332 |
|
335 |
|
333 |
$schema->storage->txn_begin; |
336 |
$schema->storage->txn_begin; |
334 |
|
337 |
|
335 |
# Run a harvest to populate the database with data |
|
|
336 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
337 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
338 |
|
339 |
$usage_data_provider->counter_files( |
340 |
[ |
341 |
{ |
342 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
343 |
file_content => $counter_file, |
344 |
filename => "Test_TR_J1", |
345 |
} |
346 |
] |
347 |
); |
348 |
|
349 |
my $librarian = $builder->build_object( |
338 |
my $librarian = $builder->build_object( |
350 |
{ |
339 |
{ |
351 |
class => 'Koha::Patrons', |
340 |
class => 'Koha::Patrons', |
Lines 355-360
subtest "provider_rollup_report" => sub {
Link Here
|
355 |
my $password = 'thePassword123'; |
344 |
my $password = 'thePassword123'; |
356 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
345 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
357 |
my $userid = $librarian->userid; |
346 |
my $userid = $librarian->userid; |
|
|
347 |
t::lib::Mocks::mock_userenv( { number => $userid } ); |
358 |
|
348 |
|
359 |
my $patron = $builder->build_object( |
349 |
my $patron = $builder->build_object( |
360 |
{ |
350 |
{ |
Lines 366-371
subtest "provider_rollup_report" => sub {
Link Here
|
366 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
356 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
367 |
my $unauth_userid = $patron->userid; |
357 |
my $unauth_userid = $patron->userid; |
368 |
|
358 |
|
|
|
359 |
# Run a harvest to populate the database with data |
360 |
my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); |
361 |
my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; |
362 |
|
363 |
$usage_data_provider->counter_files( |
364 |
[ |
365 |
{ |
366 |
usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, |
367 |
file_content => $counter_file, |
368 |
filename => "Test_TR_J1", |
369 |
} |
370 |
] |
371 |
); |
372 |
|
369 |
# Unauthorized access |
373 |
# Unauthorized access |
370 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/provider_rollup_report/title")->status_is(403); |
374 |
$t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/provider_rollup_report/title")->status_is(403); |
371 |
|
375 |
|
372 |
- |
|
|