2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2005 Canonical Ltd
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
2 |
# -*- coding: utf-8 -*-
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
3 |
#
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
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 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
8 |
#
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
13 |
#
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
14 |
# You should have received a copy of the GNU General Public License
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
||
19 |
"""Tests for bzr setting permissions.
|
|
20 |
||
21 |
Files in the branch control directory (.bzr or .bzr/branch) should inherit
|
|
22 |
the .bzr directory permissions.
|
|
23 |
So if the directory is group writable, the files and subdirs should be as well.
|
|
24 |
"""
|
|
25 |
||
26 |
# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
|
|
27 |
# defined by the local umask. This isn't terrible, is it
|
|
28 |
# the truly desired behavior?
|
|
29 |
||
30 |
import os |
|
31 |
import sys |
|
32 |
import stat |
|
33 |
from StringIO import StringIO |
|
34 |
||
35 |
from bzrlib.branch import Branch |
|
36 |
from bzrlib.bzrdir import BzrDir |
|
37 |
from bzrlib.lockable_files import LockableFiles |
|
2018.5.99
by Andrew Bennetts
Don't test mode setting for remote branches because they don't do mode setting. |
38 |
from bzrlib.remote import RemoteBranchFormat |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
39 |
from bzrlib.tests import TestCaseWithTransport, TestSkipped |
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
40 |
from bzrlib.tests.test_permissions import chmod_r, check_mode_r |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
41 |
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer |
42 |
from bzrlib.transport import get_transport |
|
43 |
from bzrlib.workingtree import WorkingTree |
|
44 |
||
45 |
||
46 |
class TestPermissions(TestCaseWithTransport): |
|
47 |
||
48 |
def test_new_branch(self): |
|
2018.5.99
by Andrew Bennetts
Don't test mode setting for remote branches because they don't do mode setting. |
49 |
if isinstance(self.branch_format, RemoteBranchFormat): |
50 |
# Remote branch format have no permission logic in them; there's
|
|
51 |
# nothing to test here.
|
|
52 |
return
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
53 |
if sys.platform == 'win32': |
54 |
raise TestSkipped('chmod has no effect on win32') |
|
55 |
# also, these are BzrBranch format specific things..
|
|
56 |
os.mkdir('a') |
|
57 |
mode = stat.S_IMODE(os.stat('a').st_mode) |
|
58 |
t = self.make_branch_and_tree('.') |
|
59 |
b = t.branch |
|
60 |
self.assertEqualMode(mode, b.control_files._dir_mode) |
|
61 |
self.assertEqualMode(mode & ~07111, b.control_files._file_mode) |
|
62 |
||
63 |
os.mkdir('b') |
|
64 |
os.chmod('b', 02777) |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
65 |
b = self.make_branch('b') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
66 |
self.assertEqualMode(02777, b.control_files._dir_mode) |
67 |
self.assertEqualMode(00666, b.control_files._file_mode) |
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
68 |
check_mode_r(self, 'b/.bzr', 00666, 02777) |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
69 |
|
70 |
os.mkdir('c') |
|
71 |
os.chmod('c', 02750) |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
72 |
b = self.make_branch('c') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
73 |
self.assertEqualMode(02750, b.control_files._dir_mode) |
74 |
self.assertEqualMode(00640, b.control_files._file_mode) |
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
75 |
check_mode_r(self, 'c/.bzr', 00640, 02750) |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
76 |
|
77 |
os.mkdir('d') |
|
78 |
os.chmod('d', 0700) |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
79 |
b = self.make_branch('d') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
80 |
self.assertEqualMode(0700, b.control_files._dir_mode) |
81 |
self.assertEqualMode(0600, b.control_files._file_mode) |
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
82 |
check_mode_r(self, 'd/.bzr', 00600, 00700) |