Skip to content

Commit e6d638f

Browse files
authored
tests: Update tests to be compatible with current staging (#1738)
* tests: Drop signing tests that use a localhost TSA * We have some localhost TSA tests already that test TSA client specifically * The removed signing tests are mostly redundant as the rekor v2 tests already use require the staging TSA to work * The removed tests are fragile since they require a hard coded TrustConfig but still use most of the staging infra Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> * Fix cross-version-verify test * Replace 3.6.6 with 3.6.7 as the latest release in that branch * Start testing on both prod and staging * Skip 3.5.6, 4.0.0 and 4.1.0 on staging: They now fail because of #1656 Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> * cross-version-verify: Use bundle name from env var Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> --------- Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 4db5aaf commit e6d638f

File tree

2 files changed

+28
-88
lines changed

2 files changed

+28
-88
lines changed

.github/workflows/cross-version-verify.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ jobs:
4242
- name: Sign
4343
run: |
4444
touch artifact
45-
python -m sigstore --staging sign --bundle artifact-rekor2.sigstore.json --identity-token $(cat oidc-token.txt) --rekor-version=2 artifact
46-
python -m sigstore --staging sign --bundle artifact-rekor1.sigstore.json --identity-token $(cat oidc-token.txt) --rekor-version=1 artifact
45+
python -m sigstore --staging sign --bundle artifact-staging-rekor2.sigstore.json --identity-token $(cat oidc-token.txt) --rekor-version=2 artifact
46+
python -m sigstore --staging sign --bundle artifact-staging-rekor1.sigstore.json --identity-token $(cat oidc-token.txt) --rekor-version=1 artifact
47+
python -m sigstore sign --bundle artifact-prod-rekor1.sigstore.json --identity-token $(cat oidc-token.txt) --rekor-version=1 artifact
4748
- name: upload signature bundle
4849
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
4950
with:
@@ -52,13 +53,24 @@ jobs:
5253
if-no-files-found: error
5354
retention-days: 1
5455
verify:
55-
name: Verify with ${{ matrix.version }}
56+
name: Verify with ${{ matrix.version }} on ${{ matrix.env }}
5657
needs: [sign]
5758
runs-on: ubuntu-latest
5859
strategy:
5960
fail-fast: false # Don't cancel other jobs if one fails
6061
matrix:
61-
version: [3.5.6, 3.6.6, 4.0.0, 4.1.0, 4.2.0]
62+
# hand crafted list of old versions we care about
63+
version: [3.5.6, 3.6.7, 4.0.0, 4.1.0, 4.2.0]
64+
env: [staging, prod]
65+
exclude:
66+
# exclude staging for versions with https://github.com/sigstore/sigstore-python/issues/1656
67+
- env: staging
68+
version: 3.5.6
69+
- env: staging
70+
version: 4.0.0
71+
- env: staging
72+
version: 4.1.0
73+
6274
steps:
6375
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
6476
with:
@@ -69,15 +81,22 @@ jobs:
6981
name: bundle
7082
- run: touch artifact
7183
- name: Verify (Rekor v2)
72-
if: startsWith(matrix.version, '3.') != true
84+
# Rekor v2 is currently only available on staging, and only supported on sigstore-python 4.x
85+
if: startsWith(matrix.version, '3.') != true && matrix.env == 'staging'
86+
env:
87+
ENV_OPT: ${{ matrix.env == 'staging' && '--staging' || '' }}
88+
BUNDLE: artifact-${{matrix.env}}-rekor2.sigstore.json
7389
run: |
74-
python -m sigstore --staging verify github --verbose \
90+
python -m sigstore $ENV_OPT verify github --verbose \
7591
--cert-identity "https://github.com/sigstore-conformance/extremely-dangerous-public-oidc-beacon/.github/workflows/extremely-dangerous-oidc-beacon.yml@refs/heads/main" \
76-
--bundle artifact-rekor2.sigstore.json \
92+
--bundle $BUNDLE \
7793
artifact
7894
- name: Verify (Rekor v1)
95+
env:
96+
ENV_OPT: ${{ matrix.env == 'staging' && '--staging' || '' }}
97+
BUNDLE: artifact-${{matrix.env}}-rekor1.sigstore.json
7998
run: |
80-
python -m sigstore --staging verify github --verbose \
99+
python -m sigstore $ENV_OPT verify github --verbose \
81100
--cert-identity "https://github.com/sigstore-conformance/extremely-dangerous-public-oidc-beacon/.github/workflows/extremely-dangerous-oidc-beacon.yml@refs/heads/main" \
82-
--bundle artifact-rekor1.sigstore.json \
101+
--bundle $BUNDLE \
83102
artifact

test/unit/test_sign.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import hashlib
15-
import logging
1615
import secrets
1716

1817
import pretend
1918
import pytest
2019
from sigstore_models.common.v1 import HashAlgorithm
2120

2221
import sigstore.oidc
23-
from sigstore._internal.timestamp import TimestampAuthorityClient
2422
from sigstore.dsse import StatementBuilder, Subject
2523
from sigstore.errors import VerificationError
2624
from sigstore.hashes import Hashed
27-
from sigstore.models import ClientTrustConfig
2825
from sigstore.sign import SigningContext
2926
from sigstore.verify.policy import UnsafeNoOp
3027

@@ -179,79 +176,3 @@ def test_sign_dsse(staging):
179176
bundle = signer.sign_dsse(stmt)
180177
# Ensures that all of our inner types serialize as expected.
181178
bundle.to_json()
182-
183-
184-
@pytest.mark.staging
185-
@pytest.mark.ambient_oidc
186-
@pytest.mark.timestamp_authority
187-
class TestSignWithTSA:
188-
@pytest.fixture
189-
def sig_ctx(self, asset, tsa_url) -> SigningContext:
190-
trust_config = ClientTrustConfig.from_json(
191-
asset("tsa/trust_config.json").read_text()
192-
)
193-
194-
trust_config._inner.signing_config.tsa_urls[0].url = tsa_url
195-
196-
return SigningContext.from_trust_config(trust_config)
197-
198-
@pytest.fixture
199-
def identity(self, staging):
200-
_, _, identity = staging
201-
return identity
202-
203-
@pytest.fixture
204-
def hashed(self) -> Hashed:
205-
input_ = secrets.token_bytes(32)
206-
return Hashed(
207-
digest=hashlib.sha256(input_).digest(), algorithm=HashAlgorithm.SHA2_256
208-
)
209-
210-
def test_sign_artifact(self, sig_ctx, identity, hashed):
211-
with sig_ctx.signer(identity) as signer:
212-
bundle = signer.sign_artifact(hashed)
213-
214-
assert bundle.to_json()
215-
assert (
216-
bundle.verification_material.timestamp_verification_data.rfc3161_timestamps
217-
)
218-
219-
def test_sign_dsse(self, sig_ctx, identity):
220-
stmt = (
221-
StatementBuilder()
222-
.subjects(
223-
[
224-
Subject(
225-
name="null", digest={"sha256": hashlib.sha256(b"").hexdigest()}
226-
)
227-
]
228-
)
229-
.predicate_type("https://cosign.sigstore.dev/attestation/v1")
230-
.predicate(
231-
{
232-
"Data": "",
233-
"Timestamp": "2023-12-07T00:37:58Z",
234-
}
235-
)
236-
).build()
237-
238-
with sig_ctx.signer(identity) as signer:
239-
bundle = signer.sign_dsse(stmt)
240-
241-
assert bundle.to_json()
242-
assert (
243-
bundle.verification_material.timestamp_verification_data.rfc3161_timestamps
244-
)
245-
246-
def test_with_timestamp_error(self, sig_ctx, identity, hashed, caplog):
247-
# Simulate here an TSA that returns an invalid Timestamp
248-
sig_ctx._tsa_clients.append(TimestampAuthorityClient("invalid-url"))
249-
250-
with caplog.at_level(logging.WARNING, logger="sigstore.sign"):
251-
with sig_ctx.signer(identity) as signer:
252-
bundle = signer.sign_artifact(hashed)
253-
254-
assert caplog.records[0].message.startswith("Unable to use invalid-url")
255-
assert (
256-
bundle.verification_material.timestamp_verification_data.rfc3161_timestamps
257-
)

0 commit comments

Comments
 (0)