Skip to content

Commit

Permalink
Make it easier to run verification test locally (#100)
Browse files Browse the repository at this point in the history
* 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 <steiza@github.com>

* 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 <steiza@github.com>

---------

Signed-off-by: Zach Steindler <steiza@github.com>
  • Loading branch information
steiza authored Sep 21, 2023
1 parent 6c958ac commit 2a930eb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
19 changes: 18 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,7 +56,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(
Expand All @@ -68,11 +71,25 @@ 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"):
return ""

gh_token = pytestconfig.getoption("--github-token")
session = requests.Session()
headers = {
Expand Down

0 comments on commit 2a930eb

Please sign in to comment.