s3: torture: adjust SMB1 cli_splice() test sizes
[Samba.git] / python / samba / tests / samba_tool / provision_password_check.py
blobb24e5804072e5f38f77f80756113e761909dba2b
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Catalyst IT Ltd. 2017
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 from samba.tests.samba_tool.base import SambaToolCmdTest
19 import os
20 import shutil
22 class ProvisionPasswordTestCase(SambaToolCmdTest):
23 """Test for password validation in domain provision subcommand"""
25 def setUp(self):
26 super(SambaToolCmdTest, self).setUp()
27 self.tempsambadir = os.path.join(self.tempdir, "samba")
28 os.mkdir(self.tempsambadir)
30 def _provision_with_password(self, password):
31 return self.runsubcmd(
32 "domain", "provision", "--realm=foo.example.com", "--domain=FOO",
33 "--targetdir=%s" % self.tempsambadir, "--adminpass=%s" % password,
34 "--use-ntvfs")
36 def test_short_and_low_quality(self):
37 (result, out, err) = self._provision_with_password("foo")
38 self.assertCmdFail(result)
40 def test_short(self):
41 (result, out, err) = self._provision_with_password("Fo0!_9")
42 self.assertCmdFail(result)
43 self.assertRegexpMatches(err, r"minimum password length")
45 def test_low_quality(self):
46 (result, out, err) = self._provision_with_password("aaaaaaaaaaaaaaaaa")
47 self.assertCmdFail(result)
48 self.assertRegexpMatches(err, r"quality standards")
50 def test_good(self):
51 (result, out, err) = self._provision_with_password("Fo0!_9.")
52 self.assertCmdSuccess(result, out, err)
54 def tearDown(self):
55 super(SambaToolCmdTest, self).tearDown()
56 shutil.rmtree(self.tempsambadir)