Passed
Push — develop ( db5506...7ff7f1 )
by Felipe
06:26 queued 02:43
created

SecurityTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 108
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
/**
3
 * Function area: Common manipulation
4
 * Sub function area: Security
5
 *
6
 * @author     Augmentum SpikeSource Team 
7
 * @copyright  2005 by Augmentum, Inc.
8
 */
9
 
10
// Import the precondition class.
11
if(is_dir('../Public')) 
12
{
13
    require_once('../Public/SetPrecondition.php');
14
}
15
16
/**
17
 * This class is to test the security management.
18
 * It includes login/logout and modify password.
19
 */
20
class SecurityTest extends PreconditionSet 
21
{
22
    // Declare the member variables for the invalid username/password.
23
    private $_invalidUserName = 'invalidusername';
24
    private $_invalidPassword = 'invalidpassword';
25
    
26
    function setUp()
27
    {  
28
        return TRUE;
29
    }
30
    
31
    
32
    function tearDown()
33
    {        
34
        return TRUE;
35
    }
36
   
37
   
38
    /*
39
     * TestCaseID: CSM01
40
     * Test to login with special user name.
41
     */
42
    function testSpecialLogin() 
43
    {
44
        global $webUrl;
45
        global $NORMAL_USER_NAME;
46
        global $lang;
47
        
48
        // Login with special user name "postgres".
49
        $this->login('postgres', $this->_invalidPassword, "$webUrl/login.php");
50
        
51
        // Verify the error messages.
52
        $this->assertWantedText($lang['strlogindisallowed']);
53
		$this->assertWantedText($lang['strviewfaq']);
54
        // Login with special user name "postgres".
55
        $this->login($NORMAL_USER_NAME, '', "$webUrl/login.php");
56
        
57
        // Verify the error messages.
58
        $this->assertWantedText($lang['strlogindisallowed']);
59
        $this->assertWantedText($lang['strviewfaq']);
60
        
61
        return TRUE;
62
    }
63
    
64
    
65
    /*
66
     * TestCaseID: CSM02
67
     * Test to login with invalid user name or password.
68
     */
69
    function testInvalidLogin() 
70
    {
71
        global $webUrl;
72
        global $SUPER_USER_NAME;
73
        global $lang;
74
        
75
        // Login with invalid user name.
76
        $this->login($this->_invalidUserName, $this->_invalidPassword, "$webUrl/login.php");
77
        
78
        // Verify the error messages.
79
        $this->assertWantedText($lang['strloginfailed']);
80
        
81
        // Login with valid username and invalid password.
82
        $this->login($SUPER_USER_NAME, $this->_invalidPassword, "$webUrl/login.php");
83
        
84
        // Verify the error messages.
85
        $this->assertWantedText($lang['strloginfailed']);
86
        
87
        return TRUE;
88
    }
89
    
90
    
91
    /*
92
     * TestCaseID: CSM03
93
     * Test to change the current user's password.
94
     */
95
    function testAccount() 
96
    {
97
        global $webUrl;
98
        global $NORMAL_USER_NAME;
99
        global $NORMAL_USER_PASSWORD;
100
        global $lang, $SERVER;
101
        $newpassword = 'newpassword';
102
        
103
        $this->login($NORMAL_USER_NAME, $NORMAL_USER_PASSWORD, "$webUrl/login.php");
104
        
105
        // Turn to the account page and change the password page.
106
        $this->assertTrue($this->get("$webUrl/users.php", array('server' => $SERVER, 'action' => 'account')));
107
        $this->assertTrue($this->clickLink($lang['strchangepassword']));
108
       
109
        // Enter the new password and different confirm password.
110
        $this->assertTrue($this->setField('password', $newpassword));
111
        $this->assertTrue($this->setField('confirm', $this->_invalidPassword));
112
       
113
        // Then submit and verify the error messages.
114
        $this->assertTrue($this->clickSubmit($lang['strok']));
115
        $this->assertWantedText($lang['strpasswordconfirm']);
116
        
117
        // Enter the new password and confirm password.
118
        $this->assertTrue($this->setField('password', $NORMAL_USER_PASSWORD));
119
        $this->assertTrue($this->setField('confirm', $NORMAL_USER_PASSWORD));
120
       
121
        // Then submit and verify the messages.
122
        $this->assertTrue($this->clickSubmit($lang['strok']));
123
        $this->assertWantedText($lang['strpasswordchanged']);
124
        
125
        $this->logout();
126
        
127
        return TRUE;
128
    }
129
130
}
131
?>
132