3206a27e6789b84ca493166518468989936685f6
[nivanova/samba-autobuild/.git] / source4 / scripting / python / samba / tests / dcerpc / srvsvc.py
1 # -*- coding: utf-8 -*-
2 #
3 # Unix SMB/CIFS implementation.
4 # Copyright © Dhananjay Sathe <dhanajaysathe@gmail.com> 2011
5 # Copyright © Jelmer Vernooij <jelmer@samba.org> 2011
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 """Tests for samba.dcerpc.srvsvc."""
22
23 from samba.dcerpc import srvsvc
24 from samba.tests import RpcInterfaceTestCase
25
26
27 class SrvsvcTests(RpcInterfaceTestCase):
28
29     def setUp(self):
30         super(SrvsvcTests, self).setUp()
31         self.conn = srvsvc.srvsvc("ncalrpc:", self.get_loadparm())
32         self.server_unc = "\\\\."
33
34     def getDummyShareObject(self):
35         share = srvsvc.NetShareInfo2()
36
37         share.name = u'test'
38         share.comment = u'test share'
39         share.type = srvsvc.STYPE_DISKTREE
40         share.current_users = 0x00000000
41         share.max_users = -1
42         share.password = None
43         share.path = u'C:\\tmp' # some random path
44         share.permissions = 123434566
45         return share
46
47     def test_NetShareAdd(self):
48         self.skip("Dangerous test")
49         share = self.getDummyShareObject()
50         self.conn.NetShareAdd(self.server_unc, 2, share, None)
51
52     def test_NetShareSetInfo(self):
53         self.skip("Dangerous test")
54         share = self.getDummyShareObject()
55         parm_error = 0x00000000
56         self.conn.NetShareAdd(self.server_unc, 502, share, parm_error)
57         name = share.name
58         share.comment = "now sucessfully modified "
59         parm_error = self.pipe.NetShareSetInfo(self.server_unc, name,
60                 502, share, parm_error)
61
62     def test_NetShareDel(self):
63         self.skip("Dangerous test")
64         share = self.getDummyShareObject()
65         parm_error = 0x00000000
66         self.expectFailure("NetShareAdd doesn't work properly from Python",
67             self.conn.NetShareAdd, self.server_unc, 502, share, parm_error)
68         self.conn.NetShareDel(self.server_unc, share.name, 0)