forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_cloud_project_kube_oidc_test.go
81 lines (74 loc) · 2.04 KB
/
resource_cloud_project_kube_oidc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
var testAccCloudProjectKubeOIDCConfig = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
}
resource "ovh_cloud_project_kube_oidc" "my-oidc" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
client_id = "%s"
issuer_url = "%s"
}
`
func TestAccCloudProjectKubeOIDC_full(t *testing.T) {
region := os.Getenv("OVH_CLOUD_PROJECT_KUBE_REGION_TEST")
name := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(
testAccCloudProjectKubeOIDCConfig,
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
name,
region,
"my-oidc-client-id",
"https://ovh.com",
)
configUpdated := fmt.Sprintf(
testAccCloudProjectKubeOIDCConfig,
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
name,
region,
"my-another-oidc-client-id",
"https://docs.ovh.com",
)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckCloud(t)
testAccCheckCloudProjectExists(t)
testAccPreCheckKubernetes(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"ovh_cloud_project_kube_oidc.my-oidc", "client_id", "my-oidc-client-id"),
resource.TestCheckResourceAttr(
"ovh_cloud_project_kube_oidc.my-oidc", "issuer_url", "https://ovh.com"),
),
},
{
Config: configUpdated,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"ovh_cloud_project_kube_oidc.my-oidc", "client_id", "my-another-oidc-client-id"),
resource.TestCheckResourceAttr(
"ovh_cloud_project_kube_oidc.my-oidc", "issuer_url", "https://docs.ovh.com"),
),
},
{
Config: configUpdated,
Destroy: true,
ResourceName: "ovh_cloud_project_kube_oidc.my-oidc",
},
},
})
}