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 => 2; |
23 |
use Test::More tests => 3; |
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 160-164
subtest 'delete() tests' => sub {
Link Here
|
160 |
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid) |
160 |
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid) |
161 |
->status_is(404); |
161 |
->status_is(404); |
162 |
|
162 |
|
|
|
163 |
$schema->storage->txn_rollback; |
164 |
}; |
165 |
|
166 |
subtest 'post() tests' => sub { |
167 |
|
168 |
plan tests => 14; |
169 |
|
170 |
$schema->storage->txn_begin; |
171 |
|
172 |
Koha::Authorities->delete; |
173 |
|
174 |
my $patron = $builder->build_object( |
175 |
{ |
176 |
class => 'Koha::Patrons', |
177 |
value => { flags => 0 } # no permissions |
178 |
} |
179 |
); |
180 |
my $password = 'thePassword123'; |
181 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
182 |
my $userid = $patron->userid; |
183 |
|
184 |
my $marcxml = q|<?xml version="1.0" encoding="UTF-8"?> |
185 |
<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"> |
186 |
<controlfield tag="001">1001</controlfield> |
187 |
<datafield tag="110" ind1=" " ind2=" "> |
188 |
<subfield code="9">102</subfield> |
189 |
<subfield code="a">My Corporation</subfield> |
190 |
</datafield> |
191 |
</record>|; |
192 |
|
193 |
my $mij = '{"fields":[{"001":"1001"},{"110":{"subfields":[{"9":"102"},{"a":"My Corporation"}],"ind1":" ","ind2":" "}}],"leader":" "}'; |
194 |
my $marc = '00079 2200049 45000010005000001100024000051001 9102aMy Corporation'; |
195 |
my $json = { |
196 |
authtypecode => "CORPO_NAME", |
197 |
marcxml => $marcxml |
198 |
}; |
199 |
|
200 |
$t->post_ok("//$userid:$password@/api/v1/authorities") |
201 |
->status_is(403, 'Not enough permissions makes it return the right code'); |
202 |
|
203 |
# Add permissions |
204 |
$builder->build( |
205 |
{ |
206 |
source => 'UserPermission', |
207 |
value => { |
208 |
borrowernumber => $patron->borrowernumber, |
209 |
module_bit => 9, |
210 |
code => 'edit_catalogue' |
211 |
} |
212 |
} |
213 |
); |
214 |
|
215 |
$t->post_ok("//$userid:$password@/api/v1/authorities" => json => $json) |
216 |
->status_is(200) |
217 |
->json_has('/id'); |
218 |
|
219 |
$t->post_ok("//$userid:$password@/api/v1/authorities" => {'Content-Type' => 'application/marcxml+xml', authority_type => 'CORPO_NAME'} => $marcxml) |
220 |
->status_is(200) |
221 |
->json_has('/id'); |
222 |
|
223 |
$t->post_ok("//$userid:$password@/api/v1/authorities" => {'Content-Type' => 'application/marc-in-json', authority_type => 'CORPO_NAME'} => $mij) |
224 |
->status_is(200) |
225 |
->json_has('/id'); |
226 |
|
227 |
$t->post_ok("//$userid:$password@/api/v1/authorities" => {'Content-Type' => 'application/marc', authority_type => 'CORPO_NAME'} => $marc) |
228 |
->status_is(200) |
229 |
->json_has('/id'); |
230 |
|
163 |
$schema->storage->txn_rollback; |
231 |
$schema->storage->txn_rollback; |
164 |
}; |
232 |
}; |
165 |
- |
|
|