|
Lines 47-62
subtest 'list() tests' => sub {
Link Here
|
| 47 |
{ |
47 |
{ |
| 48 |
class => 'Koha::Patrons', |
48 |
class => 'Koha::Patrons', |
| 49 |
value => { |
49 |
value => { |
| 50 |
flags => 2 ** 22 # 22 => ill |
50 |
flags => 2**22 # 22 => ill |
| 51 |
} |
51 |
} |
| 52 |
} |
52 |
} |
| 53 |
); |
53 |
); |
| 54 |
|
54 |
|
| 55 |
my $branch = $builder->build_object( |
55 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 56 |
{ |
|
|
| 57 |
class => 'Koha::Libraries' |
| 58 |
} |
| 59 |
); |
| 60 |
|
56 |
|
| 61 |
my $password = 'sheev_is_da_boss!'; |
57 |
my $password = 'sheev_is_da_boss!'; |
| 62 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
58 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
|
Lines 64-122
subtest 'list() tests' => sub {
Link Here
|
| 64 |
|
60 |
|
| 65 |
## Authorized user tests |
61 |
## Authorized user tests |
| 66 |
# No batches, so empty array should be returned |
62 |
# No batches, so empty array should be returned |
| 67 |
$t->get_ok("//$userid:$password@/api/v1/illbatches") |
63 |
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_is( [] ); |
| 68 |
->status_is(200) |
64 |
|
| 69 |
->json_is( [] ); |
65 |
my $batch = $builder->build_object( |
| 70 |
|
66 |
{ |
| 71 |
my $batch = $builder->build_object({ |
67 |
class => 'Koha::Illbatches', |
| 72 |
class => 'Koha::Illbatches', |
68 |
value => { |
| 73 |
value => { |
69 |
name => "PapaPalpatine", |
| 74 |
name => "PapaPalpatine", |
70 |
backend => "Mock", |
| 75 |
backend => "Mock", |
71 |
borrowernumber => $librarian->borrowernumber, |
| 76 |
borrowernumber => $librarian->borrowernumber, |
72 |
branchcode => $branch->branchcode |
| 77 |
branchcode => $branch->branchcode |
73 |
} |
| 78 |
} |
74 |
} |
| 79 |
}); |
75 |
); |
| 80 |
|
76 |
|
| 81 |
my $illrq = $builder->build({ |
77 |
my $illrq = $builder->build( |
| 82 |
source => 'Illrequest', |
78 |
{ |
| 83 |
value => { |
79 |
source => 'Illrequest', |
| 84 |
borrowernumber => $librarian->borrowernumber, |
80 |
value => { |
| 85 |
batch_id => $batch->id |
81 |
borrowernumber => $librarian->borrowernumber, |
|
|
82 |
batch_id => $batch->id |
| 83 |
} |
| 86 |
} |
84 |
} |
| 87 |
}); |
85 |
); |
| 88 |
|
86 |
|
| 89 |
# One batch created, should get returned |
87 |
# One batch created, should get returned |
| 90 |
$t->get_ok("//$userid:$password@/api/v1/illbatches") |
88 |
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_has( '/0/batch_id', 'Batch ID' ) |
| 91 |
->status_is(200) |
89 |
->json_has( '/0/name', 'Batch name' )->json_has( '/0/backend', 'Backend name' ) |
| 92 |
->json_has( '/0/id', 'Batch ID' ) |
90 |
->json_has( '/0/patron_id', 'Borrowernumber' )->json_has( '/0/library_id', 'Branchcode' ) |
| 93 |
->json_has( '/0/name', 'Batch name' ) |
91 |
->json_has( '/0/patron', 'patron embedded' )->json_has( '/0/branch', 'branch embedded' ) |
| 94 |
->json_has( '/0/backend', 'Backend name' ) |
92 |
->json_has( '/0/requests_count', 'request count' ); |
| 95 |
->json_has( '/0/borrowernumber', 'Borrowernumber' ) |
|
|
| 96 |
->json_has( '/0/branchcode', 'Branchcode' ) |
| 97 |
->json_has( '/0/patron', 'patron embedded' ) |
| 98 |
->json_has( '/0/branch', 'branch embedded' ) |
| 99 |
->json_has( '/0/requests_count', 'request count' ); |
| 100 |
|
93 |
|
| 101 |
# Try to create a second batch with the same name, this should fail |
94 |
# Try to create a second batch with the same name, this should fail |
| 102 |
my $another_batch = $builder->build_object({ class => 'Koha::Illbatches', value => { |
95 |
my $another_batch = $builder->build_object( { class => 'Koha::Illbatches', value => { name => $batch->name } } ); |
| 103 |
name => $batch->name |
96 |
|
| 104 |
} }); |
|
|
| 105 |
# Create a second batch with a different name |
97 |
# Create a second batch with a different name |
| 106 |
my $batch_with_another_name = $builder->build_object({ class => 'Koha::Illbatches' }); |
98 |
my $batch_with_another_name = $builder->build_object( { class => 'Koha::Illbatches' } ); |
| 107 |
|
99 |
|
| 108 |
# Two batches created, they should both be returned |
100 |
# Two batches created, they should both be returned |
| 109 |
$t->get_ok("//$userid:$password@/api/v1/illbatches") |
101 |
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_has( '/0', 'has first batch' ) |
| 110 |
->status_is(200) |
102 |
->json_has( '/1', 'has second batch' ); |
| 111 |
->json_has('/0', 'has first batch') |
|
|
| 112 |
->json_has('/1', 'has second batch'); |
| 113 |
|
103 |
|
| 114 |
my $patron = $builder->build_object( |
104 |
my $patron = $builder->build_object( |
| 115 |
{ |
105 |
{ |
| 116 |
class => 'Koha::Patrons', |
106 |
class => 'Koha::Patrons', |
| 117 |
value => { |
107 |
value => { |
| 118 |
cardnumber => 999, |
108 |
cardnumber => 999, |
| 119 |
flags => 0 |
109 |
flags => 0 |
| 120 |
} |
110 |
} |
| 121 |
} |
111 |
} |
| 122 |
); |
112 |
); |
|
Lines 125-132
subtest 'list() tests' => sub {
Link Here
|
| 125 |
my $unauth_userid = $patron->userid; |
115 |
my $unauth_userid = $patron->userid; |
| 126 |
|
116 |
|
| 127 |
# Unauthorized access |
117 |
# Unauthorized access |
| 128 |
$t->get_ok("//$unauth_userid:$password@/api/v1/illbatches") |
118 |
$t->get_ok("//$unauth_userid:$password@/api/v1/illbatches")->status_is(403); |
| 129 |
->status_is(403); |
|
|
| 130 |
|
119 |
|
| 131 |
$schema->storage->txn_rollback; |
120 |
$schema->storage->txn_rollback; |
| 132 |
}; |
121 |
}; |
|
Lines 154-207
subtest 'get() tests' => sub {
Link Here
|
| 154 |
} |
143 |
} |
| 155 |
); |
144 |
); |
| 156 |
|
145 |
|
| 157 |
my $branch = $builder->build_object( |
146 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
147 |
|
| 148 |
my $batch = $builder->build_object( |
| 158 |
{ |
149 |
{ |
| 159 |
class => 'Koha::Libraries' |
150 |
class => 'Koha::Illbatches', |
|
|
151 |
value => { |
| 152 |
name => "LeiaOrgana", |
| 153 |
backend => "Mock", |
| 154 |
borrowernumber => $librarian->borrowernumber, |
| 155 |
branchcode => $branch->branchcode |
| 156 |
} |
| 160 |
} |
157 |
} |
| 161 |
); |
158 |
); |
| 162 |
|
159 |
|
| 163 |
my $batch = $builder->build_object({ |
|
|
| 164 |
class => 'Koha::Illbatches', |
| 165 |
value => { |
| 166 |
name => "LeiaOrgana", |
| 167 |
backend => "Mock", |
| 168 |
borrowernumber => $librarian->borrowernumber, |
| 169 |
branchcode => $branch->branchcode |
| 170 |
} |
| 171 |
}); |
| 172 |
|
| 173 |
|
| 174 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
160 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 175 |
my $unauth_userid = $patron->userid; |
161 |
my $unauth_userid = $patron->userid; |
| 176 |
|
162 |
|
| 177 |
$t->get_ok( "//$userid:$password@/api/v1/illbatches/" . $batch->id ) |
163 |
$t->get_ok( "//$userid:$password@/api/v1/illbatches/" . $batch->id )->status_is(200) |
| 178 |
->status_is(200) |
164 |
->json_has( '/batch_id', 'Batch ID' )->json_has( '/name', 'Batch name' ) |
| 179 |
->json_has( '/id', 'Batch ID' ) |
165 |
->json_has( '/backend', 'Backend name' )->json_has( '/patron_id', 'Borrowernumber' ) |
| 180 |
->json_has( '/name', 'Batch name' ) |
166 |
->json_has( '/library_id', 'Branchcode' )->json_has( '/patron', 'patron embedded' ) |
| 181 |
->json_has( '/backend', 'Backend name' ) |
167 |
->json_has( '/branch', 'branch embedded' )->json_has( '/requests_count', 'request count' ); |
| 182 |
->json_has( '/borrowernumber', 'Borrowernumber' ) |
168 |
|
| 183 |
->json_has( '/branchcode', 'Branchcode' ) |
169 |
$t->get_ok( "//$unauth_userid:$password@/api/v1/illbatches/" . $batch->id )->status_is(403); |
| 184 |
->json_has( '/patron', 'patron embedded' ) |
170 |
|
| 185 |
->json_has( '/branch', 'branch embedded' ) |
171 |
my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } ); |
| 186 |
->json_has( '/requests_count', 'request count' ); |
|
|
| 187 |
|
| 188 |
$t->get_ok( "//$unauth_userid:$password@/api/v1/illbatches/" . $batch->id ) |
| 189 |
->status_is(403); |
| 190 |
|
| 191 |
my $batch_to_delete = $builder->build_object({ class => 'Koha::Illbatches' }); |
| 192 |
my $non_existent_id = $batch_to_delete->id; |
172 |
my $non_existent_id = $batch_to_delete->id; |
| 193 |
$batch_to_delete->delete; |
173 |
$batch_to_delete->delete; |
| 194 |
|
174 |
|
| 195 |
$t->get_ok( "//$userid:$password@/api/v1/illbatches/$non_existent_id" ) |
175 |
$t->get_ok("//$userid:$password@/api/v1/illbatches/$non_existent_id")->status_is(404) |
| 196 |
->status_is(404) |
176 |
->json_is( '/error' => 'ILL batch not found' ); |
| 197 |
->json_is( '/error' => 'ILL batch not found' ); |
|
|
| 198 |
|
177 |
|
| 199 |
$schema->storage->txn_rollback; |
178 |
$schema->storage->txn_rollback; |
| 200 |
}; |
179 |
}; |
| 201 |
|
180 |
|
| 202 |
subtest 'add() tests' => sub { |
181 |
subtest 'add() tests' => sub { |
| 203 |
|
182 |
|
| 204 |
plan tests =>19; |
183 |
plan tests => 19; |
| 205 |
|
184 |
|
| 206 |
$schema->storage->txn_begin; |
185 |
$schema->storage->txn_begin; |
| 207 |
|
186 |
|
|
Lines 225-253
subtest 'add() tests' => sub {
Link Here
|
| 225 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
204 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 226 |
my $unauth_userid = $patron->userid; |
205 |
my $unauth_userid = $patron->userid; |
| 227 |
|
206 |
|
| 228 |
my $branch = $builder->build_object( |
207 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 229 |
{ |
|
|
| 230 |
class => 'Koha::Libraries' |
| 231 |
} |
| 232 |
); |
| 233 |
|
208 |
|
| 234 |
my $batch_status = $builder->build_object( |
209 |
my $batch_status = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); |
| 235 |
{ |
|
|
| 236 |
class => 'Koha::IllbatchStatuses' |
| 237 |
} |
| 238 |
); |
| 239 |
|
210 |
|
| 240 |
my $batch_metadata = { |
211 |
my $batch_metadata = { |
| 241 |
name => "Anakin's requests", |
212 |
name => "Anakin's requests", |
| 242 |
backend => "Mock", |
213 |
backend => "Mock", |
| 243 |
cardnumber => $librarian->cardnumber, |
214 |
cardnumber => $librarian->cardnumber, |
| 244 |
branchcode => $branch->branchcode, |
215 |
library_id => $branch->branchcode, |
| 245 |
statuscode => $batch_status->code |
216 |
statuscode => $batch_status->code |
| 246 |
}; |
217 |
}; |
| 247 |
|
218 |
|
| 248 |
# Unauthorized attempt to write |
219 |
# Unauthorized attempt to write |
| 249 |
$t->post_ok("//$unauth_userid:$password@/api/v1/illbatches" => json => $batch_metadata) |
220 |
$t->post_ok( "//$unauth_userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(403); |
| 250 |
->status_is(403); |
|
|
| 251 |
|
221 |
|
| 252 |
# Authorized attempt to write invalid data |
222 |
# Authorized attempt to write invalid data |
| 253 |
my $batch_with_invalid_field = { |
223 |
my $batch_with_invalid_field = { |
|
Lines 255-290
subtest 'add() tests' => sub {
Link Here
|
| 255 |
doh => 1 |
225 |
doh => 1 |
| 256 |
}; |
226 |
}; |
| 257 |
|
227 |
|
| 258 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_with_invalid_field ) |
228 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_with_invalid_field )->status_is(400) |
| 259 |
->status_is(400) |
229 |
->json_is( |
| 260 |
->json_is( |
|
|
| 261 |
"/errors" => [ |
230 |
"/errors" => [ |
| 262 |
{ |
231 |
{ |
| 263 |
message => "Properties not allowed: doh.", |
232 |
message => "Properties not allowed: doh.", |
| 264 |
path => "/body" |
233 |
path => "/body" |
| 265 |
} |
234 |
} |
| 266 |
] |
235 |
] |
| 267 |
); |
236 |
); |
| 268 |
|
237 |
|
| 269 |
# Authorized attempt to write |
238 |
# Authorized attempt to write |
| 270 |
my $batch_id = |
239 |
my $batch_id = |
| 271 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata ) |
240 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(201) |
| 272 |
->status_is( 201 ) |
241 |
->json_is( '/name' => $batch_metadata->{name} )->json_is( '/backend' => $batch_metadata->{backend} ) |
| 273 |
->json_is( '/name' => $batch_metadata->{name} ) |
242 |
->json_is( '/patron_id' => $librarian->borrowernumber ) |
| 274 |
->json_is( '/backend' => $batch_metadata->{backend} ) |
243 |
->json_is( '/library_id' => $batch_metadata->{library_id} )->json_is( '/statuscode' => $batch_status->code ) |
| 275 |
->json_is( '/borrowernumber' => $librarian->borrowernumber ) |
244 |
->json_has('/patron')->json_has('/status')->json_has('/requests_count')->json_has('/branch'); |
| 276 |
->json_is( '/branchcode' => $batch_metadata->{branchcode} ) |
|
|
| 277 |
->json_is( '/statuscode' => $batch_status->code ) |
| 278 |
->json_has( '/patron' ) |
| 279 |
->json_has( '/status' ) |
| 280 |
->json_has( '/requests_count' ) |
| 281 |
->json_has( '/branch' ); |
| 282 |
|
245 |
|
| 283 |
# Authorized attempt to create with null id |
246 |
# Authorized attempt to create with null id |
| 284 |
$batch_metadata->{id} = undef; |
247 |
$batch_metadata->{id} = undef; |
| 285 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata ) |
248 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(400) |
| 286 |
->status_is(400) |
249 |
->json_has('/errors'); |
| 287 |
->json_has('/errors'); |
|
|
| 288 |
|
250 |
|
| 289 |
$schema->storage->txn_rollback; |
251 |
$schema->storage->txn_rollback; |
| 290 |
}; |
252 |
}; |
|
Lines 315-395
subtest 'update() tests' => sub {
Link Here
|
| 315 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
277 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 316 |
my $unauth_userid = $patron->userid; |
278 |
my $unauth_userid = $patron->userid; |
| 317 |
|
279 |
|
| 318 |
my $branch = $builder->build_object( |
280 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 319 |
{ |
|
|
| 320 |
class => 'Koha::Libraries' |
| 321 |
} |
| 322 |
); |
| 323 |
|
281 |
|
| 324 |
my $batch_id = $builder->build_object({ class => 'Koha::Illbatches' } )->id; |
282 |
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id; |
| 325 |
|
283 |
|
| 326 |
# Unauthorized attempt to update |
284 |
# Unauthorized attempt to update |
| 327 |
$t->put_ok( "//$unauth_userid:$password@/api/v1/illbatches/$batch_id" => json => { name => 'These are not the droids you are looking for' } ) |
285 |
$t->put_ok( "//$unauth_userid:$password@/api/v1/illbatches/$batch_id" => json => |
| 328 |
->status_is(403); |
286 |
{ name => 'These are not the droids you are looking for' } )->status_is(403); |
| 329 |
|
287 |
|
| 330 |
my $batch_status = $builder->build_object( |
288 |
my $batch_status = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); |
| 331 |
{ |
|
|
| 332 |
class => 'Koha::IllbatchStatuses' |
| 333 |
} |
| 334 |
); |
| 335 |
|
289 |
|
| 336 |
# Attempt partial update on a PUT |
290 |
# Attempt partial update on a PUT |
| 337 |
my $batch_with_missing_field = { |
291 |
my $batch_with_missing_field = { |
| 338 |
backend => "Mock", |
292 |
backend => "Mock", |
| 339 |
borrowernumber => $librarian->borrowernumber, |
293 |
patron_id => $librarian->borrowernumber, |
| 340 |
branchcode => $branch->branchcode, |
294 |
library_id => $branch->branchcode, |
| 341 |
statuscode => $batch_status->code |
295 |
statuscode => $batch_status->code |
| 342 |
}; |
296 |
}; |
| 343 |
|
297 |
|
| 344 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_missing_field ) |
298 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_missing_field ) |
| 345 |
->status_is(400) |
299 |
->status_is(400)->json_is( "/errors" => [ { message => "Missing property.", path => "/body/name" } ] ); |
| 346 |
->json_is( "/errors" => |
|
|
| 347 |
[ { message => "Missing property.", path => "/body/name" } ] |
| 348 |
); |
| 349 |
|
300 |
|
| 350 |
# Full object update on PUT |
301 |
# Full object update on PUT |
| 351 |
my $batch_with_updated_field = { |
302 |
my $batch_with_updated_field = { |
| 352 |
name => "Master Ploo Koon", |
303 |
name => "Master Ploo Koon", |
| 353 |
backend => "Mock", |
304 |
backend => "Mock", |
| 354 |
borrowernumber => $librarian->borrowernumber, |
305 |
patron_id => $librarian->borrowernumber, |
| 355 |
branchcode => $branch->branchcode, |
306 |
library_id => $branch->branchcode, |
| 356 |
statuscode => $batch_status->code |
307 |
statuscode => $batch_status->code |
| 357 |
}; |
308 |
}; |
| 358 |
|
309 |
|
| 359 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field ) |
310 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field ) |
| 360 |
->status_is(200) |
311 |
->status_is(200)->json_is( '/name' => 'Master Ploo Koon' ); |
| 361 |
->json_is( '/name' => 'Master Ploo Koon' ); |
|
|
| 362 |
|
312 |
|
| 363 |
# Authorized attempt to write invalid data |
313 |
# Authorized attempt to write invalid data |
| 364 |
my $batch_with_invalid_field = { |
314 |
my $batch_with_invalid_field = { |
| 365 |
doh => 1, |
315 |
doh => 1, |
| 366 |
name => "Master Mace Windu", |
316 |
name => "Master Mace Windu", |
| 367 |
backend => "Mock" |
317 |
backend => "Mock" |
| 368 |
}; |
318 |
}; |
| 369 |
|
319 |
|
| 370 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_invalid_field ) |
320 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_invalid_field ) |
| 371 |
->status_is(400) |
321 |
->status_is(400)->json_is( |
| 372 |
->json_is( |
|
|
| 373 |
"/errors" => [ |
322 |
"/errors" => [ |
| 374 |
{ |
323 |
{ |
| 375 |
message => "Properties not allowed: doh.", |
324 |
message => "Properties not allowed: doh.", |
| 376 |
path => "/body" |
325 |
path => "/body" |
| 377 |
} |
326 |
} |
| 378 |
] |
327 |
] |
| 379 |
); |
328 |
); |
| 380 |
|
329 |
|
| 381 |
my $batch_to_delete = $builder->build_object({ class => 'Koha::Cities' }); |
330 |
my $batch_to_delete = $builder->build_object( { class => 'Koha::Cities' } ); |
| 382 |
my $non_existent_id = $batch_to_delete->id; |
331 |
my $non_existent_id = $batch_to_delete->id; |
| 383 |
$batch_to_delete->delete; |
332 |
$batch_to_delete->delete; |
| 384 |
|
333 |
|
| 385 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$non_existent_id" => json => $batch_with_updated_field ) |
334 |
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$non_existent_id" => json => $batch_with_updated_field ) |
| 386 |
->status_is(404); |
335 |
->status_is(404); |
| 387 |
|
336 |
|
| 388 |
# Wrong method (POST) |
337 |
# Wrong method (POST) |
| 389 |
$batch_with_updated_field->{id} = 2; |
338 |
$batch_with_updated_field->{id} = 2; |
| 390 |
|
339 |
|
| 391 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field ) |
340 |
$t->post_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field ) |
| 392 |
->status_is(404); |
341 |
->status_is(404); |
| 393 |
|
342 |
|
| 394 |
$schema->storage->txn_rollback; |
343 |
$schema->storage->txn_rollback; |
| 395 |
}; |
344 |
}; |
|
Lines 420-436
subtest 'delete() tests' => sub {
Link Here
|
| 420 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
369 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 421 |
my $unauth_userid = $patron->userid; |
370 |
my $unauth_userid = $patron->userid; |
| 422 |
|
371 |
|
| 423 |
my $batch_id = $builder->build_object({ class => 'Koha::Illbatches' })->id; |
372 |
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id; |
| 424 |
|
373 |
|
| 425 |
# Unauthorized attempt to delete |
374 |
# Unauthorized attempt to delete |
| 426 |
$t->delete_ok( "//$unauth_userid:$password@/api/v1/illbatches/$batch_id" ) |
375 |
$t->delete_ok("//$unauth_userid:$password@/api/v1/illbatches/$batch_id")->status_is(403); |
| 427 |
->status_is(403); |
|
|
| 428 |
|
376 |
|
| 429 |
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id") |
377 |
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id")->status_is(204); |
| 430 |
->status_is(204); |
|
|
| 431 |
|
378 |
|
| 432 |
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id") |
379 |
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id")->status_is(404); |
| 433 |
->status_is(404); |
|
|
| 434 |
|
380 |
|
| 435 |
$schema->storage->txn_rollback; |
381 |
$schema->storage->txn_rollback; |
| 436 |
}; |
382 |
}; |