Lines 20-26
use Modern::Perl;
Link Here
|
20 |
use utf8; |
20 |
use utf8; |
21 |
use Encode; |
21 |
use Encode; |
22 |
|
22 |
|
23 |
use Test::More tests => 1; |
23 |
use Test::More tests => 2; |
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Mojo; |
25 |
use Test::Mojo; |
26 |
use Test::Warn; |
26 |
use Test::Warn; |
Lines 108-112
subtest 'get() tests' => sub {
Link Here
|
108 |
->status_is(404) |
108 |
->status_is(404) |
109 |
->json_is( '/error', 'Object not found.' ); |
109 |
->json_is( '/error', 'Object not found.' ); |
110 |
|
110 |
|
|
|
111 |
$schema->storage->txn_rollback; |
112 |
}; |
113 |
|
114 |
subtest 'delete() tests' => sub { |
115 |
|
116 |
plan tests => 7; |
117 |
|
118 |
$schema->storage->txn_begin; |
119 |
|
120 |
my $patron = $builder->build_object( |
121 |
{ |
122 |
class => 'Koha::Patrons', |
123 |
value => { flags => 0 } # no permissions |
124 |
} |
125 |
); |
126 |
my $password = 'thePassword123'; |
127 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
128 |
my $userid = $patron->userid; |
129 |
|
130 |
my $authority = $builder->build_object({ 'class' => 'Koha::Authorities', value => { |
131 |
marcxml => q|<?xml version="1.0" encoding="UTF-8"?> |
132 |
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"> |
133 |
<controlfield tag="001">1001</controlfield> |
134 |
<datafield tag="110" ind1=" " ind2=" "> |
135 |
<subfield code="9">102</subfield> |
136 |
<subfield code="a">My Corporation</subfield> |
137 |
</datafield> |
138 |
</record>| |
139 |
} }); |
140 |
|
141 |
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid) |
142 |
->status_is(403, 'Not enough permissions makes it return the right code'); |
143 |
|
144 |
# Add permissions |
145 |
$builder->build( |
146 |
{ |
147 |
source => 'UserPermission', |
148 |
value => { |
149 |
borrowernumber => $patron->borrowernumber, |
150 |
module_bit => 9, |
151 |
code => 'edit_catalogue' |
152 |
} |
153 |
} |
154 |
); |
155 |
|
156 |
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid) |
157 |
->status_is(204, 'SWAGGER3.2.4') |
158 |
->content_is('', 'SWAGGER3.3.4'); |
159 |
|
160 |
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid) |
161 |
->status_is(404); |
162 |
|
111 |
$schema->storage->txn_rollback; |
163 |
$schema->storage->txn_rollback; |
112 |
}; |
164 |
}; |
113 |
- |
|
|