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
):
43 self
.realm
= os
.environ
["REALM"]
44 self
.domain
= os
.environ
["DOMAIN"]
45 self
.server
= os
.environ
["SERVER"]
46 self
.lp
= self
.get_loadparm()
48 def test_net_join(self
):
49 netbios_name
= "S3NetJoinTest"
50 machinepass
= "abcdefghij"
51 creds
= self
.insta_creds(template
=self
.get_credentials(),
52 kerberos_state
=DONT_USE_KERBEROS
)
53 s3_lp
= s3param
.get_context()
54 s3_lp
.load(self
.lp
.configfile
)
56 s3_lp
.set('realm', self
.realm
)
57 s3_lp
.set('workgroup', self
.domain
)
58 s3_lp
.set("private dir", self
.tempdir
)
59 s3_lp
.set("lock dir", self
.tempdir
)
60 s3_lp
.set("state directory", self
.tempdir
)
61 s3_lp
.set('server role', 'member server')
62 net
= s3_Net(creds
, s3_lp
, server
=self
.server
)
65 (domain_sid
, domain_name
) = net
.join_member(netbios_name
,
66 machinepass
=machinepass
)
67 except WERRORError
as e
:
68 self
.fail('Join failed: %s' % e
.args
[1])
73 except WERRORError
as e
:
74 self
.fail('Leave failed: %s' % e
.args
[1])
76 self
.assertTrue(ret
, 'Leave failed!')