14
14
# limitations under the License.
15
15
16
16
import mock
17
- import unittest2
17
+ import unittest
18
18
19
19
from st2auth_pam_backend import pam_backend
20
20
21
21
22
- class PAMBackendAuthenticationTest (unittest2 .TestCase ):
22
+ class PAMBackendAuthenticationTest (unittest .TestCase ):
23
23
@mock .patch ('os.geteuid' )
24
24
def test_non_root_user (self , mock_get_euid ):
25
25
# non root
26
26
mock_get_euid .return_value = 100
27
27
28
28
expected_msg = 'st2auth process needs to run as "root"'
29
- self .assertRaisesRegexp (ValueError , expected_msg ,
29
+ self .assertRaisesRegex (ValueError , expected_msg ,
30
30
pam_backend .PAMAuthenticationBackend )
31
31
32
32
# non root, but check for root is disabled
@@ -37,16 +37,14 @@ def test_non_root_user(self, mock_get_euid):
37
37
mock_get_euid .return_value = 0
38
38
pam_backend .PAMAuthenticationBackend ()
39
39
40
- # See scrips/travis/ prepare-integration.sh for right username + password.
40
+ # See scrips/prepare-integration.sh for right username + password.
41
41
@mock .patch ('os.geteuid' , mock .Mock (return_value = 0 ))
42
42
def test_good_password (self ):
43
43
pam = pam_backend .PAMAuthenticationBackend ()
44
- self .assertEqual (pam .authenticate ('pammer' , 'spammer' ), True ,
45
- 'Valid credentials should return True.' )
44
+ assert pam .authenticate ('pammer' , 'spammer' ), 'Valid credentials should return True.'
46
45
47
- # See scrips/travis/ prepare-integration.sh for right username + password.
46
+ # See scrips/prepare-integration.sh for right username + password.
48
47
@mock .patch ('os.geteuid' , mock .Mock (return_value = 0 ))
49
48
def test_bad_password (self ):
50
49
pam = pam_backend .PAMAuthenticationBackend ()
51
- self .assertEqual (pam .authenticate ('pammer' , 'oumpalumpa' ), False ,
52
- 'Invalid credentials should return False.' )
50
+ assert not pam .authenticate ('pammer' , 'oumpalumpa' ), 'Invalid credentials should return False.'
0 commit comments