Passed
Pull Request — develop (#92)
by Felipe
06:21
created

SecurityTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {        
34
        return TRUE;
35
    }
36
   
37
   
38
    /*
39
     * TestCaseID: CSM01
40
     * Test to login with special user name.
41
     */
42
    function testSpecialLogin() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
132