(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func TestMetadataValidateVersion(t *testing.T) { |
| 78 | testValid := map[string]struct { |
| 79 | version string |
| 80 | }{ |
| 81 | "valid semver": {version: "1.0.0"}, |
| 82 | "valid semver with prerelease": {version: "1.2.3-alpha.1+build.123"}, |
| 83 | "empty version": {version: ""}, |
| 84 | } |
| 85 | |
| 86 | testInvalid := map[string]struct { |
| 87 | version string |
| 88 | }{ |
| 89 | "valid semver with v prefix": {version: "v1.0.0"}, |
| 90 | "path traversal": {version: "../../../../tmp/evil"}, |
| 91 | "path traversal in version": {version: "1.0.0/../../etc"}, |
| 92 | "not a version": {version: "not-a-version"}, |
| 93 | } |
| 94 | |
| 95 | for name, tc := range testValid { |
| 96 | t.Run(name, func(t *testing.T) { |
| 97 | m := mockSubprocessCLIPlugin(t, "testplugin") |
| 98 | m.metadata.Version = tc.version |
| 99 | err := m.Metadata().Validate() |
| 100 | assert.NoError(t, err) |
| 101 | }) |
| 102 | } |
| 103 | |
| 104 | for name, tc := range testInvalid { |
| 105 | t.Run(name, func(t *testing.T) { |
| 106 | m := mockSubprocessCLIPlugin(t, "testplugin") |
| 107 | m.metadata.Version = tc.version |
| 108 | err := m.Metadata().Validate() |
| 109 | assert.ErrorContains(t, err, "invalid plugin version") |
| 110 | }) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestMetadataValidateMultipleErrors(t *testing.T) { |
| 115 | // Create metadata with multiple validation issues |
nothing calls this directly
no test coverage detected
searching dependent graphs…