MCPcopy Create free account
hub / github.com/docker/buildx / TestSourceToInputSingleSource

Function TestSourceToInputSingleSource

policy/validate_test.go:26–884  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func 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{

Callers

nothing calls this directly

Calls 10

newTestAttestationChainFunction · 0.85
mustMarshalImageConfigFunction · 0.85
gitObjectSHA1Function · 0.85
sourceToInputFunction · 0.85
LenMethod · 0.80
RunMethod · 0.80
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…