-
Notifications
You must be signed in to change notification settings - Fork 399
/
Copy pathresetpw.php
68 lines (56 loc) · 1.89 KB
/
resetpw.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
include_once dirname(__FILE__) . '/config.php';
//
// Test cases for help/resetpw.php
//
$challenge = "";
class ResetPwInvalidRequestLinkTest extends WebTestCase {
public function test() {
global $webroot, $settings;
$reset = array(
'email' => $settings['email'] . "invalid",
'unittest' => 'true'
);
$msg = $this->post($webroot . "help/resetpw.php", $reset);
$this->assertText('Sorry, that e-mail address is not registered');
}
}
class ResetPwValidRequestLinkTest extends WebTestCase {
public function test() {
global $webroot, $settings, $challenge;
$reset = array(
'email' => $settings['email'],
'unittest' => 'true'
);
$msg = $this->post($webroot . "help/resetpw.php", $reset);
$this->assertText('https://openflights.org/help/resetpw?user=' . $settings['name']);
$chunks = explode("***", $msg);
$challenge = $chunks[1];
}
}
class ResetPwInvalidChallengeTest extends WebTestCase {
public function test() {
global $webroot, $settings, $challenge;
$reset = array(
'user' => $settings['name'],
'challenge' => $challenge . "XXX"
);
$msg = $this->get($webroot . "help/resetpw.php", $reset);
$this->assertText('Invalid challenge');
}
}
class ResetPwValidChallengeTest extends WebTestCase {
public function test() {
global $webroot, $settings, $challenge;
$reset = array(
'user' => $settings['name'],
'challenge' => $challenge
);
$msg = $this->get($webroot . "help/resetpw.php", $reset);
$this->assertText('Your new password');
$chunks = explode("b", $msg);
$pw = substr($chunks[1], 0, 8);
$result = login($this, $settings["name"], $pw);
$this->assertEqual($result->status, "0");
}
}