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