| 91 | } |
| 92 | |
| 93 | func TestPluginPackageDefaultRequiresSigning(t *testing.T) { |
| 94 | // Create a test plugin directory |
| 95 | tempDir := t.TempDir() |
| 96 | pluginDir := filepath.Join(tempDir, "test-plugin") |
| 97 | if err := os.MkdirAll(pluginDir, 0755); err != nil { |
| 98 | t.Fatal(err) |
| 99 | } |
| 100 | |
| 101 | // Create a plugin.yaml file |
| 102 | if err := os.WriteFile(filepath.Join(pluginDir, "plugin.yaml"), []byte(testPluginYAML), 0644); err != nil { |
| 103 | t.Fatal(err) |
| 104 | } |
| 105 | |
| 106 | // Create package options with default sign=true and invalid keyring |
| 107 | o := &pluginPackageOptions{ |
| 108 | sign: true, // This is now the default |
| 109 | keyring: "/non/existent/keyring", |
| 110 | pluginPath: pluginDir, |
| 111 | destination: tempDir, |
| 112 | } |
| 113 | |
| 114 | // Run the package command |
| 115 | out := &bytes.Buffer{} |
| 116 | err := o.run(out) |
| 117 | |
| 118 | // Should fail because signing is required by default |
| 119 | if err == nil { |
| 120 | t.Error("expected error when signing fails with default settings") |
| 121 | } |
| 122 | |
| 123 | // Check that no tarball was created |
| 124 | tarballPath := filepath.Join(tempDir, "test-plugin.tgz") |
| 125 | if _, err := os.Stat(tarballPath); !os.IsNotExist(err) { |
| 126 | t.Error("tarball should not exist when signing fails") |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | func TestPluginPackageSigningFailure(t *testing.T) { |
| 131 | // Create a test plugin directory |