-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug with ssh git repo cloning (#124)
- Loading branch information
1 parent
20cac10
commit 2ae91f0
Showing
2 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,10 @@ def setUp(self): | |
{ | ||
"url": "https://github.com/test-user2/test-repo2", | ||
"exclude": ["windows/*", "*_mobile.yara"] | ||
}, | ||
{ | ||
"url": "[email protected]:test-user3/test-repo3", | ||
|
||
} | ||
] | ||
} | ||
|
@@ -98,10 +102,12 @@ def _mock_git_clone(self, args: List[str]) -> None: | |
if cloned_repo_root.endswith('test-repo1'): | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'yara', 'cloned.yara')) | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'not_included.yara')) | ||
else: | ||
elif cloned_repo_root.endswith('test-repo2'): | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'yara', 'cloned.yara')) | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'yara', 'exluded_mobile.yara')) | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'windows', 'excluded.yara')) | ||
elif cloned_repo_root.endswith('test-repo3'): | ||
self.fs.CreateFile(os.path.join(cloned_repo_root, 'yara', 'cloned.yara')) | ||
|
||
@mock.patch.object(clone_rules, 'print') | ||
def test_clone_remote_rules(self, mock_print: mock.MagicMock): | ||
|
@@ -110,18 +116,22 @@ def test_clone_remote_rules(self, mock_print: mock.MagicMock): | |
clone_rules.clone_remote_rules() | ||
|
||
mock_print.assert_has_calls([ | ||
mock.call('[1/2] Cloning https://github.com/test-user1/test-repo1... ', | ||
mock.call('[1/3] Cloning https://github.com/test-user1/test-repo1... ', | ||
end='', flush=True), | ||
mock.call('1 YARA file copied'), | ||
mock.call('[2/3] Cloning https://github.com/test-user2/test-repo2... ', | ||
end='', flush=True), | ||
mock.call('1 YARA file copied'), | ||
mock.call('[2/2] Cloning https://github.com/test-user2/test-repo2... ', | ||
mock.call('[3/3] Cloning git@github.com:test-user3/test-repo3... ', | ||
end='', flush=True), | ||
mock.call('1 YARA file copied'), | ||
mock.call('Done! 2 YARA files cloned from 2 repositories.') | ||
mock.call('Done! 3 YARA files cloned from 3 repositories.') | ||
]) | ||
|
||
expected_files = { | ||
'github.com/test-user1/test-repo1/yara/cloned.yara', | ||
'github.com/test-user2/test-repo2/yara/cloned.yara', | ||
'github.com/test-user3/test-repo3/yara/cloned.yara', | ||
'private/private.yara' | ||
} | ||
self.assertEqual(expected_files, set(compile_rules._find_yara_files())) |