(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestSourceToInputSingleSource(t *testing.T) { |
| 27 | tm := time.Date(2024, 1, 2, 3, 4, 5, 0, time.UTC) |
| 28 | |
| 29 | tests := []struct { |
| 30 | name string |
| 31 | src *gwpb.ResolveSourceMetaResponse |
| 32 | platform *ocispecs.Platform |
| 33 | verifier PolicyVerifierProvider |
| 34 | expInput Input |
| 35 | expUnk []string |
| 36 | expErrMsg string |
| 37 | assert func(*testing.T, Input, []string, error) |
| 38 | }{ |
| 39 | { |
| 40 | name: "nil-source-metadata", |
| 41 | src: nil, |
| 42 | expErrMsg: "no source info in request", |
| 43 | }, |
| 44 | { |
| 45 | name: "invalid-source-identifier", |
| 46 | src: &gwpb.ResolveSourceMetaResponse{ |
| 47 | Source: &pb.SourceOp{Identifier: "not-a-source"}, |
| 48 | }, |
| 49 | expErrMsg: "invalid source identifier: not-a-source", |
| 50 | }, |
| 51 | { |
| 52 | name: "http-source-with-checksum-and-auth", |
| 53 | src: &gwpb.ResolveSourceMetaResponse{ |
| 54 | Source: &pb.SourceOp{ |
| 55 | Identifier: "https://example.com/foo.tar.gz?download=1", |
| 56 | Attrs: map[string]string{ |
| 57 | pb.AttrHTTPAuthHeaderSecret: "my-secret", |
| 58 | }, |
| 59 | }, |
| 60 | HTTP: &gwpb.ResolveSourceHTTPResponse{ |
| 61 | Checksum: "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", |
| 62 | }, |
| 63 | }, |
| 64 | expInput: Input{ |
| 65 | HTTP: &HTTP{ |
| 66 | URL: "https://example.com/foo.tar.gz?download=1", |
| 67 | Schema: "https", |
| 68 | Host: "example.com", |
| 69 | Path: "/foo.tar.gz", |
| 70 | Query: map[string][]string{"download": {"1"}}, |
| 71 | HasAuth: true, |
| 72 | Checksum: "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", |
| 73 | }, |
| 74 | }, |
| 75 | }, |
| 76 | { |
| 77 | name: "http-source-without-checksum", |
| 78 | src: &gwpb.ResolveSourceMetaResponse{ |
| 79 | Source: &pb.SourceOp{ |
| 80 | Identifier: "http://example.com/archive.tgz", |
| 81 | }, |
| 82 | }, |
| 83 | expInput: Input{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…