fix latest tag for relase verify asset
This commit is contained in:
parent
6b19a85471
commit
4fb9b29ac9
2 changed files with 46 additions and 3 deletions
|
|
@ -168,7 +168,7 @@ func verifyAssetRun(config *VerifyAssetConfig) error {
|
|||
}
|
||||
|
||||
// Filter attestations by tag name
|
||||
filteredAttestations, err := shared.FilterAttestationsByTag(attestations, opts.TagName)
|
||||
filteredAttestations, err := shared.FilterAttestationsByTag(attestations, tagName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing attestations for tag %s: %w", tagName, err)
|
||||
}
|
||||
|
|
@ -201,9 +201,9 @@ func verifyAssetRun(config *VerifyAssetConfig) error {
|
|||
io := config.IO
|
||||
cs := io.ColorScheme()
|
||||
fmt.Fprintf(io.Out, "Calculated digest for %s: %s\n", fileName, fileDigest.DigestWithAlg())
|
||||
fmt.Fprintf(io.Out, "Resolved tag %s to %s\n", opts.TagName, releaseRefDigest.DigestWithAlg())
|
||||
fmt.Fprintf(io.Out, "Resolved tag %s to %s\n", tagName, releaseRefDigest.DigestWithAlg())
|
||||
fmt.Fprint(io.Out, "Loaded attestation from GitHub API\n\n")
|
||||
fmt.Fprintf(io.Out, cs.Green("%s Verification succeeded! %s is present in release %s\n"), cs.SuccessIcon(), fileName, opts.TagName)
|
||||
fmt.Fprintf(io.Out, cs.Green("%s Verification succeeded! %s is present in release %s\n"), cs.SuccessIcon(), fileName, tagName)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,49 @@ func Test_verifyAssetRun_Success(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_verifyAssetRun_SuccessNoTagArg(t *testing.T) {
|
||||
ios, _, _, _ := iostreams.Test()
|
||||
tagName := "v6"
|
||||
|
||||
fakeHTTP := &httpmock.Registry{}
|
||||
defer fakeHTTP.Verify(t)
|
||||
fakeSHA := "1234567890abcdef1234567890abcdef12345678"
|
||||
shared.StubFetchRefSHA(t, fakeHTTP, "OWNER", "REPO", tagName, fakeSHA)
|
||||
shared.StubFetchRelease(t, fakeHTTP, "OWNER", "REPO", "", `{
|
||||
"tag_name": "v6",
|
||||
"draft": false,
|
||||
"url": "https://api.github.com/repos/OWNER/REPO/releases/23456"
|
||||
}`)
|
||||
|
||||
baseRepo, err := ghrepo.FromFullName("OWNER/REPO")
|
||||
require.NoError(t, err)
|
||||
result := &verification.AttestationProcessingResult{
|
||||
Attestation: &api.Attestation{
|
||||
Bundle: data.GitHubReleaseBundle(t),
|
||||
BundleURL: "https://example.com",
|
||||
},
|
||||
VerificationResult: nil,
|
||||
}
|
||||
|
||||
releaseAssetPath := test.NormalizeRelativePath("../../attestation/test/data/github_release_artifact.zip")
|
||||
|
||||
cfg := &VerifyAssetConfig{
|
||||
Opts: &VerifyAssetOptions{
|
||||
AssetFilePath: releaseAssetPath,
|
||||
TagName: "", // No tag argument provided
|
||||
BaseRepo: baseRepo,
|
||||
Exporter: nil,
|
||||
},
|
||||
IO: ios,
|
||||
HttpClient: &http.Client{Transport: fakeHTTP},
|
||||
AttClient: api.NewTestClient(),
|
||||
AttVerifier: shared.NewMockVerifier(result),
|
||||
}
|
||||
|
||||
err = verifyAssetRun(cfg)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_verifyAssetRun_FailedNoAttestations(t *testing.T) {
|
||||
ios, _, _, _ := iostreams.Test()
|
||||
tagName := "v1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue