Bug 20115: Remove sort on rfc4646_subtag in OPAC templates
[koha.git] / t / NorwegianPatronDB.t
blobec630203d65c44b96ac4f90b5e931087fd354974
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
19 use Test::More;
20 use Test::MockModule;
21 use t::lib::Mocks;
22 use Data::Dumper;
24 # Check that all the modules we need are installed, or bail out
25 BEGIN {
26 my $missing_lib;
27 eval {
28 require Test::DBIx::Class;
30 } or do {
31 $missing_lib = "Test::DBIx::Class";
34 eval {
35 require SOAP::Lite;
37 } or do {
38 $missing_lib = "SOAP::Lite";
41 eval {
42 require Crypt::GCrypt;
44 } or do {
45 $missing_lib = "Crypt::GCrypt";
48 eval {
49 require Convert::BaseN;
51 } or do {
52 $missing_lib = "Convert::BaseN";
55 if ( $missing_lib ) {
56 plan skip_all => $missing_lib . " is not available.";
57 } else {
58 # Everything good
59 plan tests => 73;
63 use Test::DBIx::Class {}, 'Borrower', 'BorrowerSync'; #Also loads those modules.
65 # Make the code in the module use our mocked Koha::Schema/Koha::Database
66 my $db = Test::MockModule->new('Koha::Database');
67 $db->mock(
68 # Schema() gives us the DB connection set up by Test::DBIx::Class
69 _new_schema => sub { return Schema(); }
72 fixtures_ok [
73 'Borrower' => [
74 [qw/firstname surname borrowernumber address city/],
75 ['Test', 'Borrower', 1, 'Test road', 'Test city'],
76 ['Test', 'Borrower', 2, 'Test road', 'Test city'],
77 ['Test', 'Borrower', 3, 'Test road', 'Test city'],
78 ['Test', 'Borrower', 4, 'Test road', 'Test city'],
80 'BorrowerSync' => [
81 [qw/borrowernumber sync syncstatus lastsync hashed_pin synctype/],
82 [1, 1, 'new', '2014-03-31T12:35:14', 'abc', 'norwegianpatrondb' ],
83 [2, 1, 'edited', '2014-03-31T12:35:14', 'abc', 'norwegianpatrondb' ],
84 [3, 1, 'new', '2014-03-31T12:35:14', 'abc', 'norwegianpatrondb' ],
85 [4, 1, 'new', '2014-03-31T12:35:14', 'abc', 'norwegianpatrondb' ],
87 ], 'installed some fixtures';
89 =head1 LOADING THE MODULE
91 =cut
93 BEGIN { use_ok( 'Koha::NorwegianPatronDB', ':all' ) }
96 =head1 UTILITY SUBROUTINES
98 =head2 NLCheckSysprefs
100 Relevant sysprefs:
102 =over 4
104 =item * NorwegianPatronDBEnable
106 =item * NorwegianPatronDBEndpoint
108 =item * NorwegianPatronDBUsername
110 =item * NorwegianPatronDBPassword
112 =back
114 =cut
116 BEGIN {
117 t::lib::Mocks::mock_config('nlkey', 'key');
118 t::lib::Mocks::mock_config('nlvendoruser', 'user');
119 t::lib::Mocks::mock_config('nlvendorpass', 'pass');
121 t::lib::Mocks::mock_preference('NorwegianPatronDBEnable', 0);
122 t::lib::Mocks::mock_preference('NorwegianPatronDBEndpoint', '');
123 t::lib::Mocks::mock_preference('NorwegianPatronDBUsername', '');
124 t::lib::Mocks::mock_preference('NorwegianPatronDBPassword', '');
126 ok( my $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' );
127 is( $result->{ 'error' }, 1, 'error detected' );
128 is( $result->{ 'nlenabled' }, 0, 'NL is not enabled' );
129 is( $result->{ 'endpoint' }, 0, 'an endpoint is not specified' );
130 is( $result->{ 'userpass' }, 0, 'username and/or password is missing' );
132 t::lib::Mocks::mock_preference('NorwegianPatronDBEnable', 1);
133 ok( $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' );
134 is( $result->{ 'error' }, 1, 'error detected' );
135 is( $result->{ 'nlenabled' }, 1, 'NL is enabled' );
136 is( $result->{ 'endpoint' }, 0, 'an endpoint is not specified' );
137 is( $result->{ 'userpass' }, 0, 'username and/or password is missing' );
139 t::lib::Mocks::mock_preference('NorwegianPatronDBEnable', 0);
140 t::lib::Mocks::mock_preference('NorwegianPatronDBUsername', 'user');
141 t::lib::Mocks::mock_preference('NorwegianPatronDBPassword', 'pass');
142 ok( $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' );
143 is( $result->{ 'error' }, 1, 'error detected' );
144 is( $result->{ 'nlenabled' }, 0, 'NL is not enabled' );
145 is( $result->{ 'endpoint' }, 0, 'an endpoint is not specified' );
146 is( $result->{ 'userpass' }, 1, 'username and/or password is present' );
148 t::lib::Mocks::mock_preference('NorwegianPatronDBEnable', 1);
149 t::lib::Mocks::mock_preference('NorwegianPatronDBEndpoint', 'http://example.com/');
150 ok( $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' );
151 is( $result->{ 'error' }, 0, 'no error detected' );
152 is( $result->{ 'nlenabled' }, 1, 'NL is enabled' );
153 is( $result->{ 'endpoint' }, 1, 'an endpoint is specified' );
154 is( $result->{ 'userpass' }, 1, 'username and/or password is present' );
156 =head2 NLGetFirstname and NLGetSurname
158 =cut
160 my $firstname = 'Firstname';
161 my $surname = 'Surname';
162 my $fullname = "$surname, $firstname";
163 my $wrongname = "$surname $firstname";
165 is( NLGetFirstname( $fullname ), $firstname, 'can get firstname from name' );
166 is( NLGetSurname( $fullname ), $surname, 'can get surname from name' );
167 is( NLGetFirstname( $wrongname ), $wrongname, 'returns full string when name misses comma' );
168 is( NLGetSurname( $wrongname ), $wrongname, 'returns full string when name misses comma' );
170 =head2 NLDecodePin and NLEncryptPIN
172 =cut
174 my $pin = '1234';
175 my $hash = NLEncryptPIN( $pin );
177 is( NLEncryptPIN( $pin ), $hash, 'NLEncryptPIN works' );
178 is( NLDecodePin( $hash ), $pin, 'NLDecodePin works' );
180 =head2 NLUpdateHashedPIN
182 =cut
184 is ( BorrowerSync->find({ 'borrowernumber' => 1 })->get_column('hashed_pin'), 'abc', 'hashed_pin is "abc"' );
185 # Set a new pin
186 my $new_pin = 'bcd';
187 ok( NLUpdateHashedPIN( 1, $new_pin ), 'NLUpdateHashedPIN runs ok' );
188 # Hash the new pin and compare it to the one stored in the database
189 my $hashed_pin = Koha::NorwegianPatronDB::_encrypt_pin( $new_pin );
190 is ( BorrowerSync->find({ 'borrowernumber' => 1 })->get_column('hashed_pin'), $hashed_pin, 'hashed_pin was updated' );
192 =head2 NLMarkForDeletion
194 =cut
196 is ( BorrowerSync->find({ 'borrowernumber' => 3 })->get_column('syncstatus'), 'new', 'syncstatus is "new"' );
197 ok( NLMarkForDeletion( 3 ), 'NLMarkForDeletion runs ok' );
198 # Check that the syncstatus was updated. Note: We will use this status later, to check syncing of deleted borrowers
199 is ( BorrowerSync->find({ 'borrowernumber' => 3 })->get_column('syncstatus'), 'delete', 'syncstatus is "delete"' );
201 =head2 NLGetSyncDataFromBorrowernumber
203 =cut
205 ok( my $sync_data = NLGetSyncDataFromBorrowernumber( 1 ), 'NLGetSyncDataFromBorrowernumber runs ok' );
206 isa_ok( $sync_data, 'Koha::Schema::Result::BorrowerSync' );
207 is( $sync_data->sync, 1, 'the sync is on' );
208 is( $sync_data->syncstatus, 'new', 'syncstatus is "new"' );
209 is( $sync_data->lastsync, '2014-03-31T12:35:14', 'lastsync is ok' );
210 is( $sync_data->hashed_pin, $hashed_pin, 'hashed_pin is ok' );
212 =head1 SUBROUTINES THAT TALK TO SOAP
214 =head2 NLSearch
216 =cut
218 my $lite = Test::MockModule->new('SOAP::Lite');
220 # Mock a successfull call to the "hent" method
221 $lite->mock(
222 hent => sub { return SOAP::Deserializer->deserialize( hent_success() )->result; }
224 ok( my $res = NLSearch( '12345678910' ), 'successfull call to NLSearch' );
225 is( $res->{'antall_poster_returnert'}, 1, 'got 1 record' );
226 isa_ok( $res, "Resultat" );
227 isa_ok( $res->{'respons_poster'}, "LaanerListe" );
228 isa_ok( $res->{'respons_poster'}[0], "Laaner" );
230 # Mock an unsuccessfull call to the "hent" method
231 $lite->mock(
232 hent => sub { return SOAP::Deserializer->deserialize( hent_failure() )->result; }
234 ok( $res = NLSearch( '12345678910' ), 'call to NLSearch with an illegal argument' );
235 is( $res->{'antall_poster_returnert'}, 0, 'got 0 records' );
236 isa_ok( $res, "Resultat" );
237 like( $res->{'melding'}, qr/Ulovlig argument: hverken LNR eller FNR_HASH/, "got expected error message for an illegal identifier" );
239 =head2 NLSync
241 =head3 New patron
243 =cut
245 my $borrower = Borrower->find({ 'borrowernumber' => 1 });
246 $lite->mock(
247 nyPost => sub { return SOAP::Deserializer->deserialize( nyPost_success() )->result; }
249 is ( BorrowerSync->find({ 'borrowernumber' => 1 })->get_column('syncstatus'), 'new', 'patron is new' );
250 ok ( $result = NLSync({ 'patron' => $borrower }), 'successfull call to NLSync via patron ("nyPost")' );
251 is ( BorrowerSync->find({ 'borrowernumber' => 1 })->get_column('syncstatus'), 'synced', 'patron is synced' );
253 # Now do the same test, but pass in a borrowernumber, not a Koha::Schema::Result::Borrower
254 is ( BorrowerSync->find({ 'borrowernumber' => 4 })->get_column('syncstatus'), 'new', 'patron is new' );
255 ok ( $result = NLSync({ 'borrowernumber' => 4 }), 'successfull call to NLSync via borrowernumber ("nyPost")' );
256 is ( BorrowerSync->find({ 'borrowernumber' => 4 })->get_column('syncstatus'), 'synced', 'patron is synced' );
258 =head3 Edited patron
260 =cut
262 ok ( $borrower = Borrower->find({ 'borrowernumber' => 2 }), 'find our "edited" mock patron' );
263 $lite->mock(
264 endre => sub { return SOAP::Deserializer->deserialize( endre_success() )->result; }
266 is ( BorrowerSync->find({ 'borrowernumber' => 2 })->get_column('syncstatus'), 'edited', 'patron is edited' );
267 ok ( $result = NLSync({ 'patron' => $borrower }), 'successfull call to NLSync ("endre")' );
268 is ( BorrowerSync->find({ 'borrowernumber' => 2 })->get_column('syncstatus'), 'synced', 'patron is synced' );
270 =head3 Deleted patron
272 =cut
274 ok ( $borrower = Borrower->find({ 'borrowernumber' => 3 }), 'find our "deleted" mock patron' );
275 $lite->mock(
276 slett => sub { return SOAP::Deserializer->deserialize( endre_success() )->result; }
278 is ( BorrowerSync->find({ 'borrowernumber' => 3 })->get_column('syncstatus'), 'delete', 'patron is marked for deletion' );
279 ok ( $result = NLSync({ 'patron' => $borrower }), 'successfull call to NLSync ("slett")' );
280 is ( BorrowerSync->find({ 'borrowernumber' => 3 })->get_column('sync'), 0, 'sync is now disabled' );
282 =head2 NLGetChanged
284 =cut
286 # Mock a successfull call to the "soekEndret" method
287 $lite->mock(
288 soekEndret => sub { return SOAP::Deserializer->deserialize( soekEndret_success() ); }
290 ok( $res = NLGetChanged(), 'successfull call to NLGetChanged - 2 results' );
291 is( $res->{'melding'}, 'OK', 'got "OK"' );
292 is( $res->{'antall_poster_returnert'}, 2, 'got 2 records' );
293 isa_ok( $res, "Resultat" );
294 isa_ok( $res->{'respons_poster'}, "LaanerListe" );
295 isa_ok( $res->{'respons_poster'}[0], "Laaner" );
298 # Mock a successfull call to the "soekEndret" method, but with zero new records
299 $lite->mock(
300 soekEndret => sub { return SOAP::Deserializer->deserialize( soekEndret_zero_new() ); }
302 ok( $res = NLGetChanged(), 'successfull call to NLGetChanged - 0 results' );
303 is( $res->{'melding'}, 'ingen treff', 'got "ingen treff"' );
304 is( $res->{'antall_poster_returnert'}, 0, 'got 0 records' );
305 is( $res->{'antall_treff'}, 0, 'got 0 records' );
307 =head1 SAMPLE SOAP XML RESPONSES
309 These responses can be gathered by setting "outputxml()" to true on the SOAP
310 client:
312 my $client = SOAP::Lite
313 ->on_action( sub { return '""';})
314 ->uri('http://lanekortet.no')
315 ->proxy('https://fl.lanekortet.no/laanekort/fl_test.php')
316 ->outputxml(1);
317 my $response = $client->slett( $x );
318 say $response;
320 Pretty formatting can be achieved by piping the output from a test script
321 through xmllint:
323 perl my_test_script.pl > xmllint --format -
325 =cut
327 sub slett_success {
329 return <<'ENDRESPONSE';
330 <?xml version="1.0" encoding="UTF-8"?>
331 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://lanekortet.no" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
332 <SOAP-ENV:Body>
333 <ns1:slettResponse>
334 <return xsi:type="ns1:Svar">
335 <status xsi:type="xsd:boolean">true</status>
336 <melding xsi:type="xsd:string">Test Testersen (1973-08-11) er slettet fra registeret</melding>
337 <lnr xsi:type="xsd:string">N000106188</lnr>
338 <server_tid xsi:type="xsd:string">2014-06-02T16:51:58</server_tid>
339 </return>
340 </ns1:slettResponse>
341 </SOAP-ENV:Body>
342 </SOAP-ENV:Envelope>
343 ENDRESPONSE
347 sub endre_success {
349 return <<'ENDRESPONSE';
350 <?xml version="1.0" encoding="UTF-8"?>
351 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://lanekortet.no" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
352 <SOAP-ENV:Body>
353 <ns1:endreResponse>
354 <return xsi:type="ns1:Svar">
355 <status xsi:type="xsd:boolean">true</status>
356 <melding xsi:type="xsd:string">Oppdaterte felt: navn, p_adresse1, p_postnr, p_sted, p_land, fdato, fnr_hash, kjonn, pin, sist_endret, sist_endret_av</melding>
357 <lnr xsi:type="xsd:string">N000106188</lnr>
358 <server_tid xsi:type="xsd:string">2014-06-02T16:42:32</server_tid>
359 </return>
360 </ns1:endreResponse>
361 </SOAP-ENV:Body>
362 </SOAP-ENV:Envelope>
363 ENDRESPONSE
367 sub nyPost_success {
369 return <<'ENDRESPONSE';
370 <?xml version="1.0" encoding="UTF-8"?>
371 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://lanekortet.no" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
372 <SOAP-ENV:Body>
373 <ns1:nyPostResponse>
374 <return xsi:type="ns1:Svar">
375 <status xsi:type="xsd:boolean">true</status>
376 <melding xsi:type="xsd:string">Ny post er opprettet</melding>
377 <lnr xsi:type="xsd:string">N000106188</lnr>
378 <server_tid xsi:type="xsd:string">2014-06-02T14:10:09</server_tid>
379 </return>
380 </ns1:nyPostResponse>
381 </SOAP-ENV:Body>
382 </SOAP-ENV:Envelope>
383 ENDRESPONSE
387 sub soekEndret_success {
389 return <<'ENDRESPONSE';
390 <?xml version="1.0" encoding="UTF-8"?>
391 <SOAP-ENV:Envelope
392 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
393 xmlns:ns1="http://lanekortet.no"
394 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
395 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
396 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
397 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
398 <SOAP-ENV:Body>
399 <ns1:soekEndretResponse>
400 <return xsi:type="ns1:Resultat">
401 <status xsi:type="xsd:boolean">true</status>
402 <melding xsi:type="xsd:string">OK</melding>
403 <antall_treff xsi:type="xsd:int">2</antall_treff>
404 <antall_poster_returnert xsi:type="xsd:int">2</antall_poster_returnert>
405 <neste_indeks xsi:type="xsd:int">0</neste_indeks>
406 <respons_poster SOAP-ENC:arrayType="ns1:Laaner[2]" xsi:type="ns1:LaanerListe">
407 <item xsi:type="ns1:Laaner">
408 <lnr xsi:type="xsd:string">N000106186</lnr>
409 <navn xsi:type="xsd:string">Hansen, Hanne</navn>
410 <p_adresse1 xsi:type="xsd:string"/>
411 <p_adresse2 xsi:type="xsd:string"/>
412 <p_postnr xsi:type="xsd:string"/>
413 <p_sted xsi:type="xsd:string">BØDØ</p_sted>
414 <p_land xsi:type="xsd:string">no</p_land>
415 <p_sjekk xsi:type="xsd:string">0</p_sjekk>
416 <m_adresse1 xsi:type="xsd:string"/>
417 <m_adresse2 xsi:type="xsd:string"/>
418 <m_postnr xsi:type="xsd:string"/>
419 <m_sted xsi:type="xsd:string"/>
420 <m_land xsi:type="xsd:string"/>
421 <m_sjekk xsi:type="xsd:string">0</m_sjekk>
422 <m_gyldig_til xsi:type="xsd:string">0000-00-00</m_gyldig_til>
423 <tlf_hjemme xsi:type="xsd:string"/>
424 <tlf_jobb xsi:type="xsd:string"/>
425 <tlf_mobil xsi:type="xsd:string"/>
426 <epost xsi:type="xsd:string"/>
427 <epost_sjekk xsi:type="xsd:string"/>
428 <prim_kontakt xsi:type="xsd:string"/>
429 <hjemmebibliotek xsi:type="xsd:string">5180401</hjemmebibliotek>
430 <fdato xsi:type="xsd:string">1994-04-08</fdato>
431 <fnr_hash xsi:type="xsd:string">11087395628</fnr_hash>
432 <kjonn xsi:type="xsd:string">F</kjonn>
433 <pin xsi:type="xsd:string">89308dfc85ee7a5826ae14e2d8efad1e</pin>
434 <passord xsi:type="xsd:string"/>
435 <feide xsi:type="xsd:string">0</feide>
436 <opprettet xsi:type="xsd:string">2014-04-28T15:20:38</opprettet>
437 <opprettet_av xsi:type="xsd:string">5180401</opprettet_av>
438 <sist_endret xsi:type="xsd:string">2014-04-28T15:20:38</sist_endret>
439 <sist_endret_av xsi:type="xsd:string">5180401</sist_endret_av>
440 <folkeregsjekk_dato xsi:type="xsd:string">0000-00-00</folkeregsjekk_dato>
441 </item>
442 <item xsi:type="ns1:Laaner">
443 <lnr xsi:type="xsd:string">N000106184</lnr>
444 <navn xsi:type="xsd:string">Enger, Magnus</navn>
445 <p_adresse1 xsi:type="xsd:string">Svarthammarveien 633333</p_adresse1>
446 <p_adresse2 xsi:type="xsd:string"/>
447 <p_postnr xsi:type="xsd:string">8015</p_postnr>
448 <p_sted xsi:type="xsd:string">Bodø</p_sted>
449 <p_land xsi:type="xsd:string">no</p_land>
450 <p_sjekk xsi:type="xsd:string">0</p_sjekk>
451 <m_adresse1 xsi:type="xsd:string"/>
452 <m_adresse2 xsi:type="xsd:string"/>
453 <m_postnr xsi:type="xsd:string"/>
454 <m_sted xsi:type="xsd:string"/>
455 <m_land xsi:type="xsd:string">no</m_land>
456 <m_sjekk xsi:type="xsd:string">0</m_sjekk>
457 <m_gyldig_til xsi:type="xsd:string">0000-00-00</m_gyldig_til>
458 <tlf_hjemme xsi:type="xsd:string">95158548</tlf_hjemme>
459 <tlf_jobb xsi:type="xsd:string"/>
460 <tlf_mobil xsi:type="xsd:string"/>
461 <epost xsi:type="xsd:string">magnus@enger.priv.no</epost>
462 <epost_sjekk xsi:type="xsd:string"/>
463 <prim_kontakt xsi:type="xsd:string"/>
464 <hjemmebibliotek xsi:type="xsd:string">5180401</hjemmebibliotek>
465 <fdato xsi:type="xsd:string">1973-08-11</fdato>
466 <fnr_hash xsi:type="xsd:string">11087345795</fnr_hash>
467 <kjonn xsi:type="xsd:string">M</kjonn>
468 <pin xsi:type="xsd:string">a632c504b8c4fba3149115cb07e0796c</pin>
469 <passord xsi:type="xsd:string"/>
470 <feide xsi:type="xsd:string">0</feide>
471 <opprettet xsi:type="xsd:string">2014-04-28T14:52:02</opprettet>
472 <opprettet_av xsi:type="xsd:string">5180401</opprettet_av>
473 <sist_endret xsi:type="xsd:string">2014-05-13T11:01:33</sist_endret>
474 <sist_endret_av xsi:type="xsd:string">5180401</sist_endret_av>
475 <folkeregsjekk_dato xsi:type="xsd:string">0000-00-00</folkeregsjekk_dato>
476 </item>
477 </respons_poster>
478 <server_tid xsi:type="xsd:string">2014-05-16T14:44:44</server_tid>
479 </return>
480 </ns1:soekEndretResponse>
481 </SOAP-ENV:Body>
482 </SOAP-ENV:Envelope>
483 ENDRESPONSE
486 sub soekEndret_zero_new {
487 return <<'ENDRESPONSE';
488 <?xml version="1.0" encoding="UTF-8"?>
489 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://lanekortet.no" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
490 <SOAP-ENV:Body>
491 <ns1:soekEndretResponse>
492 <return xsi:type="ns1:Resultat">
493 <status xsi:type="xsd:boolean">false</status>
494 <melding xsi:type="xsd:string">ingen treff</melding>
495 <antall_treff xsi:type="xsd:int">0</antall_treff>
496 <antall_poster_returnert xsi:type="xsd:int">0</antall_poster_returnert>
497 <neste_indeks xsi:type="xsd:int">0</neste_indeks>
498 <respons_poster SOAP-ENC:arrayType="ns1:Laaner[0]" xsi:type="ns1:LaanerListe"/>
499 <server_tid xsi:type="xsd:string">2014-05-20T13:02:02</server_tid>
500 </return>
501 </ns1:soekEndretResponse>
502 </SOAP-ENV:Body>
503 </SOAP-ENV:Envelope>
504 ENDRESPONSE
507 sub hent_failure {
508 return <<'ENDRESPONSE';
509 <?xml version="1.0" encoding="UTF-8"?>
510 <SOAP-ENV:Envelope
511 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
512 xmlns:ns1="http://lanekortet.no"
513 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
514 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
515 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
516 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
517 <SOAP-ENV:Body>
518 <ns1:hentResponse>
519 <return xsi:type="ns1:Resultat">
520 <status xsi:type="xsd:boolean">false</status>
521 <melding xsi:type="xsd:string">hent: Ulovlig argument: hverken LNR eller FNR_HASH</melding>
522 <antall_treff xsi:type="xsd:int">0</antall_treff>
523 <antall_poster_returnert xsi:type="xsd:int">0</antall_poster_returnert>
524 <neste_indeks xsi:type="xsd:int">0</neste_indeks>
525 <respons_poster SOAP-ENC:arrayType="ns1:Laaner[0]" xsi:type="ns1:LaanerListe"/>
526 <server_tid xsi:type="xsd:string">2014-05-15T10:56:24</server_tid>
527 </return>
528 </ns1:hentResponse>
529 </SOAP-ENV:Body>
530 </SOAP-ENV:Envelope>
531 ENDRESPONSE
535 sub hent_success {
537 return <<'ENDRESPONSE';
538 <?xml version="1.0" encoding="UTF-8"?>
539 <SOAP-ENV:Envelope
540 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
541 xmlns:ns1="http://lanekortet.no"
542 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
543 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
544 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
545 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
546 <SOAP-ENV:Body>
547 <ns1:hentResponse>
548 <return xsi:type="ns1:Resultat">
549 <status xsi:type="xsd:boolean">true</status>
550 <melding xsi:type="xsd:string">OK</melding>
551 <antall_treff xsi:type="xsd:int">1</antall_treff>
552 <antall_poster_returnert xsi:type="xsd:int">1</antall_poster_returnert>
553 <neste_indeks xsi:type="xsd:int">0</neste_indeks>
554 <respons_poster SOAP-ENC:arrayType="ns1:Laaner[1]" xsi:type="ns1:LaanerListe">
555 <item xsi:type="ns1:Laaner">
556 <lnr xsi:type="xsd:string">N000123456</lnr>
557 <navn xsi:type="xsd:string">Test, Testersen</navn>
558 <p_adresse1 xsi:type="xsd:string">Bibliotekveien 6</p_adresse1>
559 <p_adresse2 xsi:type="xsd:string"/>
560 <p_postnr xsi:type="xsd:string">1234</p_postnr>
561 <p_sted xsi:type="xsd:string">Lillevik</p_sted>
562 <p_land xsi:type="xsd:string">no</p_land>
563 <p_sjekk xsi:type="xsd:string">0</p_sjekk>
564 <m_adresse1 xsi:type="xsd:string"/>
565 <m_adresse2 xsi:type="xsd:string"/>
566 <m_postnr xsi:type="xsd:string"/>
567 <m_sted xsi:type="xsd:string"/>
568 <m_land xsi:type="xsd:string">no</m_land>
569 <m_sjekk xsi:type="xsd:string">0</m_sjekk>
570 <m_gyldig_til xsi:type="xsd:string">0000-00-00</m_gyldig_til>
571 <tlf_hjemme xsi:type="xsd:string"/>
572 <tlf_jobb xsi:type="xsd:string"/>
573 <tlf_mobil xsi:type="xsd:string">12345678</tlf_mobil>
574 <epost xsi:type="xsd:string">test@example.com</epost>
575 <epost_sjekk xsi:type="xsd:string">0</epost_sjekk>
576 <prim_kontakt xsi:type="xsd:string"/>
577 <hjemmebibliotek xsi:type="xsd:string">2060000</hjemmebibliotek>
578 <fdato xsi:type="xsd:string">1964-05-22</fdato>
579 <fnr_hash xsi:type="xsd:string">22056412345</fnr_hash>
580 <kjonn xsi:type="xsd:string">F</kjonn>
581 <pin xsi:type="xsd:string">g345abc123dab567abc78900abc123ab</pin>
582 <passord xsi:type="xsd:string"/>
583 <feide xsi:type="xsd:string"/>
584 <opprettet xsi:type="xsd:string">2005-10-20</opprettet>
585 <opprettet_av xsi:type="xsd:string">2060000</opprettet_av>
586 <sist_endret xsi:type="xsd:string">2013-05-13T13:51:24</sist_endret>
587 <sist_endret_av xsi:type="xsd:string">2060000</sist_endret_av>
588 <gyldig_til xsi:type="xsd:string"/>
589 <folkeregsjekk_dato xsi:type="xsd:string">0000-00-00</folkeregsjekk_dato>
590 </item>
591 </respons_poster>
592 <server_tid xsi:type="xsd:string">2014-01-07T14:43:18</server_tid>
593 </return>
594 </ns1:hentResponse>
595 </SOAP-ENV:Body>
596 </SOAP-ENV:Envelope>
597 ENDRESPONSE