Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: tests/gclient_utils_test.py

Issue 9214004: Add UpgradeToHttps() to reliably and forcibly upgrade all urls to https (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Saner processing. Had to workaround urlparse default behavior Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gclient_utils_test.py
diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py
index 937e43a7cbc6da1c0008518f42afa12a501c5004..9f01c5d1e6e56dad659ae392993089bc5a4ee360 100755
--- a/tests/gclient_utils_test.py
+++ b/tests/gclient_utils_test.py
@@ -35,10 +35,11 @@ class GclientUtilsUnittest(GclientUtilBase):
'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated',
'PathDifference', 'ParseCodereviewSettingsContent',
'PrintableObject', 'RemoveDirectory', 'RunEditor',
- 'SplitUrlRevision', 'SyntaxErrorToError', 'Wrapper', 'WorkItem',
+ 'SplitUrlRevision', 'SyntaxErrorToError',
+ 'UpgradeToHttps', 'Wrapper', 'WorkItem',
'errno', 'lockedmethod', 'logging', 'os', 'Queue', 're', 'rmtree',
'safe_makedirs', 'stat', 'subprocess2', 'sys', 'tempfile', 'threading',
- 'time',
+ 'time', 'urlparse',
]
# If this test fails, you should add the relevant test.
self.compareMembers(gclient_utils, members)
@@ -171,20 +172,45 @@ class GClientUtilsTest(trial_dir.TestCase):
os.chmod(l2, 0)
os.chmod(l1, 0)
+ def testUpgradeToHttps(self):
+ values = [
+ ['', ''],
+ [None, None],
+ ['foo', 'https://foo'],
+ ['http://foo', 'https://foo'],
+ ['foo/', 'https://foo/'],
+ ['ssh-svn://foo', 'ssh-svn://foo'],
+ ['ssh-svn://foo/bar/', 'ssh-svn://foo/bar/'],
+ ['codereview.chromium.org', 'https://chromiumcodereview.appspot.com'],
+ ['codereview.chromium.org/', 'https://chromiumcodereview.appspot.com/'],
+ ['http://foo:8080', 'http://foo:8080'],
+ ['http://foo:8080/bar', 'http://foo:8080/bar'],
+ ['foo:8080', 'http://foo:8080'],
+ ['foo:', 'https://foo:'],
+ ]
+ for content, expected in values:
+ self.assertEquals(
+ expected, gclient_utils.UpgradeToHttps(content))
+
def testParseCodereviewSettingsContent(self):
- expected = {
- 'Foo': 'bar:baz',
- 'Second': 'value',
- }
- content = (
- '# bleh\n'
- '\t# foo : bar\n'
- 'Foo:bar:baz\n'
- ' Second : value \n\r'
- '#inconsistency'
- )
- self.assertEquals(
- expected, gclient_utils.ParseCodereviewSettingsContent(content))
+ values = [
+ ['# bleh\n', {}],
+ ['\t# foo : bar\n', {}],
+ ['Foo:bar', {'Foo': 'bar'}],
+ ['Foo:bar:baz\n', {'Foo': 'bar:baz'}],
+ [' Foo : bar ', {'Foo': 'bar'}],
+ [' Foo : bar \n', {'Foo': 'bar'}],
+ ['a:b\n\rc:d\re:f', {'a': 'b', 'c': 'd', 'e': 'f'}],
+ ['an_url:http://value/', {'an_url': 'http://value/'}],
+ [
+ 'CODE_REVIEW_SERVER : http://r/s',
+ {'CODE_REVIEW_SERVER': 'https://r/s'}
+ ],
+ ['VIEW_VC:http://r/s', {'VIEW_VC': 'https://r/s'}],
+ ]
+ for content, expected in values:
+ self.assertEquals(
+ expected, gclient_utils.ParseCodereviewSettingsContent(content))
if __name__ == '__main__':
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698