1 # Unix SMB/CIFS implementation.
3 # Copyright (C) David Mulder <dmulder@samba.org> 2020
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 Confirm that net_s3.join_member works
25 from samba
.net_s3
import Net
as s3_Net
26 from samba
.credentials
import DONT_USE_KERBEROS
27 from samba
.samba3
import param
as s3param
28 from samba
import WERRORError
32 for f
in os
.listdir(rmdir
):
33 if os
.path
.isdir(os
.path
.join(rmdir
, f
)):
34 rm(os
.path
.join(rmdir
, f
))
35 os
.rmdir(os
.path
.join(rmdir
, f
))
37 os
.unlink(os
.path
.join(rmdir
, f
))
39 class NetS3JoinTests(samba
.tests
.TestCaseInTempDir
):
42 super(NetS3JoinTests
, self
).setUp()
43 self
.realm
= os
.environ
["REALM"]
44 self
.domain
= os
.environ
["DOMAIN"]
45 self
.server
= os
.environ
["SERVER"]
46 self
.lp
= self
.get_loadparm()
49 super(NetS3JoinTests
, self
).tearDown()
51 def test_net_join(self
):
52 netbios_name
= "S3NetJoinTest"
53 machinepass
= "abcdefghij"
54 creds
= self
.insta_creds(template
=self
.get_credentials(),
55 kerberos_state
=DONT_USE_KERBEROS
)
56 s3_lp
= s3param
.get_context()
57 s3_lp
.load(self
.lp
.configfile
)
59 s3_lp
.set('realm', self
.realm
)
60 s3_lp
.set('workgroup', self
.domain
)
61 s3_lp
.set("private dir", self
.tempdir
)
62 s3_lp
.set("lock dir", self
.tempdir
)
63 s3_lp
.set("state directory", self
.tempdir
)
64 s3_lp
.set('server role', 'member server')
65 net
= s3_Net(creds
, s3_lp
, server
=self
.server
)
68 (domain_sid
, domain_name
) = net
.join_member(netbios_name
,
69 machinepass
=machinepass
)
70 except WERRORError
as e
:
71 self
.fail('Join failed: %s' % e
.args
[1])
76 except WERRORError
as e
:
77 self
.fail('Leave failed: %s' % e
.args
[1])
79 self
.assertTrue(ret
, 'Leave failed!')