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

Function testBuildPolicyHTTP

tests/policy_build.go:710–894  ·  view source on GitHub ↗
(t *testing.T, sb integration.Sandbox)

Source from the content-addressed store, hash-verified

708}
709
710func testBuildPolicyHTTP(t *testing.T, sb integration.Sandbox) {
711 skipNoCompatBuildKit(t, sb, ">= 0.26.0-0", "policy input requires BuildKit v0.26.0+")
712 resp := &httpserver.Response{Content: []byte("policy-http")}
713 server := httpserver.NewTestServer(map[string]*httpserver.Response{
714 "/file": resp,
715 })
716 defer server.Close()
717
718 parsedURL, err := url.Parse(server.URL)
719 require.NoError(t, err)
720
721 baseURL := server.URL + "/file"
722 queryURL := baseURL + "?policy=allow&case=http"
723 checksum := digest.FromBytes(resp.Content).String()
724 testCases := []struct {
725 name string
726 policy string
727 addURL string
728 wantErrContains string
729 requiresHTTPChecksum bool
730 }{
731 {
732 name: "http-url-allow",
733 policy: fmt.Sprintf(`
734package docker
735
736default allow = false
737
738allow if not input.http
739
740allow if input.http.url == "%s"
741
742decision := {"allow": allow}
743`, queryURL),
744 addURL: queryURL,
745 },
746 {
747 name: "http-schema-allow",
748 policy: `
749package docker
750
751default allow = false
752
753allow if not input.http
754
755allow if input.http.schema == "http"
756
757decision := {"allow": allow}
758`,
759 addURL: baseURL,
760 },
761 {
762 name: "http-host-allow",
763 policy: fmt.Sprintf(`
764package docker
765
766default allow = false
767

Callers

nothing calls this directly

Calls 10

skipNoCompatBuildKitFunction · 0.85
isRemoteWorkerFunction · 0.85
tmpdirFunction · 0.85
buildxCmdFunction · 0.85
withDirFunction · 0.85
withArgsFunction · 0.85
RunMethod · 0.80
CloseMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…