Mercurial > hgsubversion
annotate tests/test_urls.py @ 1551:22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Fixes #472.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 24 Mar 2018 15:16:11 -0400 |
parents | 7917abf6b456 |
children |
rev | line source |
---|---|
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
1 import test_util |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
2 |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
3 import unittest |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
4 import urllib |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
5 |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
475
diff
changeset
|
6 from hgsubversion.svnwrap import parse_url |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
467
diff
changeset
|
7 from hgsubversion import svnrepo |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
8 |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
9 class TestSubversionUrls(test_util.TestBase): |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
10 def test_standard_url(self): |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
11 self.check_parse_url((None, None, 'file:///var/svn/repo'), |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
12 ('file:///var/svn/repo', )) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
13 |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
14 def test_user_url(self): |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
15 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
16 ('joe', None, 'https://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
17 ('https://joe@svn.testurl.com/repo', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
18 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
19 ('bob', None, 'https://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
20 ('https://joe@svn.testurl.com/repo', 'bob', )) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
21 |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
22 def test_password_url(self): |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
23 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
24 (None, 't3stpw', 'svn+ssh://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
25 ('svn+ssh://:t3stpw@svn.testurl.com/repo', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
26 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
27 (None, '123abc', 'svn+ssh://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
28 ('svn+ssh://:t3stpw@svn.testurl.com/repo', None, '123abc', )) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
29 |
392
35993ba9d119
urls: Make sure we preserve username in urls given to ssh.
Augie Fackler <durin42@gmail.com>
parents:
337
diff
changeset
|
30 def test_svnssh_preserve_user(self): |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
31 self.check_parse_url( |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
32 ('user', 't3stpw', 'svn+ssh://user@svn.testurl.com/repo',), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
33 ('svn+ssh://user:t3stpw@svn.testurl.com/repo', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
34 self.check_parse_url( |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
35 ('bob', '123abc', 'svn+ssh://bob@svn.testurl.com/repo',), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
36 ('svn+ssh://user:t3stpw@svn.testurl.com/repo', 'bob', '123abc', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
37 self.check_parse_url( |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
38 ('user2', None, 'svn+ssh://user2@svn.testurl.com/repo',), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
39 ('svn+ssh://user2@svn.testurl.com/repo', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
40 self.check_parse_url( |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
41 ('bob', None, 'svn+ssh://bob@svn.testurl.com/repo',), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
42 ('svn+ssh://user2@svn.testurl.com/repo', 'bob', )) |
392
35993ba9d119
urls: Make sure we preserve username in urls given to ssh.
Augie Fackler <durin42@gmail.com>
parents:
337
diff
changeset
|
43 |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
44 def test_user_password_url(self): |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
45 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
46 ('joe', 't3stpw', 'https://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
47 ('https://joe:t3stpw@svn.testurl.com/repo', )) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
48 self.check_parse_url( |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
49 ('bob', '123abc', 'https://svn.testurl.com/repo'), |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
50 ('https://joe:t3stpw@svn.testurl.com/repo', 'bob', '123abc', )) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
51 |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
467
diff
changeset
|
52 def test_url_rewriting(self): |
1534
7917abf6b456
test_urls: correctly use test_util.testui instead of ui.ui
Augie Fackler <raf@durin42.com>
parents:
1453
diff
changeset
|
53 ui = test_util.testui() |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
467
diff
changeset
|
54 ui.setconfig('hgsubversion', 'username', 'bob') |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
467
diff
changeset
|
55 repo = svnrepo.svnremoterepo(ui, 'svn+ssh://joe@foo/bar') |
710
db56e65906f4
svnrepo: make the svnurl property obtain the URL from Subversion.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
699
diff
changeset
|
56 self.assertEqual('svn+ssh://bob@foo/bar', repo.svnauth[0]) |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
57 self.assertEqual('svn+ssh://bob@foo/bar', repo.svnurl) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
diff
changeset
|
58 |
469
5567af673f83
Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents:
468
diff
changeset
|
59 repo = svnrepo.svnremoterepo(ui, 'svn+http://joe@foo/bar') |
5567af673f83
Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents:
468
diff
changeset
|
60 self.assertEqual(('http://foo/bar', 'bob', None), repo.svnauth) |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
61 self.assertEqual('http://foo/bar', repo.svnurl) |
469
5567af673f83
Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents:
468
diff
changeset
|
62 |
475
15443c592f7a
Remove the svn+ from svn+https urls before calling the Subversion API. This was already being done for svn+http urls.
David Stanek <dstanek@dstanek.com>
parents:
469
diff
changeset
|
63 repo = svnrepo.svnremoterepo(ui, 'svn+https://joe@foo/bar') |
15443c592f7a
Remove the svn+ from svn+https urls before calling the Subversion API. This was already being done for svn+http urls.
David Stanek <dstanek@dstanek.com>
parents:
469
diff
changeset
|
64 self.assertEqual(('https://foo/bar', 'bob', None), repo.svnauth) |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
65 self.assertEqual('https://foo/bar', repo.svnurl) |
475
15443c592f7a
Remove the svn+ from svn+https urls before calling the Subversion API. This was already being done for svn+http urls.
David Stanek <dstanek@dstanek.com>
parents:
469
diff
changeset
|
66 |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
67 def test_quoting(self): |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
68 ui = self.ui() |
866
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
69 repo_path = self.load_svndump('non_ascii_path_1.svndump') |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
70 |
866
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
71 repo_url = test_util.fileurl(repo_path) |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
72 subdir = '/b\xC3\xB8b' |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
73 quoted_subdir = urllib.quote(subdir) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
74 |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
75 repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
76 repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
77 self.assertEqual(repo1.svnurl, repo2.svnurl) |
1453
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
78 |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
79 def check_parse_url(self, expected, args): |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
80 self.assertEqual(expected, parse_url(*args)) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
81 if len(args) == 1: |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
82 repo = svnrepo.svnremoterepo(self.ui(), path=args[0]) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
83 self.assertEqual(expected[2], repo.svnauth[0]) |
d890d8d4e168
svnrepo: change svnurl to not use self.svn
Jun Wu <quark@fb.com>
parents:
1044
diff
changeset
|
84 self.assertEqual(expected[2], repo.svnurl) |