1 # Unix SMB/CIFS implementation.
3 # Copyright (C) Samuel Cabrero <scabrero@suse.de> 2018
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.
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.
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/>.
20 from subprocess import Popen, PIPE
21 from samba.tests.ntlm_auth_base import NTLMAuthTestCase
22 from samba.compat import get_string
24 class NTLMAuthHelpersTests(NTLMAuthTestCase):
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"]
32 def test_specified_domain(self):
33 """ ntlm_auth with specified domain """
39 ret = self.run_helper(client_username=username,
40 client_password=password,
42 server_username=username,
43 server_password=password,
45 server_use_winbind=False)
52 ret = self.run_helper(client_username=username,
53 client_password=password,
55 server_username=username,
56 server_password=password,
58 server_use_winbind=False)
61 def test_agaist_winbind(self):
62 """ ntlm_auth against winbindd """
64 ret = self.run_helper(client_username=self.username,
65 client_password=self.password,
66 client_domain=self.domain,
67 server_use_winbind=True)
70 def test_ntlmssp_gss_spnego(self):
71 """ ntlm_auth with NTLMSSP client and gss-spnego server """
77 ret = self.run_helper(client_username=username,
78 client_password=password,
80 server_username=username,
81 server_password=password,
83 client_helper="ntlmssp-client-1",
84 server_helper="gss-spnego",
85 server_use_winbind=False)
88 def test_gss_spnego(self):
89 """ ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server """
95 ret = self.run_helper(client_username=username,
96 client_password=password,
98 server_username=username,
99 server_password=password,
100 server_domain=domain,
101 client_helper="gss-spnego-client",
102 server_helper="gss-spnego",
103 server_use_winbind=False)
106 def test_gss_spnego_winbind(self):
107 """ ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server
110 ret = self.run_helper(client_username=self.username,
111 client_password=self.password,
112 client_domain=self.domain,
113 client_helper="gss-spnego-client",
114 server_helper="gss-spnego",
115 server_use_winbind=True)
118 def test_ntlmssp_gss_spnego_cached_creds(self):
119 """ ntlm_auth with NTLMSSP client and gss-spnego server against
120 winbind with cached credentials """
122 param = "--ccache-save=%s%s%s%%%s" % (self.domain,
123 self.winbind_separator,
126 cache_cmd = ["wbinfo",
128 self.check_exit_code(cache_cmd, 0)
130 ret = self.run_helper(client_username=self.username,
131 client_password=self.password,
132 client_domain=self.domain,
133 client_use_cached_creds=True,
134 client_helper="ntlmssp-client-1",
135 server_helper="gss-spnego",
136 server_use_winbind=True)