samba python tests: convert 'except X, e' to 'except X as e'
[samba.git] / python / samba / tests / pam_winbind.py
1 # Unix SMB/CIFS implementation.
2 #
3 # Copyright (C) 2017      Andreas Schneider <asn@samba.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18
19 import samba.tests
20 import pypamtest
21 import os
22
23 class SimplePamTests(samba.tests.TestCase):
24     def test_authenticate(self):
25         domain = os.environ["DOMAIN"]
26         username = os.environ["USERNAME"]
27         password = os.environ["PASSWORD"]
28         unix_username = "%s/%s" % (domain, username)
29         expected_rc = 0 # PAM_SUCCESS
30
31         tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
32         res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
33
34         self.assertTrue(res != None)
35
36     def test_authenticate_error(self):
37         domain = os.environ["DOMAIN"]
38         username = os.environ["USERNAME"]
39         password = "WrongPassword"
40         unix_username = "%s/%s" % (domain, username)
41         expected_rc = 7 # PAM_AUTH_ERR
42
43         tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
44         res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
45
46         self.assertTrue(res != None)