From ecf3313667c182638991bf2ced553efb2595d78f Mon Sep 17 00:00:00 2001 From: Matthew Jackoski <43562993+DS-KoolAid@users.noreply.github.com> Date: Fri, 27 Jan 2023 11:42:03 -0800 Subject: [PATCH] Utilize Automatic Package Discovery Co-authored-by: mason.davis --- .github/workflows/integration.yaml | 4 ++-- .github/workflows/integration_sh.yaml | 8 ++++---- pyproject.toml | 7 +------ {integration => test}/creds.json | 0 {integration => test}/integration_utils.py | 0 {integration => test}/runner_helper.py | 0 {integration => test}/test_cases.json | 0 {integration => test}/test_enumeration.py | 0 {integration => test}/test_help.py | 0 {integration => unit_test}/__init__.py | 0 {test => unit_test}/files/bad_dir/bad_file | 0 {test => unit_test}/files/example_repo.json | 0 {test => unit_test}/files/main.yaml | 0 {test => unit_test}/files/readme.md | 0 {test => unit_test}/files/run_log.zip | Bin {test => unit_test}/files/test_repos_bad.txt | 0 {test => unit_test}/files/test_repos_good.txt | 0 .../files/workflow_test/.github/workflows/test.yml | 0 {test => unit_test}/files/workflow_test/README.md | 0 {test => unit_test}/test_api.py | 0 {test => unit_test}/test_attack.py | 0 {test => unit_test}/test_cicd_attack.py | 0 {test => unit_test}/test_cli.py | 3 ++- {test => unit_test}/test_enumerate.py | 0 {test => unit_test}/test_git.py | 0 {test => unit_test}/test_main.py | 0 {test => unit_test}/test_search.py | 0 {test => unit_test}/test_workflow_parser.py | 0 28 files changed, 9 insertions(+), 13 deletions(-) rename {integration => test}/creds.json (100%) rename {integration => test}/integration_utils.py (100%) rename {integration => test}/runner_helper.py (100%) rename {integration => test}/test_cases.json (100%) rename {integration => test}/test_enumeration.py (100%) rename {integration => test}/test_help.py (100%) rename {integration => unit_test}/__init__.py (100%) rename {test => unit_test}/files/bad_dir/bad_file (100%) rename {test => unit_test}/files/example_repo.json (100%) rename {test => unit_test}/files/main.yaml (100%) rename {test => unit_test}/files/readme.md (100%) rename {test => unit_test}/files/run_log.zip (100%) rename {test => unit_test}/files/test_repos_bad.txt (100%) rename {test => unit_test}/files/test_repos_good.txt (100%) rename {test => unit_test}/files/workflow_test/.github/workflows/test.yml (100%) rename {test => unit_test}/files/workflow_test/README.md (100%) rename {test => unit_test}/test_api.py (100%) rename {test => unit_test}/test_attack.py (100%) rename {test => unit_test}/test_cicd_attack.py (100%) rename {test => unit_test}/test_cli.py (98%) rename {test => unit_test}/test_enumerate.py (100%) rename {test => unit_test}/test_git.py (100%) rename {test => unit_test}/test_main.py (100%) rename {test => unit_test}/test_search.py (100%) rename {test => unit_test}/test_workflow_parser.py (100%) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 0a7256f..a38970d 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -35,7 +35,7 @@ jobs: python-version: 3.11 - run: pip install requests - name: Dispatch Runner Event - run: python integration/runner_helper.py dispatch + run: python test/runner_helper.py dispatch Integration-Testing: name: Gato Integration Testing needs: SH-Runner-Dispatch @@ -61,4 +61,4 @@ jobs: pip install ".[test]" - name: Kick off integration tests. run: | - pytest integration/ + pytest test/ diff --git a/.github/workflows/integration_sh.yaml b/.github/workflows/integration_sh.yaml index fb23469..c37db89 100644 --- a/.github/workflows/integration_sh.yaml +++ b/.github/workflows/integration_sh.yaml @@ -6,7 +6,7 @@ env: SH_RUNNER_MANAGE_TOKEN: ${{secrets.SH_RUNNER_MANAGE_TOKEN }} jobs: - # This job creates a self-hosted runner attached to the + # This job creates a self-hosted runner attached to the # test organization. Integration_SH_Runner: name: Ephemeral Self-Hosted Runner @@ -25,14 +25,14 @@ jobs: mkdir actions-runner && cd actions-runner curl -o actions-runner-linux-x64-2.300.2.tar.gz -L https://github.com/actions/runner/releases/download/v2.300.2/actions-runner-linux-x64-2.300.2.tar.gz tar xzf ./actions-runner-linux-x64-2.300.2.tar.gz - python ../integration/runner_helper.py register + python ../test/runner_helper.py register nohup ./run.sh & - name: Sleep run: python3 -c "import time; time.sleep(840)" - name: Remove Runner run: | cd actions-runner - python ../integration/runner_helper.py remove + python ../test/runner_helper.py remove SH_Runner_Cleanup: # Removes the self-hosted runner forcibly in the event the cleanup operation # did not work. @@ -50,4 +50,4 @@ jobs: - name: Force Remove SH Runner run: | pip install requests - python integration/runner_helper.py force_remove + python test/runner_helper.py force_remove diff --git a/pyproject.toml b/pyproject.toml index 29e8417..b059a1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,13 +34,8 @@ test = [ "pytest-cov" ] -[tool.setuptools] -py-modules = [ - "gato" -] - [tool.pytest.ini_options] -testpaths = ["test"] +testpaths = ["unit_test"] python_files = ["test_*.py"] addopts = "--cov=gato" diff --git a/integration/creds.json b/test/creds.json similarity index 100% rename from integration/creds.json rename to test/creds.json diff --git a/integration/integration_utils.py b/test/integration_utils.py similarity index 100% rename from integration/integration_utils.py rename to test/integration_utils.py diff --git a/integration/runner_helper.py b/test/runner_helper.py similarity index 100% rename from integration/runner_helper.py rename to test/runner_helper.py diff --git a/integration/test_cases.json b/test/test_cases.json similarity index 100% rename from integration/test_cases.json rename to test/test_cases.json diff --git a/integration/test_enumeration.py b/test/test_enumeration.py similarity index 100% rename from integration/test_enumeration.py rename to test/test_enumeration.py diff --git a/integration/test_help.py b/test/test_help.py similarity index 100% rename from integration/test_help.py rename to test/test_help.py diff --git a/integration/__init__.py b/unit_test/__init__.py similarity index 100% rename from integration/__init__.py rename to unit_test/__init__.py diff --git a/test/files/bad_dir/bad_file b/unit_test/files/bad_dir/bad_file similarity index 100% rename from test/files/bad_dir/bad_file rename to unit_test/files/bad_dir/bad_file diff --git a/test/files/example_repo.json b/unit_test/files/example_repo.json similarity index 100% rename from test/files/example_repo.json rename to unit_test/files/example_repo.json diff --git a/test/files/main.yaml b/unit_test/files/main.yaml similarity index 100% rename from test/files/main.yaml rename to unit_test/files/main.yaml diff --git a/test/files/readme.md b/unit_test/files/readme.md similarity index 100% rename from test/files/readme.md rename to unit_test/files/readme.md diff --git a/test/files/run_log.zip b/unit_test/files/run_log.zip similarity index 100% rename from test/files/run_log.zip rename to unit_test/files/run_log.zip diff --git a/test/files/test_repos_bad.txt b/unit_test/files/test_repos_bad.txt similarity index 100% rename from test/files/test_repos_bad.txt rename to unit_test/files/test_repos_bad.txt diff --git a/test/files/test_repos_good.txt b/unit_test/files/test_repos_good.txt similarity index 100% rename from test/files/test_repos_good.txt rename to unit_test/files/test_repos_good.txt diff --git a/test/files/workflow_test/.github/workflows/test.yml b/unit_test/files/workflow_test/.github/workflows/test.yml similarity index 100% rename from test/files/workflow_test/.github/workflows/test.yml rename to unit_test/files/workflow_test/.github/workflows/test.yml diff --git a/test/files/workflow_test/README.md b/unit_test/files/workflow_test/README.md similarity index 100% rename from test/files/workflow_test/README.md rename to unit_test/files/workflow_test/README.md diff --git a/test/test_api.py b/unit_test/test_api.py similarity index 100% rename from test/test_api.py rename to unit_test/test_api.py diff --git a/test/test_attack.py b/unit_test/test_attack.py similarity index 100% rename from test/test_attack.py rename to unit_test/test_attack.py diff --git a/test/test_cicd_attack.py b/unit_test/test_cicd_attack.py similarity index 100% rename from test/test_cicd_attack.py rename to unit_test/test_cicd_attack.py diff --git a/test/test_cli.py b/unit_test/test_cli.py similarity index 98% rename from test/test_cli.py rename to unit_test/test_cli.py index a289b44..c3e259f 100644 --- a/test/test_cli.py +++ b/unit_test/test_cli.py @@ -91,10 +91,11 @@ def test_attack_bad_args1(capfd): def test_attack_bad_args2(capfd): """Test attack command with conflicting params. """ + curr_path = pathlib.Path(__file__).parent.resolve() with pytest.raises(SystemExit): cli.cli(["attack", "-t", "test", "-pr", - "-f", "test/files/main.yaml", "-n", "invalid"]) + "-f", os.path.join(curr_path, "files/main.yaml"), "-n", "invalid"]) out, err = capfd.readouterr() assert "cannot be used with a custom" in err diff --git a/test/test_enumerate.py b/unit_test/test_enumerate.py similarity index 100% rename from test/test_enumerate.py rename to unit_test/test_enumerate.py diff --git a/test/test_git.py b/unit_test/test_git.py similarity index 100% rename from test/test_git.py rename to unit_test/test_git.py diff --git a/test/test_main.py b/unit_test/test_main.py similarity index 100% rename from test/test_main.py rename to unit_test/test_main.py diff --git a/test/test_search.py b/unit_test/test_search.py similarity index 100% rename from test/test_search.py rename to unit_test/test_search.py diff --git a/test/test_workflow_parser.py b/unit_test/test_workflow_parser.py similarity index 100% rename from test/test_workflow_parser.py rename to unit_test/test_workflow_parser.py