s3:ntlm_auth: make logs more consistent with length check
[Samba.git] / python / samba / tests / password_test.py
blobba9f0655f73dec2019b667eafd2615c88aa56b87
1 # -*- coding: utf-8 -*-
3 # Common functionality for all password change tests
5 # Copyright (C) Andrew Bartlett <abartlet@samba.org> 2018
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import samba.tests
24 class PasswordCommon:
26 @staticmethod
27 def allow_password_changes(testcase, samdb):
28 """Updates the DC to allow password changes during the current test"""
30 # Get the old "dSHeuristics" if it was set
31 dsheuristics = samdb.get_dsheuristics()
33 # Reset the "dSHeuristics" as they were before
34 testcase.addCleanup(samdb.set_dsheuristics, dsheuristics)
36 # Set the "dSHeuristics" to activate the correct "userPassword" behaviour
37 samdb.set_dsheuristics("000000001")
39 # Get the old "minPwdAge"
40 minPwdAge = samdb.get_minPwdAge()
42 # Reset the "minPwdAge" as it was before
43 testcase.addCleanup(samdb.set_minPwdAge, minPwdAge)
45 # Set it temporarily to "0"
46 samdb.set_minPwdAge("0")
49 class PasswordTestCase(samba.tests.TestCase):
51 # this requires that an LDB connection has already been setup (so is not
52 # part of the inherited setUp())
53 def allow_password_changes(self, samdb=None):
54 """Updates the DC to allow password changes during the current test"""
56 if samdb is None:
57 samdb = self.ldb
59 PasswordCommon.allow_password_changes(self, samdb)