-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from mgerst/feature/43-filter-autopwn
Limit AutoPWN by team, service name, or both.
- Loading branch information
Showing
2 changed files
with
63 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from flag_slurper.cli import cli | ||
from flag_slurper.project import Project | ||
|
||
|
||
@pytest.fixture | ||
def pwn_project(create_project): | ||
tmpdir = create_project(""" | ||
_version: "1.0" | ||
project: Flag Slurper Test | ||
base: {dir}/pwn-test | ||
""") | ||
p = Project.get_instance() | ||
p.load(str(tmpdir.join('project.yml'))) | ||
return str(tmpdir.join('project.yml')) | ||
|
||
|
||
def test_autopwn_no_project(): | ||
p = Project.get_instance() | ||
p.project_data = None | ||
runner = CliRunner() | ||
result = runner.invoke(cli, ['-np', 'autopwn', 'results']) | ||
assert result.exit_code == 4 | ||
assert result.output == "[!] AutoPWN commands require an active project\n" | ||
|
||
|
||
def test_autopwn_pwn_limit_team(pwn_project, mocker, service): | ||
runner = CliRunner() | ||
pwn_service = mocker.patch('flag_slurper.autopwn._pwn_service') | ||
result = runner.invoke(cli, ['autopwn', 'pwn', '-t', service.team.number]) | ||
assert result.exit_code == 0 | ||
pwn_service.assert_called_with((), service) | ||
|
||
|
||
def test_autopwn_pwn_limit_service(pwn_project, mocker): | ||
runner = CliRunner() | ||
pwn_service = mocker.patch('flag_slurper.autopwn._pwn_service') | ||
result = runner.invoke(cli, ['autopwn', 'pwn', '-s', 'non-existant service']) | ||
assert result.exit_code == 0 | ||
pwn_service.assert_not_called() |