(t *testing.T)
| 391 | } |
| 392 | |
| 393 | func Test_ValidateImageCommandImages(t *testing.T) { |
| 394 | validateImageCmd := validateImageCmd(happyValidator()) |
| 395 | cmd := setUpCobra(validateImageCmd) |
| 396 | |
| 397 | client := fake.FakeClient{} |
| 398 | commonMockClient(&client) |
| 399 | ctx := utils.WithFS(context.Background(), afero.NewMemMapFs()) |
| 400 | ctx = oci.WithClient(ctx, &client) |
| 401 | cmd.SetContext(ctx) |
| 402 | |
| 403 | effectiveTimeTest := time.Now().UTC().Format(time.RFC3339Nano) |
| 404 | |
| 405 | images := `{ |
| 406 | "components": [ |
| 407 | { |
| 408 | "name": "bacon", |
| 409 | "containerImage": "registry.localhost/bacon:v2.0", |
| 410 | "source": { |
| 411 | "git": { |
| 412 | "url": "https://git.localhost/bacon.git", |
| 413 | "revision": "8abf15bef376e0e21f1f9e9c3d74483d5018f3d5" |
| 414 | } |
| 415 | } |
| 416 | }, |
| 417 | { |
| 418 | "name": "spam", |
| 419 | "containerImage": "registry.localhost/spam:v1.0", |
| 420 | "source": { |
| 421 | "git": { |
| 422 | "url": "https://git.localhost/spam.git", |
| 423 | "revision": "ded982e702e07bb7b6effafdc353db3fe172c83f" |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | ] |
| 428 | }` |
| 429 | |
| 430 | cmd.SetArgs(append(rootArgs, []string{ |
| 431 | "--images", |
| 432 | images, |
| 433 | "--policy", |
| 434 | fmt.Sprintf(`{"publicKey": %s}`, utils.TestPublicKeyJSON), |
| 435 | "--effective-time", |
| 436 | effectiveTimeTest, |
| 437 | }...)) |
| 438 | |
| 439 | var out bytes.Buffer |
| 440 | cmd.SetOut(&out) |
| 441 | |
| 442 | utils.SetTestRekorPublicKey(t) |
| 443 | |
| 444 | err := cmd.Execute() |
| 445 | assert.NoError(t, err) |
| 446 | assert.JSONEq(t, fmt.Sprintf(`{ |
| 447 | "success": true, |
| 448 | "ec-version": "development", |
| 449 | "effective-time": %q, |
| 450 | "key": %s, |
nothing calls this directly
no test coverage detected