forked from jpatokal/openflights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetpw.php
60 lines (49 loc) · 1.65 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
<?php
include_once(dirname(__FILE__) . '/config.php');
//
// Test cases for help/resetpw.php
//
$challenge = "";
class ResetPwInvalidRequestLinkTest extends WebTestCase {
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 {
function test() {
global $webroot, $settings, $challenge;
$reset = array('email' => $settings['email'],
'unittest' => 'true');
$msg = $this->post($webroot . "help/resetpw.php", $reset);
$this->assertText('http://openflights.org/help/resetpw?user=' . $settings['name']);
$chunks = explode("***", $msg);
$challenge = $chunks[1];
}
}
class ResetPwInvalidChallengeTest extends WebTestCase {
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 {
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 = preg_split("<b>", $msg);
$pw = substr($chunks[1], 0, 8);
$result = login($this, $settings["name"], $pw);
$this->assertEqual($result->status, "0");
}
}
?>