Skip to content

Commit

Permalink
Update the test suite to use the new flags instead of --insecure
Browse files Browse the repository at this point in the history
  • Loading branch information
joonas committed Sep 1, 2024
1 parent 92eb57c commit b67d55e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/cmd/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func init() {

initCmd.Flags().IntVar(&pkgConfig.PkgOpts.Retries, "retries", v.GetInt(common.VPkgRetries), lang.CmdPackageFlagRetries)
initCmd.Flags().StringVarP(&pkgConfig.PkgOpts.PublicKeyPath, "key", "k", v.GetString(common.VPkgPublicKey), lang.CmdPackageFlagFlagPublicKey)
initCmd.Flags().BoolVar(&pkgConfig.PkgOpts.SkipSignatureValidation, "skip-signature-validation", false, lang.CmdPackageFlagSkipSignatureValidation)

initCmd.Flags().SortFlags = true
}
4 changes: 2 additions & 2 deletions src/test/e2e/11_oci_pull_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ func (suite *PullInspectTestSuite) Test_0_Pull() {
suite.Contains(stdErr, "Package signature validated!")

// Test pull w/ bad ref.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+badPullInspectRef.String(), "--insecure")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+badPullInspectRef.String(), "--plain-http", "--insecure-skip-tls-verify")
suite.Error(err, stdOut, stdErr)
}

func (suite *PullInspectTestSuite) Test_1_Remote_Inspect() {
suite.T().Log("E2E: Package Inspect oci://")

// Test inspect w/ bad ref.
_, stdErr, err := e2e.Zarf(suite.T(), "package", "inspect", "oci://"+badPullInspectRef.String(), "--insecure")
_, stdErr, err := e2e.Zarf(suite.T(), "package", "inspect", "oci://"+badPullInspectRef.String(), "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.Error(err, stdErr)

// Test inspect on a public package.
Expand Down
24 changes: 12 additions & 12 deletions src/test/e2e/14_oci_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,47 @@ func (suite *PublishCopySkeletonSuite) Test_0_Publish_Skeletons() {
ref := suite.Reference.String()

helmCharts := filepath.Join("examples", "helm-charts")
_, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", helmCharts, "oci://"+ref, "--insecure")
_, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", helmCharts, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify")
suite.NoError(err)
suite.Contains(stdErr, "Published "+ref)

bigBang := filepath.Join("src", "test", "packages", "14-import-everything", "big-bang-min")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", bigBang, "oci://"+ref, "--insecure")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", bigBang, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify")
suite.NoError(err)
suite.Contains(stdErr, "Published "+ref)

composable := filepath.Join("src", "test", "packages", "09-composable-packages")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", composable, "oci://"+ref, "--insecure")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", composable, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify")
suite.NoError(err)
suite.Contains(stdErr, "Published "+ref)

_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", importEverything, "oci://"+ref, "--insecure")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", importEverything, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify")
suite.NoError(err)
suite.Contains(stdErr, "Published "+ref)

_, _, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/import-everything:0.0.1", "--insecure", "-a", "skeleton")
_, _, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/import-everything:0.0.1", "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation", "-a", "skeleton")
suite.NoError(err)

_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/import-everything:0.0.1", "-o", "build", "--insecure", "-a", "skeleton")
_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/import-everything:0.0.1", "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "-a", "skeleton")
suite.NoError(err)

_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "-o", "build", "--insecure", "-a", "skeleton")
_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "-a", "skeleton")
suite.NoError(err)

_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/big-bang-min:2.10.0", "-o", "build", "--insecure", "-a", "skeleton")
_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/big-bang-min:2.10.0", "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "-a", "skeleton")
suite.NoError(err)

_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/test-compose-package:0.0.1", "-o", "build", "--insecure", "-a", "skeleton")
_, _, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/test-compose-package:0.0.1", "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "-a", "skeleton")
suite.NoError(err)
}

func (suite *PublishCopySkeletonSuite) Test_1_Compose_Everything_Inception() {
suite.T().Log("E2E: Skeleton Package Compose oci://")

_, _, err := e2e.Zarf(suite.T(), "package", "create", importEverything, "-o", "build", "--insecure", "--confirm")
_, _, err := e2e.Zarf(suite.T(), "package", "create", importEverything, "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "--confirm")
suite.NoError(err)

_, _, err = e2e.Zarf(suite.T(), "package", "create", importception, "-o", "build", "--insecure", "--confirm")
_, _, err = e2e.Zarf(suite.T(), "package", "create", importception, "-o", "build", "--plain-http", "--insecure-skip-tls-verify", "--confirm")
suite.NoError(err)

_, stdErr, err := e2e.Zarf(suite.T(), "package", "inspect", importEverythingPath)
Expand Down Expand Up @@ -183,7 +183,7 @@ func (suite *PublishCopySkeletonSuite) Test_3_Copy() {
t := suite.T()

example := filepath.Join("build", fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch))
stdOut, stdErr, err := e2e.Zarf(t, "package", "publish", example, "oci://"+suite.Reference.Registry, "--insecure")
stdOut, stdErr, err := e2e.Zarf(t, "package", "publish", example, "oci://"+suite.Reference.Registry, "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.NoError(err, stdOut, stdErr)

suite.Reference.Repository = "helm-charts"
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/31_checksum_and_signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestChecksumAndSignature(t *testing.T) {
// Test that we get an error when trying to deploy a package without providing the public key
stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", pkgName, "--confirm")
require.Error(t, err, stdOut, stdErr)
require.Contains(t, e2e.StripMessageFormatting(stdErr), "failed to deploy package: unable to load the package: package is signed but no key was provided - add a key with the --key flag or use the --insecure flag and run the command again")
require.Contains(t, e2e.StripMessageFormatting(stdErr), "failed to deploy package: unable to load the package: package is signed but no key was provided - add a key with the --key flag or use the --skip-signature-validation flag and run the command again")

// Test that we don't get an error when we remember to provide the public key
stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", pkgName, publicKeyFlag, "--confirm")
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/34_custom_init_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestCustomInit(t *testing.T) {
// Test that we get an error when trying to deploy a package without providing the public key
stdOut, stdErr, err = e2e.Zarf(t, "init", "--confirm")
require.Error(t, err, stdOut, stdErr)
require.Contains(t, e2e.StripMessageFormatting(stdErr), "unable to load the package: package is signed but no key was provided - add a key with the --key flag or use the --insecure flag and run the command again")
require.Contains(t, e2e.StripMessageFormatting(stdErr), "unable to load the package: package is signed but no key was provided - add a key with the --key flag or use the --skip-signature-validation flag and run the command again")

/* Test operations during package deploy */
// Test that we can deploy the package with the public key
Expand Down
20 changes: 10 additions & 10 deletions src/test/e2e/50_oci_publish_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ func (suite *PublishDeploySuiteTestSuite) Test_0_Publish() {
// Publish package.
example := filepath.Join(suite.PackagesDir, fmt.Sprintf("zarf-package-helm-charts-%s-0.0.1.tar.zst", e2e.Arch))
ref := suite.Reference.String()
stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--insecure")
stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.NoError(err, stdOut, stdErr)
suite.Contains(stdErr, "Published "+ref)

// Pull the package via OCI.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "--insecure")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "--plain-http", "--insecure-skip-tls-verify")
suite.NoError(err, stdOut, stdErr)

// Publish w/ package missing `metadata.version` field.
example = filepath.Join(suite.PackagesDir, fmt.Sprintf("zarf-package-component-actions-%s.tar.zst", e2e.Arch))
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--insecure")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.Error(err, stdErr)

// Inline publish package.
dir := filepath.Join("examples", "helm-charts")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "create", dir, "-o", "oci://"+ref, "--insecure", "--oci-concurrency=5", "--confirm")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "create", dir, "-o", "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify", "--oci-concurrency=5", "--confirm")
suite.NoError(err, stdOut, stdErr)

// Inline publish flavor.
dir = filepath.Join("examples", "package-flavors")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "create", dir, "-o", "oci://"+ref, "--flavor", "oracle-cookie-crunch", "--insecure", "--confirm")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "create", dir, "-o", "oci://"+ref, "--flavor", "oracle-cookie-crunch", "--plain-http", "--insecure-skip-tls-verify", "--confirm")
suite.NoError(err, stdOut, stdErr)

// Inspect published flavor.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/package-flavors:1.0.0-oracle-cookie-crunch", "--insecure")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/package-flavors:1.0.0-oracle-cookie-crunch", "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.NoError(err, stdOut, stdErr)

// Inspect the published package.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/helm-charts:0.0.1", "--insecure")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/helm-charts:0.0.1", "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation")
suite.NoError(err, stdOut, stdErr)
}

Expand All @@ -87,15 +87,15 @@ func (suite *PublishDeploySuiteTestSuite) Test_1_Deploy() {
ref := suite.Reference.String()

// Deploy the package via OCI.
stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "deploy", "oci://"+ref, "--insecure", "--confirm")
stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "deploy", "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation", "--confirm")
suite.NoError(err, stdOut, stdErr)

// Remove the package via OCI.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "remove", "oci://"+ref, "--insecure", "--confirm")
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "remove", "oci://"+ref, "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation", "--confirm")
suite.NoError(err, stdOut, stdErr)

// Test deploy w/ bad ref.
_, stdErr, err = e2e.Zarf(suite.T(), "package", "deploy", "oci://"+badDeployRef.String(), "--insecure", "--confirm")
_, stdErr, err = e2e.Zarf(suite.T(), "package", "deploy", "oci://"+badDeployRef.String(), "--plain-http", "--insecure-skip-tls-verify", "--skip-signature-validation", "--confirm")
suite.Error(err, stdErr)
}

Expand Down

0 comments on commit b67d55e

Please sign in to comment.