(t *testing.T)
| 183 | } |
| 184 | |
| 185 | func Test_ValidateInputCmd_StrictMode(t *testing.T) { |
| 186 | fs := afero.NewMemMapFs() |
| 187 | require.NoError(t, afero.WriteFile(fs, "/file.yaml", []byte("some: data"), 0o644)) |
| 188 | |
| 189 | // Mock validator: returns no error, but a violation. |
| 190 | outMock := &output.Output{ |
| 191 | PolicyCheck: []evaluator.Outcome{ |
| 192 | { |
| 193 | Failures: []evaluator.Result{ |
| 194 | {Message: "Some violation"}, |
| 195 | }, |
| 196 | }, |
| 197 | }, |
| 198 | } |
| 199 | |
| 200 | cmd, _ := setUpValidateInputCmd(mockValidate(outMock, nil), fs) |
| 201 | cmd.SetArgs([]string{ |
| 202 | "input", |
| 203 | "--file", "/file.yaml", |
| 204 | "--policy", `{"publicKey": "testkey"}`, |
| 205 | "--strict", "true", |
| 206 | }) |
| 207 | |
| 208 | utils.SetTestRekorPublicKey(t) |
| 209 | err := cmd.Execute() |
| 210 | assert.Error(t, err) |
| 211 | assert.Contains(t, err.Error(), "success criteria not met") |
| 212 | } |
| 213 | |
| 214 | func Test_ValidateInputCmd_NonStrictMode(t *testing.T) { |
| 215 | fs := afero.NewMemMapFs() |
nothing calls this directly
no test coverage detected