github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/test/e2e/35_custom_init_package_test.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: 2021-Present The Jackal Authors 3 4 // Package test provides e2e tests for Jackal. 5 package test 6 7 import ( 8 "fmt" 9 "path/filepath" 10 "testing" 11 12 "github.com/stretchr/testify/require" 13 ) 14 15 func TestCustomInit(t *testing.T) { 16 t.Log("E2E: Custom Init Package") 17 e2e.SetupWithCluster(t) 18 buildPath := filepath.Join("src", "test", "packages", "35-custom-init-package") 19 pkgName := fmt.Sprintf("jackal-init-%s-%s.tar.zst", e2e.Arch, e2e.GetJackalVersion(t)) 20 privateKeyFlag := "--signing-key=src/test/packages/jackal-test.prv-key" 21 publicKeyFlag := "--key=src/test/packages/jackal-test.pub" 22 23 stdOut, stdErr, err := e2e.Jackal("package", "create", buildPath, privateKeyFlag, "--confirm") 24 require.NoError(t, err, stdOut, stdErr) 25 defer e2e.CleanFiles(pkgName) 26 27 /* Test operations during package inspect */ 28 // Test that we can inspect the yaml of the package without the private key 29 stdOut, stdErr, err = e2e.Jackal("package", "inspect", pkgName) 30 require.NoError(t, err, stdOut, stdErr) 31 32 // Test that we don't get an error when we remember to provide the public key 33 stdOut, stdErr, err = e2e.Jackal("package", "inspect", pkgName, publicKeyFlag) 34 require.NoError(t, err, stdOut, stdErr) 35 require.Contains(t, stdErr, "Verified OK") 36 37 /* Test operations during package deploy */ 38 // Test that we get an error when trying to deploy a package without providing the public key 39 stdOut, stdErr, err = e2e.Jackal("init", "--confirm") 40 require.Error(t, err, stdOut, stdErr) 41 require.Contains(t, 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") 42 43 /* Test operations during package deploy */ 44 // Test that we can deploy the package with the public key 45 stdOut, stdErr, err = e2e.Jackal("init", "--confirm", publicKeyFlag) 46 require.NoError(t, err, stdOut, stdErr) 47 }