@@ -494,6 +494,14 @@ func TestAccKubernetesProvider_config_path(t *testing.T) {
494494 PlanOnly : true ,
495495 ExpectNonEmptyPlan : true ,
496496 },
497+ {
498+ Config : testAccKubernetesProviderConfig (
499+ providerConfig_config_path ("./testdata/kubeconfig" ) +
500+ providerConfig_config_context ("test-context" ),
501+ ),
502+ PlanOnly : true ,
503+ ExpectNonEmptyPlan : true ,
504+ },
497505 {
498506 Config : testAccKubernetesProviderConfig (
499507 providerConfig_config_path ("./missing/file" ),
@@ -523,8 +531,27 @@ func TestAccKubernetesProvider_config_path(t *testing.T) {
523531 {
524532 Config : testAccKubernetesProviderConfig (
525533 providerConfig_config_path ("./testdata/kubeconfig" ) +
526- providerConfig_config_context ("test-context" ),
534+ providerConfig_cluster_ca_certificate ("test-ca-cert" ),
535+ ),
536+ ExpectError : regexp .MustCompile (`"config_path": conflicts with cluster_ca_certificate` ),
537+ PlanOnly : true ,
538+ ExpectNonEmptyPlan : true ,
539+ },
540+ {
541+ Config : testAccKubernetesProviderConfig (
542+ providerConfig_config_path ("./testdata/kubeconfig" ) +
543+ providerConfig_client_cert ("test-client-cert" ),
527544 ),
545+ ExpectError : regexp .MustCompile (`"config_path": conflicts with client_certificate` ),
546+ PlanOnly : true ,
547+ ExpectNonEmptyPlan : true ,
548+ },
549+ {
550+ Config : testAccKubernetesProviderConfig (
551+ providerConfig_config_path ("./testdata/kubeconfig" ) +
552+ providerConfig_client_key ("test-client-key" ),
553+ ),
554+ ExpectError : regexp .MustCompile (`"config_path": conflicts with client_key` ),
528555 PlanOnly : true ,
529556 ExpectNonEmptyPlan : true ,
530557 },
@@ -539,7 +566,7 @@ func TestAccKubernetesProvider_config_paths(t *testing.T) {
539566 Steps : []resource.TestStep {
540567 {
541568 Config : testAccKubernetesProviderConfig (
542- providerConfig_config_paths (`["./testdata/kubeconfig"]` ),
569+ providerConfig_config_paths (`["./testdata/kubeconfig", "./testdata/kubeconfig" ]` ),
543570 ),
544571 PlanOnly : true ,
545572 ExpectNonEmptyPlan : true ,
@@ -569,13 +596,6 @@ func TestAccKubernetesProvider_config_paths(t *testing.T) {
569596 PlanOnly : true ,
570597 ExpectNonEmptyPlan : true ,
571598 },
572- {
573- Config : testAccKubernetesProviderConfig (
574- providerConfig_config_paths (`["./testdata/kubeconfig", "./testdata/kubeconfig"]` ),
575- ),
576- PlanOnly : true ,
577- ExpectNonEmptyPlan : true ,
578- },
579599 },
580600 })
581601}
@@ -608,8 +628,6 @@ func TestAccKubernetesProvider_config_paths_env(t *testing.T) {
608628}
609629
610630func TestAccKubernetesProvider_config_paths_env_wantError (t * testing.T ) {
611- wantError := `"config_path": conflicts with config_paths`
612-
613631 resource .Test (t , resource.TestCase {
614632 PreCheck : func () {
615633 testAccPreCheckInternal_setEnv (t , map [string ]string {
@@ -624,7 +642,7 @@ func TestAccKubernetesProvider_config_paths_env_wantError(t *testing.T) {
624642 Steps : []resource.TestStep {
625643 {
626644 Config : testAccKubernetesProviderConfig ("# empty" ),
627- ExpectError : regexp .MustCompile (wantError ),
645+ ExpectError : regexp .MustCompile (`"config_path": conflicts with config_paths` ),
628646 PlanOnly : true ,
629647 ExpectNonEmptyPlan : true ,
630648 },
@@ -633,8 +651,6 @@ func TestAccKubernetesProvider_config_paths_env_wantError(t *testing.T) {
633651}
634652
635653func TestAccKubernetesProvider_config_paths_host_env_wantError (t * testing.T ) {
636- wantError := `"config_paths": conflicts with host`
637-
638654 resource .Test (t , resource.TestCase {
639655 PreCheck : func () {
640656 testAccPreCheckInternal_setEnv (t , map [string ]string {
@@ -649,9 +665,46 @@ func TestAccKubernetesProvider_config_paths_host_env_wantError(t *testing.T) {
649665 Steps : []resource.TestStep {
650666 {
651667 Config : testAccKubernetesProviderConfig ("# empty" ),
652- ExpectError : regexp .MustCompile (wantError ),
668+ ExpectError : regexp .MustCompile (`"config_paths": conflicts with host` ),
669+ PlanOnly : true ,
670+ ExpectNonEmptyPlan : true ,
671+ },
672+ },
673+ })
674+ }
675+
676+ func TestAccKubernetesProvider_token (t * testing.T ) {
677+
678+ resource .Test (t , resource.TestCase {
679+ PreCheck : func () { testAccPreCheckInternal (t ) },
680+ ProviderFactories : testAccProviderFactoriesInternal ,
681+ Steps : []resource.TestStep {
682+ {
683+ Config : testAccKubernetesProviderConfig (
684+ providerConfig_token ("test-token" ) +
685+ providerConfig_host ("https://test-host" ),
686+ ),
687+ PlanOnly : true ,
688+ ExpectNonEmptyPlan : true ,
689+ },
690+ {
691+ Config : testAccKubernetesProviderConfig (
692+ providerConfig_token ("test-token" ) +
693+ providerConfig_host ("test-host" ),
694+ ),
695+ PlanOnly : true ,
696+ ExpectNonEmptyPlan : true ,
697+ // "token": all of `host,token` must be specified
698+ ExpectError : regexp .MustCompile (`Error: expected "host" to have a host, got test-host` ),
699+ },
700+ {
701+ Config : testAccKubernetesProviderConfig (
702+ providerConfig_token ("test-token" ),
703+ ),
653704 PlanOnly : true ,
654705 ExpectNonEmptyPlan : true ,
706+ // "token": all of `host,token` must be specified
707+ ExpectError : regexp .MustCompile ("host,token" ),
655708 },
656709 },
657710 })
@@ -697,7 +750,7 @@ func providerConfig_token(token string) string {
697750` , token )
698751}
699752
700- func providerConfig_ca_cert (ca_cert string ) string {
753+ func providerConfig_cluster_ca_certificate (ca_cert string ) string {
701754 return fmt .Sprintf (`
702755 cluster_ca_certificate = "%s"
703756` , ca_cert )
0 commit comments