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

(-)a/t/db_dependent/Auth.t (-2 / +31 lines)
Lines 38-44 $schema->storage->txn_begin; Link Here
38
38
39
subtest 'checkauth() tests' => sub {
39
subtest 'checkauth() tests' => sub {
40
40
41
    plan tests => 3;
41
    plan tests => 4;
42
42
43
    my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } });
43
    my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } });
44
44
Lines 78-83 subtest 'checkauth() tests' => sub { Link Here
78
    # FIXME This belongs to t/db_dependent/Auth/haspermission.t but we do not want to c/p the pervious mock statements
78
    # FIXME This belongs to t/db_dependent/Auth/haspermission.t but we do not want to c/p the pervious mock statements
79
    ok( !$is_allowed, 'DB user should not have any permissions');
79
    ok( !$is_allowed, 'DB user should not have any permissions');
80
80
81
    subtest 'Prevent authentication when sending credential via GET' => sub {
82
83
        plan tests => 2;
84
85
        my $patron = $builder->build_object(
86
            { class => 'Koha::Patrons', value => { flags => 1 } } );
87
        my $password = 'password';
88
        t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
89
        $patron->set_password( { password => $password } );
90
        $cgi = Test::MockObject->new();
91
        $cgi->mock( 'cookie', sub { return; } );
92
        $cgi->mock(
93
            'param',
94
            sub {
95
                my ( $self, $param ) = @_;
96
                if    ( $param eq 'userid' )   { return $patron->userid; }
97
                elsif ( $param eq 'password' ) { return $password; }
98
                else                           { return; }
99
            }
100
        );
101
102
        $cgi->mock( 'request_method', sub { return 'POST' } );
103
        ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' );
104
        is( $userid, $patron->userid, 'If librarian user is used and password with POST, they should be logged in' );
105
106
        $cgi->mock( 'request_method', sub { return 'GET' } );
107
        ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' );
108
        is( $userid, undef, 'If librarian user is used and password with GET, they should not be logged in' );
109
    };
110
81
    C4::Context->_new_userenv; # For next tests
111
    C4::Context->_new_userenv; # For next tests
82
112
83
};
113
};
84
- 

Return to bug 21325