807
808
self.assertEqualBzrdirs([baz, foo, bar],
808
809
bzrdir.BzrDir.find_bzrdirs(transport))
811
def make_fake_permission_denied_transport(self, transport, paths):
812
"""Create a transport that raises PermissionDenied for some paths."""
815
raise errors.PermissionDenied(path)
817
path_filter_server = pathfilter.PathFilteringServer(transport, filter)
818
path_filter_server.start_server()
819
self.addCleanup(path_filter_server.stop_server)
820
path_filter_transport = pathfilter.PathFilteringTransport(
821
path_filter_server, '.')
822
return (path_filter_server, path_filter_transport)
824
def assertBranchUrlsEndWith(self, expect_url_suffix, actual_bzrdirs):
825
"""Check that each branch url ends with the given suffix."""
826
for actual_bzrdir in actual_bzrdirs:
827
self.assertEndsWith(actual_bzrdir.user_url, expect_url_suffix)
829
def test_find_bzrdirs_permission_denied(self):
830
foo, bar, baz = self.make_foo_bar_baz()
831
transport = get_transport(self.get_url())
832
path_filter_server, path_filter_transport = \
833
self.make_fake_permission_denied_transport(transport, ['foo'])
835
self.assertBranchUrlsEndWith('/baz/',
836
bzrdir.BzrDir.find_bzrdirs(path_filter_transport))
838
smart_transport = self.make_smart_server('.',
839
backing_server=path_filter_server)
840
self.assertBranchUrlsEndWith('/baz/',
841
bzrdir.BzrDir.find_bzrdirs(smart_transport))
810
843
def test_find_bzrdirs_list_current(self):
811
844
def list_current(transport):
812
845
return [s for s in transport.list_dir('') if s != 'baz']