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

(-)a/t/db_dependent/Koha/REST/V1.t (-2 / +48 lines)
Lines 17-28 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 1;
20
use Test::More tests => 2;
21
use Test::Mojo;
21
use Test::Mojo;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
26
27
use Koha::ActionLogs;
28
use Koha::Database;
29
24
use JSON::Validator::OpenAPI::Mojolicious;
30
use JSON::Validator::OpenAPI::Mojolicious;
25
31
32
my $builder = t::lib::TestBuilder->new;
33
my $schema  = Koha::Database->new->schema;
34
35
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
36
37
my $t = Test::Mojo->new('Koha::REST::V1');
38
26
subtest 'Type definition tests' => sub {
39
subtest 'Type definition tests' => sub {
27
40
28
    plan tests => 4;
41
    plan tests => 4;
Lines 42-44 subtest 'Type definition tests' => sub { Link Here
42
    is( $types->type('mij'),  'application/marc-in-json', 'application/marc-in-json is defined' );
55
    is( $types->type('mij'),  'application/marc-in-json', 'application/marc-in-json is defined' );
43
    is( $types->type('marc'), 'application/marc',         'application/marc is defined' );
56
    is( $types->type('marc'), 'application/marc',         'application/marc is defined' );
44
};
57
};
45
- 
58
59
subtest 'logging with the right interface' => sub {
60
61
    plan tests => 4;
62
63
    $schema->storage->txn_begin;
64
65
    my $user     = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } );
66
    my $userid   = $user->userid;
67
    my $password = 'thisIsaPassword!234';
68
    $user->set_password( { password => $password, skip_validation => 1 } );
69
70
    # create a known patron
71
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
72
73
    # Make changes to the patron through the API
74
    $t->put_ok(
75
        "//$userid:$password@/api/v1/patrons/"
76
            . $patron->borrowernumber => json => {
77
            surname     => 'This is a new firstname',
78
            address     => 'An address',
79
            city        => $patron->city,
80
            library_id  => $patron->branchcode,
81
            category_id => $patron->categorycode
82
            }
83
    )->status_is(200);
84
85
    my $log = Koha::ActionLogs->search(
86
        { module => 'MEMBERS', action => 'MODIFY', object => $patron->borrowernumber } )->next;
87
    is( $log->interface, 'api', 'Interface correctly logged' );
88
    is( $log->user, $user->borrowernumber, 'User correctly logged' );
89
90
    $schema->storage->txn_rollback;
91
};

Return to bug 18205