4bfb37e7a554c5be639a91836f664c2e02b0e3e4
[samba.git] / python / samba / tests / ntlm_auth.py
1 # Unix SMB/CIFS implementation.
2 #
3 # Copyright (C) Samuel Cabrero <scabrero@suse.de> 2018
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 os
20 from subprocess import Popen, PIPE
21 from samba.tests.ntlm_auth_base import NTLMAuthTestCase
22 from samba.compat import get_string
23
24 class NTLMAuthHelpersTests(NTLMAuthTestCase):
25
26     def setUp(self):
27         super(NTLMAuthHelpersTests, self).setUp()
28         self.username = os.environ["DC_USERNAME"]
29         self.password = os.environ["DC_PASSWORD"]
30         self.domain = os.environ["DOMAIN"]
31
32     def test_specified_domain(self):
33         """ ntlm_auth with specified domain """
34
35         username = "foo"
36         password = "secret"
37         domain = "FOO"
38
39         ret = self.run_helper(client_username=username,
40                               client_password=password,
41                               client_domain=domain,
42                               server_username=username,
43                               server_password=password,
44                               server_domain=domain,
45                               server_use_winbind=False)
46         self.assertTrue(ret)
47
48         username = "foo"
49         password = "secret"
50         domain = "fOo"
51
52         ret = self.run_helper(client_username=username,
53                               client_password=password,
54                               client_domain=domain,
55                               server_username=username,
56                               server_password=password,
57                               server_domain=domain,
58                               server_use_winbind=False)
59         self.assertTrue(ret)
60
61     def test_agaist_winbind(self):
62         """ ntlm_auth against winbindd """
63
64         ret = self.run_helper(client_username=self.username,
65                               client_password=self.password,
66                               client_domain=self.domain,
67                               server_use_winbind=True)
68         self.assertTrue(ret)