|
|
@ -20,7 +20,6 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"regexp"
|
|
|
|
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/repo/repotest"
|
|
|
|
"helm.sh/helm/v3/pkg/repo/repotest"
|
|
|
@ -37,6 +36,10 @@ func TestPullCmd(t *testing.T) {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
helmTestKeyOut := "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) <helm-testing@helm.sh>\n" +
|
|
|
|
|
|
|
|
"Using Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\n" +
|
|
|
|
|
|
|
|
"Chart Hash Verified: "
|
|
|
|
|
|
|
|
|
|
|
|
// all flags will get "-d outdir" appended.
|
|
|
|
// all flags will get "-d outdir" appended.
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
@ -49,6 +52,7 @@ func TestPullCmd(t *testing.T) {
|
|
|
|
expectFile string
|
|
|
|
expectFile string
|
|
|
|
expectDir bool
|
|
|
|
expectDir bool
|
|
|
|
expectVerify bool
|
|
|
|
expectVerify bool
|
|
|
|
|
|
|
|
expectSha string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "Basic chart fetch",
|
|
|
|
name: "Basic chart fetch",
|
|
|
@ -77,6 +81,7 @@ func TestPullCmd(t *testing.T) {
|
|
|
|
args: "test/signtest --verify --keyring testdata/helm-test-key.pub",
|
|
|
|
args: "test/signtest --verify --keyring testdata/helm-test-key.pub",
|
|
|
|
expectFile: "./signtest-0.1.0.tgz",
|
|
|
|
expectFile: "./signtest-0.1.0.tgz",
|
|
|
|
expectVerify: true,
|
|
|
|
expectVerify: true,
|
|
|
|
|
|
|
|
expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "Fetch and fail verify",
|
|
|
|
name: "Fetch and fail verify",
|
|
|
@ -110,6 +115,7 @@ func TestPullCmd(t *testing.T) {
|
|
|
|
expectFile: "./signtest2",
|
|
|
|
expectFile: "./signtest2",
|
|
|
|
expectDir: true,
|
|
|
|
expectDir: true,
|
|
|
|
expectVerify: true,
|
|
|
|
expectVerify: true,
|
|
|
|
|
|
|
|
expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "Chart fetch using repo URL",
|
|
|
|
name: "Chart fetch using repo URL",
|
|
|
@ -171,13 +177,11 @@ func TestPullCmd(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if tt.expectVerify {
|
|
|
|
if tt.expectVerify {
|
|
|
|
pointerAddressPattern := "0[xX][A-Fa-f0-9]+"
|
|
|
|
outString := helmTestKeyOut + tt.expectSha + "\n"
|
|
|
|
sha256Pattern := "[A-Fa-f0-9]{64}"
|
|
|
|
if out != outString {
|
|
|
|
verificationRegex := regexp.MustCompile(
|
|
|
|
t.Errorf("%q: expected verification output %q, got %q", tt.name, outString, out)
|
|
|
|
fmt.Sprintf("Verification: &{%s sha256:%s signtest-0.1.0.tgz}\n", pointerAddressPattern, sha256Pattern))
|
|
|
|
|
|
|
|
if !verificationRegex.MatchString(out) {
|
|
|
|
|
|
|
|
t.Errorf("%q: expected match for regex %s, got %s", tt.name, verificationRegex, out)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ef := filepath.Join(outdir, tt.expectFile)
|
|
|
|
ef := filepath.Join(outdir, tt.expectFile)
|
|
|
|