(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestGetLocalAttestations(t *testing.T) { |
| 67 | t.Run("with JSON file containing one bundle", func(t *testing.T) { |
| 68 | path := "../test/data/sigstore-js-2.1.0-bundle.json" |
| 69 | attestations, err := GetLocalAttestations(path) |
| 70 | |
| 71 | require.NoError(t, err) |
| 72 | require.Len(t, attestations, 1) |
| 73 | }) |
| 74 | |
| 75 | t.Run("with JSON lines file containing multiple bundles", func(t *testing.T) { |
| 76 | path := "../test/data/sigstore-js-2.1.0_with_2_bundles.jsonl" |
| 77 | attestations, err := GetLocalAttestations(path) |
| 78 | |
| 79 | require.NoError(t, err) |
| 80 | require.Len(t, attestations, 2) |
| 81 | }) |
| 82 | |
| 83 | t.Run("with file with unrecognized extension", func(t *testing.T) { |
| 84 | path := "../test/data/sigstore-js-2.1.0-bundles.tgz" |
| 85 | attestations, err := GetLocalAttestations(path) |
| 86 | |
| 87 | require.ErrorIs(t, err, ErrUnrecognisedBundleExtension) |
| 88 | require.Nil(t, attestations) |
| 89 | }) |
| 90 | |
| 91 | t.Run("with non-existent bundle file and JSON file", func(t *testing.T) { |
| 92 | path := "../test/data/not-found-bundle.json" |
| 93 | attestations, err := GetLocalAttestations(path) |
| 94 | |
| 95 | require.ErrorContains(t, err, "could not load content from file path") |
| 96 | require.Nil(t, attestations) |
| 97 | }) |
| 98 | |
| 99 | t.Run("with non-existent bundle file and JSON lines file", func(t *testing.T) { |
| 100 | path := "../test/data/not-found-bundle.jsonl" |
| 101 | attestations, err := GetLocalAttestations(path) |
| 102 | |
| 103 | require.ErrorContains(t, err, "could not load content from file path") |
| 104 | require.Nil(t, attestations) |
| 105 | }) |
| 106 | |
| 107 | t.Run("with missing verification material", func(t *testing.T) { |
| 108 | path := "../test/data/github_provenance_demo-0.0.12-py3-none-any-bundle-missing-verification-material.jsonl" |
| 109 | _, err := GetLocalAttestations(path) |
| 110 | require.ErrorIs(t, err, bundle.ErrMissingVerificationMaterial) |
| 111 | }) |
| 112 | |
| 113 | t.Run("with missing verification certificate", func(t *testing.T) { |
| 114 | path := "../test/data/github_provenance_demo-0.0.12-py3-none-any-bundle-missing-cert.jsonl" |
| 115 | _, err := GetLocalAttestations(path) |
| 116 | require.ErrorIs(t, err, bundle.ErrMissingBundleContent) |
| 117 | }) |
| 118 | } |
| 119 | |
| 120 | func TestFilterAttestations(t *testing.T) { |
| 121 | attestations := []*api.Attestation{ |
nothing calls this directly
no test coverage detected