| 40 | args: ["test"]` |
| 41 | |
| 42 | func TestPluginPackageWithoutSigning(t *testing.T) { |
| 43 | // Create a test plugin directory |
| 44 | tempDir := t.TempDir() |
| 45 | pluginDir := filepath.Join(tempDir, "test-plugin") |
| 46 | if err := os.MkdirAll(pluginDir, 0755); err != nil { |
| 47 | t.Fatal(err) |
| 48 | } |
| 49 | |
| 50 | // Create a plugin.yaml file |
| 51 | if err := os.WriteFile(filepath.Join(pluginDir, "plugin.yaml"), []byte(testPluginYAML), 0644); err != nil { |
| 52 | t.Fatal(err) |
| 53 | } |
| 54 | |
| 55 | // Create package options with sign=false |
| 56 | o := &pluginPackageOptions{ |
| 57 | sign: false, // Explicitly disable signing |
| 58 | pluginPath: pluginDir, |
| 59 | destination: tempDir, |
| 60 | } |
| 61 | |
| 62 | // Run the package command |
| 63 | out := &bytes.Buffer{} |
| 64 | err := o.run(out) |
| 65 | |
| 66 | // Should succeed without error |
| 67 | if err != nil { |
| 68 | t.Errorf("unexpected error: %v", err) |
| 69 | } |
| 70 | |
| 71 | // Check that tarball was created with plugin name and version |
| 72 | tarballPath := filepath.Join(tempDir, "test-plugin-1.0.0.tgz") |
| 73 | if _, err := os.Stat(tarballPath); os.IsNotExist(err) { |
| 74 | t.Error("tarball should exist when sign=false") |
| 75 | } |
| 76 | |
| 77 | // Check that no .prov file was created |
| 78 | provPath := tarballPath + ".prov" |
| 79 | if _, err := os.Stat(provPath); !os.IsNotExist(err) { |
| 80 | t.Error("provenance file should not exist when sign=false") |
| 81 | } |
| 82 | |
| 83 | // Output should contain warning about skipping signing |
| 84 | output := out.String() |
| 85 | if !strings.Contains(output, "WARNING: Skipping plugin signing") { |
| 86 | t.Error("should print warning when signing is skipped") |
| 87 | } |
| 88 | if !strings.Contains(output, "Successfully packaged") { |
| 89 | t.Error("should print success message") |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | func TestPluginPackageDefaultRequiresSigning(t *testing.T) { |
| 94 | // Create a test plugin directory |