MCPcopy
hub / github.com/helm/helm / TestVerifyPlugin

Function TestVerifyPlugin

internal/plugin/verify_test.go:38–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36 - command: echo`
37
38func TestVerifyPlugin(t *testing.T) {
39 // Create a test plugin and sign it
40 tempDir := t.TempDir()
41
42 // Create plugin directory
43 pluginDir := filepath.Join(tempDir, "verify-test-plugin")
44 if err := os.MkdirAll(pluginDir, 0755); err != nil {
45 t.Fatal(err)
46 }
47
48 if err := os.WriteFile(filepath.Join(pluginDir, "plugin.yaml"), []byte(testPluginYAML), 0644); err != nil {
49 t.Fatal(err)
50 }
51
52 // Create tarball
53 tarballPath := filepath.Join(tempDir, "verify-test-plugin.tar.gz")
54 tarFile, err := os.Create(tarballPath)
55 if err != nil {
56 t.Fatal(err)
57 }
58
59 if err := CreatePluginTarball(pluginDir, "test-plugin", tarFile); err != nil {
60 tarFile.Close()
61 t.Fatal(err)
62 }
63 tarFile.Close()
64
65 // Sign the plugin with source directory
66 signer, err := provenance.NewFromKeyring(testKeyFile, "helm-test")
67 if err != nil {
68 t.Fatal(err)
69 }
70 if err := signer.DecryptKey(func(_ string) ([]byte, error) {
71 return []byte(""), nil
72 }); err != nil {
73 t.Fatal(err)
74 }
75
76 // Read the tarball data
77 tarballData, err := os.ReadFile(tarballPath)
78 if err != nil {
79 t.Fatal(err)
80 }
81
82 sig, err := SignPlugin(tarballData, filepath.Base(tarballPath), signer)
83 if err != nil {
84 t.Fatal(err)
85 }
86
87 // Write the signature to .prov file
88 provFile := tarballPath + ".prov"
89 if err := os.WriteFile(provFile, []byte(sig), 0644); err != nil {
90 t.Fatal(err)
91 }
92
93 // Read the files for verification
94 archiveData, err := os.ReadFile(tarballPath)
95 if err != nil {

Callers

nothing calls this directly

Calls 11

NewFromKeyringFunction · 0.92
CreatePluginTarballFunction · 0.85
SignPluginFunction · 0.85
VerifyPluginFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.80
DecryptKeyMethod · 0.80
FatalfMethod · 0.80
CreateMethod · 0.65
WriteFileMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…