(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func TestFilterAttestations(t *testing.T) { |
| 121 | attestations := []*api.Attestation{ |
| 122 | { |
| 123 | Bundle: &bundle.Bundle{ |
| 124 | Bundle: &protobundle.Bundle{ |
| 125 | Content: &protobundle.Bundle_DsseEnvelope{ |
| 126 | DsseEnvelope: &dsse.Envelope{ |
| 127 | PayloadType: "application/vnd.in-toto+json", |
| 128 | Payload: []byte("{\"predicateType\": \"https://slsa.dev/provenance/v1\"}"), |
| 129 | }, |
| 130 | }, |
| 131 | }, |
| 132 | }, |
| 133 | }, |
| 134 | { |
| 135 | Bundle: &bundle.Bundle{ |
| 136 | Bundle: &protobundle.Bundle{ |
| 137 | Content: &protobundle.Bundle_DsseEnvelope{ |
| 138 | DsseEnvelope: &dsse.Envelope{ |
| 139 | PayloadType: "application/vnd.something-other-than-in-toto+json", |
| 140 | Payload: []byte("{\"predicateType\": \"https://slsa.dev/provenance/v1\"}"), |
| 141 | }, |
| 142 | }, |
| 143 | }, |
| 144 | }, |
| 145 | }, |
| 146 | { |
| 147 | Bundle: &bundle.Bundle{ |
| 148 | Bundle: &protobundle.Bundle{ |
| 149 | Content: &protobundle.Bundle_DsseEnvelope{ |
| 150 | DsseEnvelope: &dsse.Envelope{ |
| 151 | PayloadType: "application/vnd.in-toto+json", |
| 152 | Payload: []byte("{\"predicateType\": \"https://spdx.dev/Document/v2.3\"}"), |
| 153 | }, |
| 154 | }, |
| 155 | }, |
| 156 | }, |
| 157 | }, |
| 158 | } |
| 159 | |
| 160 | filtered, err := api.FilterAttestations("https://slsa.dev/provenance/v1", attestations) |
| 161 | require.Len(t, filtered, 1) |
| 162 | require.NoError(t, err) |
| 163 | |
| 164 | filtered, err = api.FilterAttestations("NonExistentPredicate", attestations) |
| 165 | require.Nil(t, filtered) |
| 166 | require.Error(t, err) |
| 167 | } |
nothing calls this directly
no test coverage detected