bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2005-2011 Canonical Ltd
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
2 |
# -*- coding: utf-8 -*-
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
3 |
#
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
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 |
#
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
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 |
#
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
17 |
|
18 |
||
1185.58.2
by John Arbash Meinel
Added mode to the appropriate transport functions, and tests to make sure they work. |
19 |
"""Tests for bzr setting permissions.
|
20 |
||
21 |
Files which are created underneath .bzr/ should inherit its permissions.
|
|
22 |
So if the directory is group writable, the files and subdirs should be as well.
|
|
23 |
||
24 |
In the future, when we have Repository/Branch/Checkout information, the
|
|
25 |
permissions should be inherited individually, rather than all be the same.
|
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
26 |
"""
|
27 |
||
1185.70.3
by Martin Pool
Various updates to make storage branch mergeable: |
28 |
# TODO: jam 20051215 There are no tests for ftp yet, because we have no ftp server
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
29 |
# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
|
1185.70.3
by Martin Pool
Various updates to make storage branch mergeable: |
30 |
# defined by the local umask. This isn't terrible, is it
|
31 |
# the truly desired behavior?
|
|
3638.3.6
by Vincent Ladeuil
Isolate group sticky bit related tests. |
32 |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
33 |
import os |
34 |
import sys |
|
35 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
36 |
from breezy import urlutils |
37 |
from breezy.branch import Branch |
|
38 |
from breezy.controldir import ControlDir |
|
39 |
from breezy.tests import TestCaseWithTransport, TestSkipped |
|
40 |
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer |
|
41 |
from breezy.workingtree import WorkingTree |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
42 |
|
43 |
||
44 |
def chmod_r(base, file_mode, dir_mode): |
|
45 |
"""Recursively chmod from a base directory""" |
|
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
46 |
os.chmod(base, dir_mode) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
47 |
for root, dirs, files in os.walk(base): |
48 |
for d in dirs: |
|
49 |
p = os.path.join(root, d) |
|
50 |
os.chmod(p, dir_mode) |
|
51 |
for f in files: |
|
52 |
p = os.path.join(root, f) |
|
53 |
os.chmod(p, file_mode) |
|
54 |
||
55 |
||
1185.58.7
by John Arbash Meinel
Added the ability to disable setting permissions |
56 |
def check_mode_r(test, base, file_mode, dir_mode, include_base=True): |
57 |
"""Check that all permissions match |
|
58 |
||
59 |
:param test: The TestCase being run
|
|
60 |
:param base: The path to the root directory to check
|
|
61 |
:param file_mode: The mode for all files
|
|
62 |
:param dir_mode: The mode for all directories
|
|
63 |
:param include_base: If false, only check the subdirectories
|
|
64 |
"""
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
65 |
t = test.get_transport() |
1185.58.7
by John Arbash Meinel
Added the ability to disable setting permissions |
66 |
if include_base: |
1530.1.21
by Robert Collins
Review feedback fixes. |
67 |
test.assertTransportMode(t, base, dir_mode) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
68 |
for root, dirs, files in os.walk(base): |
69 |
for d in dirs: |
|
6379.4.2
by Jelmer Vernooij
Add urlutils.quote / urlutils.unquote. |
70 |
p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [d]]) |
1530.1.21
by Robert Collins
Review feedback fixes. |
71 |
test.assertTransportMode(t, p, dir_mode) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
72 |
for f in files: |
73 |
p = os.path.join(root, f) |
|
6379.4.2
by Jelmer Vernooij
Add urlutils.quote / urlutils.unquote. |
74 |
p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [f]]) |
1530.1.21
by Robert Collins
Review feedback fixes. |
75 |
test.assertTransportMode(t, p, file_mode) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
76 |
|
1532
by Robert Collins
Merge in John Meinels integration branch. |
77 |
|
1534.4.28
by Robert Collins
first cut at merge from integration. |
78 |
class TestPermissions(TestCaseWithTransport): |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
79 |
|
80 |
def test_new_files(self): |
|
81 |
if sys.platform == 'win32': |
|
82 |
raise TestSkipped('chmod has no effect on win32') |
|
83 |
||
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. |
84 |
t = self.make_branch_and_tree('.') |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
85 |
b = t.branch |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
86 |
with open('a', 'wb') as f: |
87 |
f.write(b'foo\n') |
|
1910.2.32
by Aaron Bentley
Handle capital-letter file-ids |
88 |
# ensure check_mode_r works with capital-letter file-ids like TREE_ROOT
|
7045.1.20
by Jelmer Vernooij
Fix per_pack_repository tests. |
89 |
t.add('a', b'CAPS-ID') |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
90 |
t.commit('foo') |
91 |
||
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
92 |
chmod_r('.bzr', 0o644, 0o755) |
93 |
check_mode_r(self, '.bzr', 0o644, 0o755) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
94 |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
95 |
# although we are modifying the filesystem
|
96 |
# underneath the objects, they are not locked, and thus it must
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
97 |
# be safe for most operations. But here we want to observe a
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
98 |
# mode change in the control bits, which current do not refresh
|
99 |
# when a new lock is taken out.
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
100 |
t = WorkingTree.open('.') |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
101 |
b = t.branch |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
102 |
self.assertEqualMode(0o755, b.control_files._dir_mode) |
103 |
self.assertEqualMode(0o644, b.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
104 |
self.assertEqualMode(0o755, b.controldir._get_dir_mode()) |
105 |
self.assertEqualMode(0o644, b.controldir._get_file_mode()) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
106 |
|
107 |
# Modifying a file shouldn't break the permissions
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
108 |
with open('a', 'wb') as f: |
109 |
f.write(b'foo2\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
110 |
t.commit('foo2') |
111 |
# The mode should be maintained after commit
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
112 |
check_mode_r(self, '.bzr', 0o644, 0o755) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
113 |
|
114 |
# Adding a new file should maintain the permissions
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
115 |
with open('b', 'wb') as f: |
116 |
f.write(b'new b\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
117 |
t.add('b') |
118 |
t.commit('new b') |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
119 |
check_mode_r(self, '.bzr', 0o644, 0o755) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
120 |
|
121 |
# Recursively update the modes of all files
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
122 |
chmod_r('.bzr', 0o664, 0o775) |
123 |
check_mode_r(self, '.bzr', 0o664, 0o775) |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
124 |
t = WorkingTree.open('.') |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
125 |
b = t.branch |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
126 |
self.assertEqualMode(0o775, b.control_files._dir_mode) |
127 |
self.assertEqualMode(0o664, b.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
128 |
self.assertEqualMode(0o775, b.controldir._get_dir_mode()) |
129 |
self.assertEqualMode(0o664, b.controldir._get_file_mode()) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
130 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
131 |
with open('a', 'wb') as f: |
132 |
f.write(b'foo3\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
133 |
t.commit('foo3') |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
134 |
check_mode_r(self, '.bzr', 0o664, 0o775) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
135 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
136 |
with open('c', 'wb') as f: |
137 |
f.write(b'new c\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
138 |
t.add('c') |
139 |
t.commit('new c') |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
140 |
check_mode_r(self, '.bzr', 0o664, 0o775) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
141 |
|
3638.3.6
by Vincent Ladeuil
Isolate group sticky bit related tests. |
142 |
def test_new_files_group_sticky_bit(self): |
143 |
if sys.platform == 'win32': |
|
144 |
raise TestSkipped('chmod has no effect on win32') |
|
5688.2.1
by Jelmer Vernooij
Fix tests on Debian GNU/kFreeBSD by treating it like other FreeBSD-kernel-based systems. |
145 |
elif sys.platform == 'darwin' or 'freebsd' in sys.platform: |
146 |
# FreeBSD-based platforms create temp dirs with the 'wheel' group,
|
|
147 |
# which users are not likely to be in, and this prevents us from
|
|
148 |
# setting the sgid bit
|
|
3638.3.6
by Vincent Ladeuil
Isolate group sticky bit related tests. |
149 |
os.chown(self.test_dir, os.getuid(), os.getgid()) |
150 |
||
151 |
t = self.make_branch_and_tree('.') |
|
152 |
b = t.branch |
|
153 |
||
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
154 |
# Test the group sticky bit
|
155 |
# Recursively update the modes of all files
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
156 |
chmod_r('.bzr', 0o664, 0o2775) |
157 |
check_mode_r(self, '.bzr', 0o664, 0o2775) |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
158 |
t = WorkingTree.open('.') |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
159 |
b = t.branch |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
160 |
self.assertEqualMode(0o2775, b.control_files._dir_mode) |
161 |
self.assertEqualMode(0o664, b.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
162 |
self.assertEqualMode(0o2775, b.controldir._get_dir_mode()) |
163 |
self.assertEqualMode(0o664, b.controldir._get_file_mode()) |
|
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
164 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
165 |
with open('a', 'wb') as f: |
166 |
f.write(b'foo4\n') |
|
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
167 |
t.commit('foo4') |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
168 |
check_mode_r(self, '.bzr', 0o664, 0o2775) |
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
169 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
170 |
with open('d', 'wb') as f: |
171 |
f.write(b'new d\n') |
|
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
172 |
t.add('d') |
173 |
t.commit('new d') |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
174 |
check_mode_r(self, '.bzr', 0o664, 0o2775) |
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
175 |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
176 |
|
177 |
class TestSftpPermissions(TestCaseWithSFTPServer): |
|
178 |
||
179 |
def test_new_files(self): |
|
180 |
if sys.platform == 'win32': |
|
181 |
raise TestSkipped('chmod has no effect on win32') |
|
1185.58.2
by John Arbash Meinel
Added mode to the appropriate transport functions, and tests to make sure they work. |
182 |
# Though it would be nice to test that SFTP to a server
|
183 |
# which does support chmod has the right effect
|
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
184 |
|
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. |
185 |
# bodge around for stubsftpserver not letting use connect
|
186 |
# more than once
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
187 |
_t = self.get_transport() |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
188 |
|
189 |
os.mkdir('local') |
|
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. |
190 |
t_local = self.make_branch_and_tree('local') |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
191 |
b_local = t_local.branch |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
192 |
with open('local/a', 'wb') as f: |
193 |
f.write(b'foo\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
194 |
t_local.add('a') |
195 |
t_local.commit('foo') |
|
196 |
||
197 |
# Delete them because we are modifying the filesystem underneath them
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
198 |
chmod_r('local/.bzr', 0o644, 0o755) |
199 |
check_mode_r(self, 'local/.bzr', 0o644, 0o755) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
200 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
201 |
t = WorkingTree.open('local') |
1185.50.76
by John Arbash Meinel
[merge] robertc's integration branch: add BzrDir, and checkouts |
202 |
b_local = t.branch |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
203 |
self.assertEqualMode(0o755, b_local.control_files._dir_mode) |
204 |
self.assertEqualMode(0o644, b_local.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
205 |
self.assertEqualMode(0o755, b_local.controldir._get_dir_mode()) |
206 |
self.assertEqualMode(0o644, b_local.controldir._get_file_mode()) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
207 |
|
208 |
os.mkdir('sftp') |
|
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. |
209 |
sftp_url = self.get_url('sftp') |
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
210 |
b_sftp = ControlDir.create_branch_and_repo(sftp_url) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
211 |
|
212 |
b_sftp.pull(b_local) |
|
213 |
del b_sftp |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
214 |
chmod_r('sftp/.bzr', 0o644, 0o755) |
215 |
check_mode_r(self, 'sftp/.bzr', 0o644, 0o755) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
216 |
|
217 |
b_sftp = Branch.open(sftp_url) |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
218 |
self.assertEqualMode(0o755, b_sftp.control_files._dir_mode) |
219 |
self.assertEqualMode(0o644, b_sftp.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
220 |
self.assertEqualMode(0o755, b_sftp.controldir._get_dir_mode()) |
221 |
self.assertEqualMode(0o644, b_sftp.controldir._get_file_mode()) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
222 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
223 |
with open('local/a', 'wb') as f: |
224 |
f.write(b'foo2\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
225 |
t_local.commit('foo2') |
226 |
b_sftp.pull(b_local) |
|
227 |
# The mode should be maintained after commit
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
228 |
check_mode_r(self, 'sftp/.bzr', 0o644, 0o755) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
229 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
230 |
with open('local/b', 'wb') as f: |
231 |
f.write(b'new b\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
232 |
t_local.add('b') |
233 |
t_local.commit('new b') |
|
234 |
b_sftp.pull(b_local) |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
235 |
check_mode_r(self, 'sftp/.bzr', 0o644, 0o755) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
236 |
|
237 |
del b_sftp |
|
238 |
# Recursively update the modes of all files
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
239 |
chmod_r('sftp/.bzr', 0o664, 0o775) |
240 |
check_mode_r(self, 'sftp/.bzr', 0o664, 0o775) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
241 |
|
242 |
b_sftp = Branch.open(sftp_url) |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
243 |
self.assertEqualMode(0o775, b_sftp.control_files._dir_mode) |
244 |
self.assertEqualMode(0o664, b_sftp.control_files._file_mode) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
245 |
self.assertEqualMode(0o775, b_sftp.controldir._get_dir_mode()) |
246 |
self.assertEqualMode(0o664, b_sftp.controldir._get_file_mode()) |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
247 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
248 |
with open('local/a', 'wb') as f: |
249 |
f.write(b'foo3\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
250 |
t_local.commit('foo3') |
251 |
b_sftp.pull(b_local) |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
252 |
check_mode_r(self, 'sftp/.bzr', 0o664, 0o775) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
253 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
254 |
with open('local/c', 'wb') as f: |
255 |
f.write(b'new c\n') |
|
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
256 |
t_local.add('c') |
257 |
t_local.commit('new c') |
|
258 |
b_sftp.pull(b_local) |
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
259 |
check_mode_r(self, 'sftp/.bzr', 0o664, 0o775) |
1185.58.1
by John Arbash Meinel
Added new permissions test (currently don't pass) |
260 |
|
1185.58.10
by John Arbash Meinel
[patch] Robey Pointer to fix sftp server using umask for files (failing tests for directories) |
261 |
def test_sftp_server_modes(self): |
262 |
if sys.platform == 'win32': |
|
263 |
raise TestSkipped('chmod has no effect on win32') |
|
264 |
||
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
265 |
umask = 0o022 |
1185.58.10
by John Arbash Meinel
[patch] Robey Pointer to fix sftp server using umask for files (failing tests for directories) |
266 |
original_umask = os.umask(umask) |
267 |
||
268 |
try: |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
269 |
t = self.get_transport() |
1185.58.10
by John Arbash Meinel
[patch] Robey Pointer to fix sftp server using umask for files (failing tests for directories) |
270 |
# Direct access should be masked by umask
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
271 |
with t._sftp_open_exclusive('a', mode=0o666) as f: |
272 |
f.write(b'foo\n') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
273 |
self.assertTransportMode(t, 'a', 0o666 & ~umask) |
1185.58.10
by John Arbash Meinel
[patch] Robey Pointer to fix sftp server using umask for files (failing tests for directories) |
274 |
|
275 |
# but Transport overrides umask
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
276 |
t.put_bytes('b', b'txt', mode=0o666) |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
277 |
self.assertTransportMode(t, 'b', 0o666) |
278 |
||
279 |
t._get_sftp().mkdir('c', mode=0o777) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
280 |
self.assertTransportMode(t, 'c', 0o777 & ~umask) |
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
281 |
|
282 |
t.mkdir('d', mode=0o777) |
|
283 |
self.assertTransportMode(t, 'd', 0o777) |
|
1185.58.10
by John Arbash Meinel
[patch] Robey Pointer to fix sftp server using umask for files (failing tests for directories) |
284 |
finally: |
285 |
os.umask(original_umask) |