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

(-)a/Koha/REST/V1/Patrons/Password.pm (-1 / +1 lines)
Lines 108-114 sub set_public { Link Here
108
108
109
    my $old_password = $body->{old_password};
109
    my $old_password = $body->{old_password};
110
    my $password     = $body->{password};
110
    my $password     = $body->{password};
111
    my $password_2   = $body->{password_2};
111
    my $password_2   = $body->{password_repeated};
112
112
113
    unless ( $password eq $password_2 ) {
113
    unless ( $password eq $password_2 ) {
114
        return $c->render( status => 400, openapi => { error => "Passwords don't match" } );
114
        return $c->render( status => 400, openapi => { error => "Passwords don't match" } );
(-)a/api/v1/swagger/paths/public_patrons.json (-2 / +2 lines)
Lines 21-27 Link Here
21
                "description": "New password (plain text)",
21
                "description": "New password (plain text)",
22
                "type": "string"
22
                "type": "string"
23
              },
23
              },
24
              "password_2": {
24
              "password_repeated": {
25
                "description": "Repeated new password (plain text)",
25
                "description": "Repeated new password (plain text)",
26
                "type": "string"
26
                "type": "string"
27
              },
27
              },
Lines 30-36 Link Here
30
                "type": "string"
30
                "type": "string"
31
              }
31
              }
32
            },
32
            },
33
            "required": ["password", "password_2", "old_password"]
33
            "required": ["password", "password_repeated", "old_password"]
34
          }
34
          }
35
        }
35
        }
36
      ],
36
      ],
(-)a/t/db_dependent/api/v1/patrons_password.t (-16 / +40 lines)
Lines 139-148 subtest 'set_public() (unprivileged user tests)' => sub { Link Here
139
139
140
    my $new_password = 'abc';
140
    my $new_password = 'abc';
141
141
142
    my $tx
142
    my $tx = $t->ua->build_tx(
143
        = $t->ua->build_tx( POST => "/api/v1/public/patrons/"
143
              POST => "/api/v1/public/patrons/"
144
            . $other_patron->id
144
            . $other_patron->id
145
            . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'blah' } );
145
            . "/password" => json => {
146
            password          => $new_password,
147
            password_repeated => $new_password,
148
            old_password      => 'blah'
149
            }
150
    );
146
151
147
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
152
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
148
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
153
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
Lines 156-165 subtest 'set_public() (unprivileged user tests)' => sub { Link Here
156
161
157
    my $password = 'holapassword';
162
    my $password = 'holapassword';
158
    $patron->set_password( $password );
163
    $patron->set_password( $password );
159
    $tx
164
    $tx = $t->ua->build_tx(
160
        = $t->ua->build_tx( POST => "/api/v1/public/patrons/"
165
              POST => "/api/v1/public/patrons/"
161
            . $other_patron->id
166
            . $other_patron->id
162
            . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } );
167
            . "/password" => json => {
168
            password          => $new_password,
169
            password_repeated => $new_password,
170
            old_password      => $password
171
            }
172
    );
163
173
164
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
174
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
165
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
175
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
Lines 169-178 subtest 'set_public() (unprivileged user tests)' => sub { Link Here
169
          error => "Changing other patron's password is forbidden"
179
          error => "Changing other patron's password is forbidden"
170
        });
180
        });
171
181
172
    $tx
182
    $tx = $t->ua->build_tx(
173
        = $t->ua->build_tx( POST => "/api/v1/public/patrons/"
183
              POST => "/api/v1/public/patrons/"
174
            . $patron->id
184
            . $patron->id
175
            . "/password" => json => { password => $new_password, password_2 => 'wrong_password', old_password => $password } );
185
            . "/password" => json => {
186
            password          => $new_password,
187
            password_repeated => 'wrong_password',
188
            old_password      => $password
189
            }
190
    );
176
191
177
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
192
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
178
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
193
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
Lines 182-191 subtest 'set_public() (unprivileged user tests)' => sub { Link Here
182
          error => "Passwords don't match"
197
          error => "Passwords don't match"
183
        });
198
        });
184
199
185
    $tx
200
    $tx = $t->ua->build_tx(
186
        = $t->ua->build_tx( POST => "/api/v1/public/patrons/"
201
              POST => "/api/v1/public/patrons/"
187
            . $patron->id
202
            . $patron->id
188
            . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => 'badpassword' } );
203
            . "/password" => json => {
204
            password          => $new_password,
205
            password_repeated => $new_password,
206
            old_password      => 'badpassword'
207
            }
208
    );
189
209
190
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
210
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
191
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
211
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
Lines 195-204 subtest 'set_public() (unprivileged user tests)' => sub { Link Here
195
          error => "Invalid password"
215
          error => "Invalid password"
196
        });
216
        });
197
217
198
    $tx
218
    $tx = $t->ua->build_tx(
199
        = $t->ua->build_tx( POST => "/api/v1/public/patrons/"
219
              POST => "/api/v1/public/patrons/"
200
            . $patron->id
220
            . $patron->id
201
            . "/password" => json => { password => $new_password, password_2 => $new_password, old_password => $password } );
221
            . "/password" => json => {
222
            password          => $new_password,
223
            password_repeated => $new_password,
224
            old_password      => $password
225
            }
226
    );
202
227
203
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
228
    $tx->req->cookies( { name => 'CGISESSID', value => $session->id } );
204
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
229
    $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } );
205
- 

Return to bug 22061