Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f41a39

Browse files
committed
fix clone_from_unsafe_protocol tests
1 parent36cf7c1 commit8f41a39

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

‎test/test_repo.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def test_clone_from_safe_options(self, rw_repo):
386386
Repo.clone_from(rw_repo.common_dir,destination,multi_options=[option])
387387
assertdestination.exists()
388388

389-
deftest_clone_from_unsafe_procol(self):
389+
deftest_clone_from_unsafe_protocol(self):
390390
withtempfile.TemporaryDirectory()astdir:
391391
tmp_dir=pathlib.Path(tdir)
392392
tmp_file=tmp_dir/"pwn"
@@ -396,24 +396,49 @@ def test_clone_from_unsafe_procol(self):
396396
]
397397
forurlinurls:
398398
withself.assertRaises(UnsafeProtocolError):
399-
Repo.clone_from(url,tmp_dir)
399+
Repo.clone_from(url,tmp_dir/"repo")
400400
assertnottmp_file.exists()
401401

402-
deftest_clone_from_unsafe_procol_allowed(self):
402+
deftest_clone_from_unsafe_protocol_allowed(self):
403403
withtempfile.TemporaryDirectory()astdir:
404404
tmp_dir=pathlib.Path(tdir)
405405
tmp_file=tmp_dir/"pwn"
406406
urls= [
407-
"ext::sh -c touch%/tmp/pwn",
407+
f"ext::sh -c touch%{tmp_file}",
408408
"fd::/foo",
409409
]
410410
forurlinurls:
411411
# The URL will be allowed into the command, but the command will
412412
# fail since we don't have that protocol enabled in the Git config file.
413413
withself.assertRaises(GitCommandError):
414-
Repo.clone_from(url,tmp_dir,allow_unsafe_protocols=True)
414+
Repo.clone_from(url,tmp_dir/"repo",allow_unsafe_protocols=True)
415415
assertnottmp_file.exists()
416416

417+
deftest_clone_from_unsafe_protocol_allowed_and_enabled(self):
418+
withtempfile.TemporaryDirectory()astdir:
419+
tmp_dir=pathlib.Path(tdir)
420+
tmp_file=tmp_dir/"pwn"
421+
urls= [
422+
f"ext::sh -c touch%{tmp_file}",
423+
]
424+
allow_ext= [
425+
"--config=protocol.ext.allow=always",
426+
]
427+
forurlinurls:
428+
# The URL will be allowed into the command, and the protocol is enabled,
429+
# but the command will fail since it can't read from the remote repo.
430+
assertnottmp_file.exists()
431+
withself.assertRaises(GitCommandError):
432+
Repo.clone_from(
433+
url,
434+
tmp_dir/"repo",
435+
multi_options=allow_ext,
436+
allow_unsafe_protocols=True,
437+
allow_unsafe_options=True,
438+
)
439+
asserttmp_file.exists()
440+
tmp_file.unlink()
441+
417442
@with_rw_repo("HEAD")
418443
deftest_max_chunk_size(self,repo):
419444
classTestOutputStream(TestBase):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp