From 5c45120bb5c6d93cceb35fd06c36fec8cb0919a4 Mon Sep 17 00:00:00 2001 From: Zach Steindler Date: Wed, 20 Sep 2023 16:02:53 -0400 Subject: [PATCH 1/2] Make it easier to run verification test locally For #99 If you're only testing verification use-cases locally, you don't need the OIDC JWT. Signed-off-by: Zach Steindler --- README.md | 8 +++++++- test/conftest.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9f2e8e..e829edf 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,13 @@ invoke the client. Running the conformance suite locally, ```sh -(env) $ pytest --entrypoint=SIGSTORE_CLIENT --identity-token=$(gh auth token) +(env) $ pytest test --entrypoint=SIGSTORE_CLIENT --identity-token=$(gh auth token) +``` + +Or if you are only checking verification use cases, + +```sh +(env) $ pytest test --skip-signing --entrypoint=SIGSTORE_CLIENT ``` Using the [`gh` CLI](https://cli.github.com/) and noting SIGSTORE_CLIENT is the absolute path to a client implementing the [CLI specification](https://github.com/sigstore/sigstore-conformance/blob/main/docs/cli_protocol.md). diff --git a/test/conftest.py b/test/conftest.py index 131bebd..6edbfad 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -52,7 +52,6 @@ def pytest_addoption(parser) -> None: "--github-token", action="store", help="the GitHub token to supply to the Sigstore client under test", - required=True, type=str, ) parser.addoption( @@ -73,6 +72,9 @@ def pytest_configure(config): @pytest.fixture def identity_token(pytestconfig) -> str: + if pytestconfig.getoption("--skip-signing"): + return "" + gh_token = pytestconfig.getoption("--github-token") session = requests.Session() headers = { From 3d8279cb3459a06076788a2c9e36ea0796b140eb Mon Sep 17 00:00:00 2001 From: Zach Steindler Date: Thu, 21 Sep 2023 11:59:43 -0400 Subject: [PATCH 2/2] Nicer error message for not providing arguments ``` sigstore-conformance$ pytest test --entrypoint /Users/steiza/code/steiza/sigstore-conformance/sigstore-python-conformance Please specify one of '--github-token' or '--skip-signing' sigstore-conformance$ echo $? 3 ``` Signed-off-by: Zach Steindler --- test/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/conftest.py b/test/conftest.py index 6edbfad..1d9b5b4 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -36,6 +36,10 @@ class OidcTokenError(Exception): pass +class ConfigError(Exception): + pass + + def pytest_addoption(parser) -> None: """ Add the `--entrypoint`, `--github-token`, and `--skip-signing` flags to @@ -67,9 +71,20 @@ def pytest_runtest_setup(item): def pytest_configure(config): + if not config.getoption("--github-token") and not config.getoption("--skip-signing"): + raise ConfigError("Please specify one of '--github-token' or '--skip-signing'") + config.addinivalue_line("markers", "signing: mark test as requiring signing functionality") +def pytest_internalerror(excrepr, excinfo): + if excinfo.type == ConfigError: + print(excinfo.value) + return True + + return False + + @pytest.fixture def identity_token(pytestconfig) -> str: if pytestconfig.getoption("--skip-signing"):