View | Details | Raw Unified | Return to bug 28320
Collapse All | Expand All

(-)a/C4/SIP/Sip/MsgType.pm (+5 lines)
Lines 18-23 use Data::Dumper; Link Here
18
use CGI qw ( -utf8 );
18
use CGI qw ( -utf8 );
19
use C4::Auth qw(&check_api_auth);
19
use C4::Auth qw(&check_api_auth);
20
20
21
use Koha::Patrons;
21
use Koha::Patron::Attributes;
22
use Koha::Patron::Attributes;
22
use Koha::Items;
23
use Koha::Items;
23
24
Lines 1584-1596 my @message_type_names = ( Link Here
1584
1585
1585
sub send_acs_status {
1586
sub send_acs_status {
1586
    my ( $self, $server, $screen_msg, $print_line ) = @_;
1587
    my ( $self, $server, $screen_msg, $print_line ) = @_;
1588
1587
    my $msg = ACS_STATUS;
1589
    my $msg = ACS_STATUS;
1588
    ($server) or die "send_acs_status error: no \$server argument received";
1590
    ($server) or die "send_acs_status error: no \$server argument received";
1589
    my $account = $server->{account} or die "send_acs_status error: no 'account' in \$server object:\n" . Dumper($server);
1591
    my $account = $server->{account} or die "send_acs_status error: no 'account' in \$server object:\n" . Dumper($server);
1590
    my $policy  = $server->{policy}  or die "send_acs_status error: no 'policy' in \$server object:\n" . Dumper($server);
1592
    my $policy  = $server->{policy}  or die "send_acs_status error: no 'policy' in \$server object:\n" . Dumper($server);
1591
    my $ils     = $server->{ils}     or die "send_acs_status error: no 'ils' in \$server object:\n" . Dumper($server);
1593
    my $ils     = $server->{ils}     or die "send_acs_status error: no 'ils' in \$server object:\n" . Dumper($server);
1594
    my $sip_username = $server->{sip_username} or die "send_acs_status error: no 'sip_username' in \$server object:\n" . Dumper($server);
1592
    my ( $online_status,    $checkin_ok, $checkout_ok, $ACS_renewal_policy );
1595
    my ( $online_status,    $checkin_ok, $checkout_ok, $ACS_renewal_policy );
1593
    my ( $status_update_ok, $offline_ok, $timeout,     $retries );
1596
    my ( $status_update_ok, $offline_ok, $timeout,     $retries );
1597
    my $sip_user = Koha::Patrons->find({ userid => $sip_username });
1598
    die "send_acs_status error: sip_username cannot be found in DB or DB cannot be reached" unless $sip_user;
1594
1599
1595
    $online_status      = 'Y';
1600
    $online_status      = 'Y';
1596
    $checkout_ok        = sipbool( $ils->checkout_ok );
1601
    $checkout_ok        = sipbool( $ils->checkout_ok );
(-)a/misc/sip_cli_emulator.pl (+13 lines)
Lines 127-132 my $handlers = { Link Here
127
            location_code  => $location_code,
127
            location_code  => $location_code,
128
        },
128
        },
129
    },
129
    },
130
    sc_status_request => {
131
        name       => 'SC Status',
132
        subroutine => \&build_sc_status_command_message,
133
        parameters => {
134
        },
135
    },
130
    patron_status_request => {
136
    patron_status_request => {
131
        name       => 'Patron Status Request',
137
        name       => 'Patron Status Request',
132
        subroutine => \&build_patron_status_request_command_message,
138
        subroutine => \&build_patron_status_request_command_message,
Lines 362-367 sub build_login_command_message { Link Here
362
      . build_field( FID_LOCATION_CODE, $location_code );
368
      . build_field( FID_LOCATION_CODE, $location_code );
363
}
369
}
364
370
371
sub build_sc_status_command_message {
372
    my ($params) = @_;
373
374
    return SC_STATUS . "0" . "030" . "2.00";
375
}
376
365
sub build_patron_status_request_command_message {
377
sub build_patron_status_request_command_message {
366
    my ($params) = @_;
378
    my ($params) = @_;
367
379
Lines 653-658 Options: Link Here
653
    item_information
665
    item_information
654
    patron_information
666
    patron_information
655
    patron_status_request
667
    patron_status_request
668
    sc_status_request
656
    renew
669
    renew
657
/
670
/
658
}
671
}
(-)a/t/db_dependent/SIP/Message.t (-2 / +40 lines)
Lines 21-27 Link Here
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use Test::More tests => 10;
24
use Test::More tests => 11;
25
use Test::Exception;
25
use Test::MockObject;
26
use Test::MockObject;
26
use Test::MockModule;
27
use Test::MockModule;
27
use Test::Warn;
28
use Test::Warn;
Lines 337-342 subtest 'Patron info summary > 5 should not crash server' => sub { Link Here
337
    $schema->storage->txn_rollback;
338
    $schema->storage->txn_rollback;
338
};
339
};
339
340
341
subtest 'SC status tests' => sub {
342
343
    my $schema = Koha::Database->new->schema;
344
    $schema->storage->txn_begin;
345
346
    plan tests => 2;
347
348
    my $builder = t::lib::TestBuilder->new();
349
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
350
    my $sip_user = $builder->build_object({ class => "Koha::Patrons" });
351
352
    my ( $response, $findpatron );
353
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
354
    my $mockILS = $mocks->{ils};
355
    $mockILS->mock( 'checkout_ok', sub {1} );
356
    $mockILS->mock( 'checkin_ok', sub {1} );
357
    $mockILS->mock( 'status_update_ok', sub {1} );
358
    $mockILS->mock( 'offline_ok', sub {1} );
359
    $mockILS->mock( 'supports', sub {1} );
360
    my $server = Test::MockObject->new();
361
    $server->mock( 'get_timeout', sub {'100'});
362
    $server->{ils} = $mockILS;
363
    $server->{sip_username} = $sip_user->userid;
364
    $server->{account} = {};
365
    $server->{policy} = { renewal =>1,retries=>'000'};
366
367
    my $siprequest = SC_STATUS . '0' . '030' . '2.00';
368
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
369
    $msg->handle_sc_status( $server );
370
371
    like( $response, qr/98YYYYYY100000[0-9 ]{19}.00AO|BXYYYYYYYYYYYYYYYY|/, 'At least we got a response.' );
372
373
    $sip_user->delete;
374
375
    dies_ok{ $msg->handle_sc_status( $server ) } ,"Dies if sip user cannot be found";
376
377
};
378
340
# Here is room for some more subtests
379
# Here is room for some more subtests
341
380
342
# END of main code
381
# END of main code
343
- 

Return to bug 28320