|
Lines 85-91
subtest 'list() tests' => sub {
Link Here
|
| 85 |
my $macros_index = Koha::AdvancedEditorMacros->search({ -or => { shared => 1, borrowernumber => $patron_1->borrowernumber } })->count-1; |
85 |
my $macros_index = Koha::AdvancedEditorMacros->search({ -or => { shared => 1, borrowernumber => $patron_1->borrowernumber } })->count-1; |
| 86 |
## Authorized user tests |
86 |
## Authorized user tests |
| 87 |
# Make sure we are returned with the correct amount of macros |
87 |
# Make sure we are returned with the correct amount of macros |
| 88 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros" ) |
88 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros" ) |
| 89 |
->status_is( 200, 'SWAGGER3.2.2' ) |
89 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 90 |
->json_has('/' . $macros_index . '/macro_id') |
90 |
->json_has('/' . $macros_index . '/macro_id') |
| 91 |
->json_hasnt('/' . ($macros_index + 1) . '/macro_id'); |
91 |
->json_hasnt('/' . ($macros_index + 1) . '/macro_id'); |
|
Lines 93-117
subtest 'list() tests' => sub {
Link Here
|
| 93 |
subtest 'query parameters' => sub { |
93 |
subtest 'query parameters' => sub { |
| 94 |
|
94 |
|
| 95 |
plan tests => 15; |
95 |
plan tests => 15; |
| 96 |
$t->get_ok("//$userid:$password@/api/v1/advancededitormacros?name=" . $macro_2->name) |
96 |
$t->get_ok("//$userid:$password@/api/v1/advanced_editor/macros?name=" . $macro_2->name) |
| 97 |
->status_is(200) |
97 |
->status_is(200) |
| 98 |
->json_has( [ $macro_2 ] ); |
98 |
->json_has( [ $macro_2 ] ); |
| 99 |
$t->get_ok("//$userid:$password@/api/v1/advancededitormacros?name=" . $macro_3->name) |
99 |
$t->get_ok("//$userid:$password@/api/v1/advanced_editor/macros?name=" . $macro_3->name) |
| 100 |
->status_is(200) |
100 |
->status_is(200) |
| 101 |
->json_has( [ ] ); |
101 |
->json_has( [ ] ); |
| 102 |
$t->get_ok("//$userid:$password@/api/v1/advancededitormacros?macro_text=delete 100") |
102 |
$t->get_ok("//$userid:$password@/api/v1/advanced_editor/macros?macro_text=delete 100") |
| 103 |
->status_is(200) |
103 |
->status_is(200) |
| 104 |
->json_has( [ $macro_1, $macro_2, $macro_4 ] ); |
104 |
->json_has( [ $macro_1, $macro_2, $macro_4 ] ); |
| 105 |
$t->get_ok("//$userid:$password@/api/v1/advancededitormacros?patron_id=" . $patron_1->borrowernumber) |
105 |
$t->get_ok("//$userid:$password@/api/v1/advanced_editor/macros?patron_id=" . $patron_1->borrowernumber) |
| 106 |
->status_is(200) |
106 |
->status_is(200) |
| 107 |
->json_has( [ $macro_1, $macro_2 ] ); |
107 |
->json_has( [ $macro_1, $macro_2 ] ); |
| 108 |
$t->get_ok("//$userid:$password@/api/v1/advancededitormacros?shared=1") |
108 |
$t->get_ok("//$userid:$password@/api/v1/advanced_editor/macros?shared=1") |
| 109 |
->status_is(200) |
109 |
->status_is(200) |
| 110 |
->json_has( [ $macro_2, $macro_4 ] ); |
110 |
->json_has( [ $macro_2, $macro_4 ] ); |
| 111 |
}; |
111 |
}; |
| 112 |
|
112 |
|
| 113 |
# Warn on unsupported query parameter |
113 |
# Warn on unsupported query parameter |
| 114 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros?macro_blah=blah" ) |
114 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros?macro_blah=blah" ) |
| 115 |
->status_is(400) |
115 |
->status_is(400) |
| 116 |
->json_is( [{ path => '/query/macro_blah', message => 'Malformed query string'}] ); |
116 |
->json_is( [{ path => '/query/macro_blah', message => 'Malformed query string'}] ); |
| 117 |
|
117 |
|
|
Lines 143-168
subtest 'get() tests' => sub {
Link Here
|
| 143 |
} |
143 |
} |
| 144 |
}); |
144 |
}); |
| 145 |
|
145 |
|
| 146 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros/" . $macro_1->id ) |
146 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros/" . $macro_1->id ) |
| 147 |
->status_is( 403, 'Cannot get a shared macro via regular endpoint' ) |
147 |
->status_is( 403, 'Cannot get a shared macro via regular endpoint' ) |
| 148 |
->json_is( '/error' => 'This macro is shared, you must access it via advancededitormacros/shared' ); |
148 |
->json_is( '/error' => 'This macro is shared, you must access it via advanced_editor/macros/shared' ); |
| 149 |
|
149 |
|
| 150 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros/shared/" . $macro_1->id ) |
150 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros/shared/" . $macro_1->id ) |
| 151 |
->status_is( 200, 'Can get a shared macro via shared endpoint' ) |
151 |
->status_is( 200, 'Can get a shared macro via shared endpoint' ) |
| 152 |
->json_is( '' => Koha::REST::V1::AdvancedEditorMacro::_to_api( $macro_1->TO_JSON ), 'Macro correctly retrieved' ); |
152 |
->json_is( '' => Koha::REST::V1::AdvancedEditorMacro::_to_api( $macro_1->TO_JSON ), 'Macro correctly retrieved' ); |
| 153 |
|
153 |
|
| 154 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros/" . $macro_2->id ) |
154 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros/" . $macro_2->id ) |
| 155 |
->status_is( 403, 'Cannot access another users macro' ) |
155 |
->status_is( 403, 'Cannot access another users macro' ) |
| 156 |
->json_is( '/error' => 'You do not have permission to access this macro' ); |
156 |
->json_is( '/error' => 'You do not have permission to access this macro' ); |
| 157 |
|
157 |
|
| 158 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros/" . $macro_3->id ) |
158 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros/" . $macro_3->id ) |
| 159 |
->status_is( 200, 'Can get your own private macro' ) |
159 |
->status_is( 200, 'Can get your own private macro' ) |
| 160 |
->json_is( '' => Koha::REST::V1::AdvancedEditorMacro::_to_api( $macro_3->TO_JSON ), 'Macro correctly retrieved' ); |
160 |
->json_is( '' => Koha::REST::V1::AdvancedEditorMacro::_to_api( $macro_3->TO_JSON ), 'Macro correctly retrieved' ); |
| 161 |
|
161 |
|
| 162 |
my $non_existent_code = $macro_1->id; |
162 |
my $non_existent_code = $macro_1->id; |
| 163 |
$macro_1->delete; |
163 |
$macro_1->delete; |
| 164 |
|
164 |
|
| 165 |
$t->get_ok( "//$userid:$password@/api/v1/advancededitormacros/" . $non_existent_code ) |
165 |
$t->get_ok( "//$userid:$password@/api/v1/advanced_editor/macros/" . $non_existent_code ) |
| 166 |
->status_is(404) |
166 |
->status_is(404) |
| 167 |
->json_is( '/error' => 'Macro not found' ); |
167 |
->json_is( '/error' => 'Macro not found' ); |
| 168 |
|
168 |
|
|
Lines 205-218
subtest 'add() tests' => sub {
Link Here
|
| 205 |
$macro->delete; |
205 |
$macro->delete; |
| 206 |
|
206 |
|
| 207 |
# Unauthorized attempt to write |
207 |
# Unauthorized attempt to write |
| 208 |
$t->post_ok( "//$unauth_userid:$password@/api/v1/advancededitormacros" => json => $macro_values ) |
208 |
$t->post_ok( "//$unauth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_values ) |
| 209 |
->status_is(403); |
209 |
->status_is(403); |
| 210 |
|
210 |
|
| 211 |
# Authorized attempt to write invalid data |
211 |
# Authorized attempt to write invalid data |
| 212 |
my $macro_with_invalid_field = { %$macro_values }; |
212 |
my $macro_with_invalid_field = { %$macro_values }; |
| 213 |
$macro_with_invalid_field->{'big_mac_ro'} = 'Mac attack'; |
213 |
$macro_with_invalid_field->{'big_mac_ro'} = 'Mac attack'; |
| 214 |
|
214 |
|
| 215 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros" => json => $macro_with_invalid_field ) |
215 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_with_invalid_field ) |
| 216 |
->status_is(400) |
216 |
->status_is(400) |
| 217 |
->json_is( |
217 |
->json_is( |
| 218 |
"/errors" => [ |
218 |
"/errors" => [ |
|
Lines 224-237
subtest 'add() tests' => sub {
Link Here
|
| 224 |
); |
224 |
); |
| 225 |
|
225 |
|
| 226 |
# Authorized attempt to write |
226 |
# Authorized attempt to write |
| 227 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros" => json => $macro_values ) |
227 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_values ) |
| 228 |
->status_is( 201, 'SWAGGER3.2.1' ) |
228 |
->status_is( 201, 'SWAGGER3.2.1' ) |
| 229 |
->json_has( '/macro_id', 'We generated a new id' ) |
229 |
->json_has( '/macro_id', 'We generated a new id' ) |
| 230 |
->json_is( '/name' => $macro_values->{name}, 'The name matches what we supplied' ) |
230 |
->json_is( '/name' => $macro_values->{name}, 'The name matches what we supplied' ) |
| 231 |
->json_is( '/macro_text' => $macro_values->{macro_text}, 'The text matches what we supplied' ) |
231 |
->json_is( '/macro_text' => $macro_values->{macro_text}, 'The text matches what we supplied' ) |
| 232 |
->json_is( '/patron_id' => $macro_values->{patron_id}, 'The borrower matches the borrower who submitted' ) |
232 |
->json_is( '/patron_id' => $macro_values->{patron_id}, 'The borrower matches the borrower who submitted' ) |
| 233 |
->json_is( '/shared' => 0, 'The macro is not shared' ) |
233 |
->json_is( '/shared' => Mojo::JSON->false, 'The macro is not shared' ) |
| 234 |
->header_like( Location => qr|^\/api\/v1\/advancededitormacros\/d*|, 'Correct location' ); |
234 |
->header_like( Location => qr|^\/api\/v1\/advanced_editor/macros\/d*|, 'Correct location' ); |
| 235 |
|
235 |
|
| 236 |
# save the library_id |
236 |
# save the library_id |
| 237 |
my $macro_id = 999; |
237 |
my $macro_id = 999; |
|
Lines 239-245
subtest 'add() tests' => sub {
Link Here
|
| 239 |
# Authorized attempt to create with existing id |
239 |
# Authorized attempt to create with existing id |
| 240 |
$macro_values->{macro_id} = $macro_id; |
240 |
$macro_values->{macro_id} = $macro_id; |
| 241 |
|
241 |
|
| 242 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros" => json => $macro_values ) |
242 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_values ) |
| 243 |
->status_is(400) |
243 |
->status_is(400) |
| 244 |
->json_is( '/errors' => [ |
244 |
->json_is( '/errors' => [ |
| 245 |
{ |
245 |
{ |
|
Lines 249-262
subtest 'add() tests' => sub {
Link Here
|
| 249 |
] |
249 |
] |
| 250 |
); |
250 |
); |
| 251 |
|
251 |
|
| 252 |
$macro_values->{shared} = 1; |
252 |
$macro_values->{shared} = Mojo::JSON->true; |
| 253 |
delete $macro_values->{macro_id}; |
253 |
delete $macro_values->{macro_id}; |
| 254 |
|
254 |
|
| 255 |
# Unauthorized attempt to write a shared macro on private endpoint |
255 |
# Unauthorized attempt to write a shared macro on private endpoint |
| 256 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros" => json => $macro_values ) |
256 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_values ) |
| 257 |
->status_is(403); |
257 |
->status_is(403); |
| 258 |
# Unauthorized attempt to write a private macro on shared endpoint |
258 |
# Unauthorized attempt to write a private macro on shared endpoint |
| 259 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared" => json => $macro_values ) |
259 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared" => json => $macro_values ) |
| 260 |
->status_is(403); |
260 |
->status_is(403); |
| 261 |
|
261 |
|
| 262 |
$builder->build({ |
262 |
$builder->build({ |
|
Lines 269-279
subtest 'add() tests' => sub {
Link Here
|
| 269 |
}); |
269 |
}); |
| 270 |
|
270 |
|
| 271 |
# Authorized attempt to write a shared macro on private endpoint |
271 |
# Authorized attempt to write a shared macro on private endpoint |
| 272 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros" => json => $macro_values ) |
272 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros" => json => $macro_values ) |
| 273 |
->status_is(403); |
273 |
->status_is(403); |
| 274 |
|
274 |
|
| 275 |
# Authorized attempt to write a shared macro on shared endpoint |
275 |
# Authorized attempt to write a shared macro on shared endpoint |
| 276 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared" => json => $macro_values ) |
276 |
$t->post_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared" => json => $macro_values ) |
| 277 |
->status_is(201); |
277 |
->status_is(201); |
| 278 |
|
278 |
|
| 279 |
}; |
279 |
}; |
|
Lines 319-325
subtest 'update() tests' => sub {
Link Here
|
| 319 |
delete $macro_values->{macro_id}; |
319 |
delete $macro_values->{macro_id}; |
| 320 |
|
320 |
|
| 321 |
# Unauthorized attempt to update |
321 |
# Unauthorized attempt to update |
| 322 |
$t->put_ok( "//$unauth_userid:$password@/api/v1/advancededitormacros/$macro_id" |
322 |
$t->put_ok( "//$unauth_userid:$password@/api/v1/advanced_editor/macros/$macro_id" |
| 323 |
=> json => { name => 'New unauthorized name change' } ) |
323 |
=> json => { name => 'New unauthorized name change' } ) |
| 324 |
->status_is(403); |
324 |
->status_is(403); |
| 325 |
|
325 |
|
|
Lines 328-334
subtest 'update() tests' => sub {
Link Here
|
| 328 |
name => "Call it macro-roni", |
328 |
name => "Call it macro-roni", |
| 329 |
}; |
329 |
}; |
| 330 |
|
330 |
|
| 331 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_id" => json => $macro_with_missing_field ) |
331 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_id" => json => $macro_with_missing_field ) |
| 332 |
->status_is(400) |
332 |
->status_is(400) |
| 333 |
->json_has( "/errors" => |
333 |
->json_has( "/errors" => |
| 334 |
[ { message => "Missing property.", path => "/body/macro_text" } ] |
334 |
[ { message => "Missing property.", path => "/body/macro_text" } ] |
|
Lines 338-347
subtest 'update() tests' => sub {
Link Here
|
| 338 |
name => "Macro-update", |
338 |
name => "Macro-update", |
| 339 |
macro_text => "delete 100", |
339 |
macro_text => "delete 100", |
| 340 |
patron_id => $authorized_patron->borrowernumber, |
340 |
patron_id => $authorized_patron->borrowernumber, |
| 341 |
shared => 0, |
341 |
shared => Mojo::JSON->false, |
| 342 |
}; |
342 |
}; |
| 343 |
|
343 |
|
| 344 |
my $test = $t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_id" => json => $macro_update ) |
344 |
my $test = $t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_id" => json => $macro_update ) |
| 345 |
->status_is(200, 'Authorized user can update a macro') |
345 |
->status_is(200, 'Authorized user can update a macro') |
| 346 |
->json_is( '/macro_id' => $macro_id, 'We get the id back' ) |
346 |
->json_is( '/macro_id' => $macro_id, 'We get the id back' ) |
| 347 |
->json_is( '/name' => $macro_update->{name}, 'We get the name back' ) |
347 |
->json_is( '/name' => $macro_update->{name}, 'We get the name back' ) |
|
Lines 350-360
subtest 'update() tests' => sub {
Link Here
|
| 350 |
->json_is( '/shared' => $macro_update->{shared}, 'It should still not be shared' ); |
350 |
->json_is( '/shared' => $macro_update->{shared}, 'It should still not be shared' ); |
| 351 |
|
351 |
|
| 352 |
# Now try to make the macro shared |
352 |
# Now try to make the macro shared |
| 353 |
$macro_update->{shared} = 1; |
353 |
$macro_update->{shared} = Mojo::JSON->true; |
| 354 |
|
354 |
|
| 355 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared/$macro_id" => json => $macro_update ) |
355 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared/$macro_id" => json => $macro_update ) |
| 356 |
->status_is(403, 'Cannot make your macro shared on private endpoint'); |
356 |
->status_is(403, 'Cannot make your macro shared on private endpoint'); |
| 357 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared/$macro_id" => json => $macro_update ) |
357 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared/$macro_id" => json => $macro_update ) |
| 358 |
->status_is(403, 'Cannot make your macro shared without permission'); |
358 |
->status_is(403, 'Cannot make your macro shared without permission'); |
| 359 |
|
359 |
|
| 360 |
$builder->build({ |
360 |
$builder->build({ |
|
Lines 366-387
subtest 'update() tests' => sub {
Link Here
|
| 366 |
}, |
366 |
}, |
| 367 |
}); |
367 |
}); |
| 368 |
|
368 |
|
| 369 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_id" => json => $macro_update ) |
369 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_id" => json => $macro_update ) |
| 370 |
->status_is(403, 'Cannot make your macro shared on the private endpoint'); |
370 |
->status_is(403, 'Cannot make your macro shared on the private endpoint'); |
| 371 |
|
371 |
|
| 372 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared/$macro_id" => json => $macro_update ) |
372 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared/$macro_id" => json => $macro_update ) |
| 373 |
->status_is(200, 'Can update macro to shared with permission') |
373 |
->status_is(200, 'Can update macro to shared with permission') |
| 374 |
->json_is( '/macro_id' => $macro_id, 'We get back the id' ) |
374 |
->json_is( '/macro_id' => $macro_id, 'We get back the id' ) |
| 375 |
->json_is( '/name' => $macro_update->{name}, 'We get back the name' ) |
375 |
->json_is( '/name' => $macro_update->{name}, 'We get back the name' ) |
| 376 |
->json_is( '/macro_text' => $macro_update->{macro_text}, 'We get back the text' ) |
376 |
->json_is( '/macro_text' => $macro_update->{macro_text}, 'We get back the text' ) |
| 377 |
->json_is( '/patron_id' => $macro_update->{patron_id}, 'We get back our patron id' ) |
377 |
->json_is( '/patron_id' => $macro_update->{patron_id}, 'We get back our patron id' ) |
| 378 |
->json_is( '/shared' => 1, 'It is shared' ); |
378 |
->json_is( '/shared' => Mojo::JSON->true, 'It is shared' ); |
| 379 |
|
379 |
|
| 380 |
# Authorized attempt to write invalid data |
380 |
# Authorized attempt to write invalid data |
| 381 |
my $macro_with_invalid_field = { %$macro_update }; |
381 |
my $macro_with_invalid_field = { %$macro_update }; |
| 382 |
$macro_with_invalid_field->{'big_mac_ro'} = 'Mac attack'; |
382 |
$macro_with_invalid_field->{'big_mac_ro'} = 'Mac attack'; |
| 383 |
|
383 |
|
| 384 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_id" => json => $macro_with_invalid_field ) |
384 |
$t->put_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_id" => json => $macro_with_invalid_field ) |
| 385 |
->status_is(400) |
385 |
->status_is(400) |
| 386 |
->json_is( |
386 |
->json_is( |
| 387 |
"/errors" => [ |
387 |
"/errors" => [ |
|
Lines 396-405
subtest 'update() tests' => sub {
Link Here
|
| 396 |
my $non_existent_code = $non_existent_macro->id; |
396 |
my $non_existent_code = $non_existent_macro->id; |
| 397 |
$non_existent_macro->delete; |
397 |
$non_existent_macro->delete; |
| 398 |
|
398 |
|
| 399 |
$t->put_ok("//$auth_userid:$password@/api/v1/advancededitormacros/$non_existent_code" => json => $macro_update) |
399 |
$t->put_ok("//$auth_userid:$password@/api/v1/advanced_editor/macros/$non_existent_code" => json => $macro_update) |
| 400 |
->status_is(404); |
400 |
->status_is(404); |
| 401 |
|
401 |
|
| 402 |
$t->put_ok("//$auth_userid:$password@/api/v1/advancededitormacros/$macro_2_id" => json => $macro_update) |
402 |
$t->put_ok("//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_2_id" => json => $macro_update) |
| 403 |
->status_is(403, "Cannot update other borrowers private macro"); |
403 |
->status_is(403, "Cannot update other borrowers private macro"); |
| 404 |
}; |
404 |
}; |
| 405 |
|
405 |
|
|
Lines 442-459
subtest 'delete() tests' => sub {
Link Here
|
| 442 |
my $macro_2_id = $macro_2->id; |
442 |
my $macro_2_id = $macro_2->id; |
| 443 |
|
443 |
|
| 444 |
# Unauthorized attempt to delete |
444 |
# Unauthorized attempt to delete |
| 445 |
$t->delete_ok( "//$unauth_userid:$password@/api/v1/advancededitormacros/$macro_2_id") |
445 |
$t->delete_ok( "//$unauth_userid:$password@/api/v1/advanced_editor/macros/$macro_2_id") |
| 446 |
->status_is(403, "Cannot delete macro without permission"); |
446 |
->status_is(403, "Cannot delete macro without permission"); |
| 447 |
|
447 |
|
| 448 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_id") |
448 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_id") |
| 449 |
->status_is(200, 'Can delete macro with permission'); |
449 |
->status_is(200, 'Can delete macro with permission'); |
| 450 |
|
450 |
|
| 451 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_2_id") |
451 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_2_id") |
| 452 |
->status_is(403, 'Cannot delete other users macro with permission'); |
452 |
->status_is(403, 'Cannot delete other users macro with permission'); |
| 453 |
|
453 |
|
| 454 |
$macro_2->shared(1)->store(); |
454 |
$macro_2->shared(1)->store(); |
| 455 |
|
455 |
|
| 456 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared/$macro_2_id") |
456 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared/$macro_2_id") |
| 457 |
->status_is(403, 'Cannot delete other users shared macro without permission'); |
457 |
->status_is(403, 'Cannot delete other users shared macro without permission'); |
| 458 |
|
458 |
|
| 459 |
$builder->build({ |
459 |
$builder->build({ |
|
Lines 464-472
subtest 'delete() tests' => sub {
Link Here
|
| 464 |
code => 'delete_shared_macros', |
464 |
code => 'delete_shared_macros', |
| 465 |
}, |
465 |
}, |
| 466 |
}); |
466 |
}); |
| 467 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/$macro_2_id") |
467 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/$macro_2_id") |
| 468 |
->status_is(403, 'Cannot delete other users shared macro with permission on private endpoint'); |
468 |
->status_is(403, 'Cannot delete other users shared macro with permission on private endpoint'); |
| 469 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advancededitormacros/shared/$macro_2_id") |
469 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/advanced_editor/macros/shared/$macro_2_id") |
| 470 |
->status_is(200, 'Can delete other users shared macro with permission'); |
470 |
->status_is(200, 'Can delete other users shared macro with permission'); |
| 471 |
|
471 |
|
| 472 |
}; |
472 |
}; |
| 473 |
- |
|
|