gpo: Enable user policy application
[samba.git] / python / samba / tests / gpo_member.py
1 # Unix SMB/CIFS implementation. Tests for smb manipulation
2 # Copyright (C) David Mulder <dmulder@suse.com> 2018
3 #
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.
8 #
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.
13 #
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/>.
16
17 import os
18 from samba import gpo, tests
19 from samba.gpclass import GPOStorage
20 from samba.param import LoadParm
21 from samba.credentials import Credentials
22 from samba.gp_sec_ext import gp_access_ext
23 import logging
24
25 class GPOTests(tests.TestCase):
26     def setUp(self):
27         super(GPOTests, self).setUp()
28         self.server = os.environ["SERVER"]
29         self.dc_account = self.server.upper() + '$'
30         self.lp = LoadParm()
31         self.lp.load_default()
32         self.creds = self.insta_creds(template=self.get_credentials())
33
34     def tearDown(self):
35         super(GPOTests, self).tearDown()
36
37     def test_sec_ext_load_on_member(self):
38         logger = logging.getLogger('gpo_tests')
39         cache_dir = self.lp.get('cache directory')
40         store = GPOStorage(os.path.join(cache_dir, 'gpo.tdb'))
41         try:
42             gp_access_ext(logger, self.lp, self.creds,
43                           self.creds.get_username(), store)
44         except Exception:
45             self.fail('Initializing gp_access_ext should not require ad-dc')