mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-09 08:50:28 +03:00
import: overhaul URL validation to use urllib.parse
Python provides us a lovely URL parser with some level of validation built in. The parsed URL is then much easier to validate.
This commit is contained in:
parent
e9a6c84efd
commit
1153ac24fd
2 changed files with 49 additions and 55 deletions
|
|
@ -52,7 +52,6 @@ class ImportTest(unittest.TestCase):
|
|||
app = import_proxy.get_app_from_url(url)
|
||||
import_proxy.clone_to_tmp_dir(app)
|
||||
self.assertEqual(app.RepoType, 'git')
|
||||
self.assertEqual(app.WebSite, 'https://gitlab.com/fdroid/ci-test-app')
|
||||
self.assertEqual(app.Repo, 'https://gitlab.com/fdroid/ci-test-app.git')
|
||||
|
||||
def test_get_all_gradle_and_manifests(self):
|
||||
|
|
@ -86,6 +85,17 @@ class ImportTest(unittest.TestCase):
|
|||
subdir = import_proxy.get_gradle_subdir(build_dir, paths)
|
||||
self.assertEqual(subdirs[f], subdir)
|
||||
|
||||
def test_bad_urls(self):
|
||||
for url in ('asdf',
|
||||
'file://thing.git',
|
||||
'https:///github.com/my/project',
|
||||
'git:///so/many/slashes',
|
||||
'ssh:/notabug.org/missing/a/slash',
|
||||
'git:notabug.org/missing/some/slashes',
|
||||
'https//github.com/bar/baz'):
|
||||
with self.assertRaises(ValueError):
|
||||
import_proxy.get_app_from_url(url)
|
||||
|
||||
def test_get_app_from_url(self):
|
||||
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
|
||||
os.chdir(testdir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue