|
1 | 1 | #!/usr/bin/env bats
|
2 | 2 |
|
| 3 | +# |
| 4 | +# Copyright (c) HashiCorp, Inc. |
| 5 | +# SPDX-License-Identifier: BUSL-1.1 |
| 6 | +# |
| 7 | + |
3 | 8 | load _helpers
|
4 | 9 |
|
5 | 10 | #--------------------------------------------------------------------
|
@@ -398,3 +403,139 @@ load _helpers
|
398 | 403 | actual=$(echo "$object" | yq '.spec.gcp.projectID' | tee /dev/stderr)
|
399 | 404 | [ "${actual}" = "my-project" ]
|
400 | 405 | }
|
| 406 | + |
| 407 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/default" { |
| 408 | + cd "$(chart_dir)" |
| 409 | + local actual |
| 410 | + actual=$(helm template \ |
| 411 | + --debug \ |
| 412 | + -s templates/default-vault-auth-method.yaml \ |
| 413 | + --set 'defaultAuthMethod.enabled=true' \ |
| 414 | + . | tee /dev/stderr | |
| 415 | + yq '.spec' | tee /dev/stderr) |
| 416 | + |
| 417 | + [ "$(echo "$actual" | yq '. | has("vaultAuthGlobalRef")')" = "false" ] |
| 418 | +} |
| 419 | + |
| 420 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/enabled" { |
| 421 | + cd "$(chart_dir)" |
| 422 | + local actual |
| 423 | + actual=$(helm template \ |
| 424 | + --debug \ |
| 425 | + -s templates/default-vault-auth-method.yaml \ |
| 426 | + --set 'defaultAuthMethod.enabled=true' \ |
| 427 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 428 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 429 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 430 | + . | tee /dev/stderr | |
| 431 | + yq '.spec' | tee /dev/stderr) |
| 432 | + |
| 433 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef | has("allowDefault")')" = "false" ] |
| 434 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 435 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 436 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.params')" = "none" ] |
| 437 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.headers')" = "none" ] |
| 438 | +} |
| 439 | + |
| 440 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/defaults/empty-params" { |
| 441 | + cd "$(chart_dir)" |
| 442 | + local actual |
| 443 | + actual=$(helm template \ |
| 444 | + --debug \ |
| 445 | + -s templates/default-vault-auth-method.yaml \ |
| 446 | + --set 'defaultAuthMethod.enabled=true' \ |
| 447 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 448 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 449 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 450 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.mergeStrategy.params=' \ |
| 451 | + . | tee /dev/stderr | |
| 452 | + yq '.spec' | tee /dev/stderr) |
| 453 | + |
| 454 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef | has("allowDefault")')" = "false" ] |
| 455 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 456 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 457 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy | has("params")')" = "false" ] |
| 458 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.headers')" = "none" ] |
| 459 | +} |
| 460 | + |
| 461 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/mergeStrategy/empty-headers" { |
| 462 | + cd "$(chart_dir)" |
| 463 | + local actual |
| 464 | + actual=$(helm template \ |
| 465 | + --debug \ |
| 466 | + -s templates/default-vault-auth-method.yaml \ |
| 467 | + --set 'defaultAuthMethod.enabled=true' \ |
| 468 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 469 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 470 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 471 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.mergeStrategy.headers=' \ |
| 472 | + . | tee /dev/stderr | |
| 473 | + yq '.spec' | tee /dev/stderr) |
| 474 | + |
| 475 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef | has("allowDefault")')" = "false" ] |
| 476 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 477 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 478 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.params')" = "none" ] |
| 479 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy | has("headers")')" = "false" ] |
| 480 | +} |
| 481 | + |
| 482 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/allowDefault=true" { |
| 483 | + cd "$(chart_dir)" |
| 484 | + local actual |
| 485 | + actual=$(helm template \ |
| 486 | + --debug \ |
| 487 | + -s templates/default-vault-auth-method.yaml \ |
| 488 | + --set 'defaultAuthMethod.enabled=true' \ |
| 489 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 490 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 491 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 492 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.allowDefault=true' \ |
| 493 | + . | tee /dev/stderr | |
| 494 | + yq '.spec' | tee /dev/stderr) |
| 495 | + |
| 496 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.allowDefault')" = "true" ] |
| 497 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 498 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 499 | +} |
| 500 | + |
| 501 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/allowDefault=false" { |
| 502 | + cd "$(chart_dir)" |
| 503 | + local actual |
| 504 | + actual=$(helm template \ |
| 505 | + --debug \ |
| 506 | + -s templates/default-vault-auth-method.yaml \ |
| 507 | + --set 'defaultAuthMethod.enabled=true' \ |
| 508 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 509 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 510 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 511 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.allowDefault=false' \ |
| 512 | + . | tee /dev/stderr | |
| 513 | + yq '.spec' | tee /dev/stderr) |
| 514 | + |
| 515 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.allowDefault')" = "false" ] |
| 516 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 517 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 518 | +} |
| 519 | + |
| 520 | +@test "defaultAuthMethod/CR: with vaultAuthGlobalRef/mergeStrategy/params=union-headers=replace" { |
| 521 | + cd "$(chart_dir)" |
| 522 | + local actual |
| 523 | + actual=$(helm template \ |
| 524 | + --debug \ |
| 525 | + -s templates/default-vault-auth-method.yaml \ |
| 526 | + --set 'defaultAuthMethod.enabled=true' \ |
| 527 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.enabled=true' \ |
| 528 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.name=foo' \ |
| 529 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.namespace=baz' \ |
| 530 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.allowDefault=false' \ |
| 531 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.mergeStrategy.params=union' \ |
| 532 | + --set 'defaultAuthMethod.vaultAuthGlobalRef.mergeStrategy.headers=replace' \ |
| 533 | + . | tee /dev/stderr | |
| 534 | + yq '.spec' | tee /dev/stderr) |
| 535 | + |
| 536 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.allowDefault')" = "false" ] |
| 537 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.name')" = "foo" ] |
| 538 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.namespace')" = "baz" ] |
| 539 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.params')" = "union" ] |
| 540 | + [ "$(echo "$actual" | yq '.vaultAuthGlobalRef.mergeStrategy.headers')" = "replace" ] |
| 541 | +} |
0 commit comments