/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_url_policy_open.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-17 00:47:52 UTC
  • mfrom: (7182 work)
  • mto: This revision was merged to the branch mainline in revision 7305.
  • Revision ID: jelmer@jelmer.uk-20181117004752-6ywampe5pfywlby4
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
            BadUrl, opener.check_and_follow_branch_reference, 'a')
89
89
 
90
90
    def test_not_reference(self):
91
 
        # When branch references are forbidden, check_and_follow_branch_reference
92
 
        # does not raise on non-references.
 
91
        # When branch references are forbidden,
 
92
        # check_and_follow_branch_reference does not raise on non-references.
93
93
        opener = self.make_branch_opener(False, ['a', None])
94
94
        self.assertEqual(
95
95
            'a', opener.check_and_follow_branch_reference('a'))
106
106
        self.assertEqual(['a'], opener.follow_reference_calls)
107
107
 
108
108
    def test_allowed_reference(self):
109
 
        # check_and_follow_branch_reference does not raise if following references
110
 
        # is allowed and the source URL points to a branch reference to a
111
 
        # permitted location.
 
109
        # check_and_follow_branch_reference does not raise if following
 
110
        # references is allowed and the source URL points to a branch reference
 
111
        # to a permitted location.
112
112
        opener = self.make_branch_opener(True, ['a', 'b', None])
113
113
        self.assertEqual(
114
114
            'b', opener.check_and_follow_branch_reference('a'))
115
115
        self.assertEqual(['a', 'b'], opener.follow_reference_calls)
116
116
 
117
117
    def test_check_referenced_urls(self):
118
 
        # check_and_follow_branch_reference checks if the URL a reference points
119
 
        # to is safe.
 
118
        # check_and_follow_branch_reference checks if the URL a reference
 
119
        # points to is safe.
120
120
        opener = self.make_branch_opener(
121
121
            True, ['a', 'b', None], unsafe_urls=set('b'))
122
122
        self.assertRaises(
186
186
        self.assertRaises(NotBranchError, opener.open, ".")
187
187
        self.assertEqual(1, len(TrackingProber.seen_urls))
188
188
        TrackingProber.seen_urls = []
189
 
        # And make sure it's registered in such a way that ControlDir.open would
190
 
        # use it.
 
189
        # And make sure it's registered in such a way that ControlDir.open
 
190
        # would use it.
191
191
        self.assertRaises(NotBranchError, ControlDir.open, ".")
192
192
        self.assertEqual(1, len(TrackingProber.seen_urls))
193
193
 
334
334
        def get_url(relpath):
335
335
            return chroot_server.get_url() + relpath
336
336
 
337
 
        return urlutils.URL.from_string(chroot_server.get_url()).scheme, get_url
 
337
        return (urlutils.URL.from_string(chroot_server.get_url()).scheme,
 
338
                get_url)
338
339
 
339
340
    def test_stacked_within_scheme(self):
340
341
        # A branch that is stacked on a URL of the same scheme is safe to