forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cloud_project_kube_oidc_test.go
93 lines (81 loc) · 7.9 KB
/
data_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
82
83
84
85
86
87
88
89
90
91
92
93
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccCloudProjectKubeOIDCDataSource_basic(t *testing.T) {
name := acctest.RandomWithPrefix(test_prefix)
region := os.Getenv("OVH_CLOUD_PROJECT_KUBE_REGION_TEST")
config := fmt.Sprintf(
testAccCloudProjectKubeOIDCDataSourceConfig,
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
name,
region,
)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckKubernetes(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "client_id", "my-oidc-client-id"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "issuer_url", "https://www.ovhcloud.com/fr/"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_username_claim", "usrClaim"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_username_prefix", "usrPrefix"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_groups_claim.0", "grpClaim"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_groups_prefix", "grpPrefix"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_required_claim.0", "claim1=val1"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_required_claim.1", "claim2=val2"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_signing_algs.0", "RS512"),
resource.TestCheckResourceAttr(
"data.ovh_cloud_project_kube_oidc.oidcData", "oidc_ca_content", "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZhekNDQTFPZ0F3SUJBZ0lVYm9YRkZrL1hCQmdQUUI4UHlqbkttUGVWekNjd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1JURUxNQWtHQTFVRUJoTUNRVlV4RXpBUkJnTlZCQWdNQ2xOdmJXVXRVM1JoZEdVeElUQWZCZ05WQkFvTQpHRWx1ZEdWeWJtVjBJRmRwWkdkcGRITWdVSFI1SUV4MFpEQWVGdzB5TWpFd01UUXdOalE0TlROYUZ3MHlNekV3Ck1UUXdOalE0TlROYU1FVXhDekFKQmdOVkJBWVRBa0ZWTVJNd0VRWURWUVFJREFwVGIyMWxMVk4wWVhSbE1TRXcKSHdZRFZRUUtEQmhKYm5SbGNtNWxkQ0JYYVdSbmFYUnpJRkIwZVNCTWRHUXdnZ0lpTUEwR0NTcUdTSWIzRFFFQgpBUVVBQTRJQ0R3QXdnZ0lLQW9JQ0FRQytPMk53bGx2QTQyT05SUHMyZWlqTUp2UHhpN21RblVSS3FrOHJEV1VkCkwzZU0yM1JXeVhtS1AydDQ5Zi9LVGsweEZNVStOSTUzTEhwWmh6N3NpK3dEUFUvWWZWSS9rQmZsRm8zeVZCMSsKZWdCSnpyNGIrQ3FoaWlCUkh0Vm5LblFKUmdvOVJjVkxhRm82UEY0N1V0UWJ2bWVuNGdERnExVkYwVHhUdnFMdwpIMzRZL0U2QUJsSlZnWFBzaWQzNm54eTErNnlKV05vRXNVekFiekpWMHhzTGhxc2h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01Gc081bytORGQ5aFVBVzFoCjFLMjMwQnZzYldYYVo4MStIdTU4U1BsYTM5R3FMTG85MzR6dEs4WkRWNFRGTVJxMnNVQ1cxcWFidDh5ejd2RzAKSGV3dXdxelRwR1lTSFI1U0ZvMm45R0xKVUN4SnhxcDlOWVJjMlhUdXRUdkJESzVPMXFZZEJaQzd6cmcxSnczawp2SjI4UGx2TzBQRE42ZVlUdElJdC9yU05ZbW56eVVNRTRYREt0di9KRitLZWZNSWxDTkpzZDRHYXVTdlo5M1NOClhINmcrNEZvRkp4UzNxRmZ0WEc4czNRNnppNzNLRzh5UHZVNHU0WmZNRGd2aG92L0V5YkNLWUpFdVVZSlJWNGEKbmc3cWh3NDBabXQ0eWNCRzU5a2tFSGhNYWtxTWpPaUNkV2x4MEVjZXIxcEFGT1pqN3o1NktURXIxa0ZwUHVaRApjVER5SnNwTjh6dm9CQ0l1ancvQjR6S3kyWStOQitRR1p3dXhyTk9mRGR6ek9yQUE1Ym9OS2gwUUh4c0RxNTExClFaU3hCR21EcGJzN2QzMUQvQll3WEhIUWdwb3FoVUU5dFBGSThpN0pkM2FyeXZCdHlnTWlxSmt1VlRFVk1Ta0UKNTZ0VnFsMjlXenFhRXNrbDN3VUlmczVKKzN3RzRPcWNxRDdXaGQxWUtnc0VUMjdFTWlqVXZIYzQ4TXE0bU1rPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="),
),
},
},
})
}
var testAccCloudProjectKubeOIDCDataSourceConfig = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
}
resource "ovh_cloud_project_kube_oidc" "oidc" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
client_id = "my-oidc-client-id"
issuer_url = "https://www.ovhcloud.com/fr/"
oidc_username_claim = "usrClaim"
oidc_username_prefix = "usrPrefix"
oidc_groups_claim = ["grpClaim"]
oidc_groups_prefix = "grpPrefix"
oidc_required_claim = ["claim1=val1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VlUdElJdC9yU05ZbW56eVVNRTRYREt0di9KRitLZWZNSWxDTkpzZDRHYXVTdlo5M1NOClhINmcrNEZvRkp4UzNxRmZ0WEc4czNRNnppNzNLRzh5UHZVNHU0WmZNRGd2aG92L0V5YkNLWUpFdVVZSlJWNGEKbmc3cWh3NDBabXQ0eWNCRzU5a2tFSGhNYWtxTWpPaUNkV2x4MEVjZXIxcEFGT1pqN3o1NktURXIxa0ZwUHVaRApjVER5SnNwTjh6dm9CQ0l1ancvQjR6S3kyWStOQitRR1p3dXhyTk9mRGR6ek9yQUE1Ym9OS2gwUUh4c0RxNTExClFaU3hCR21EcGJzN2QzMUQvQll3WEhIUWdwb3FoVUU5dFBGSThpN0pkM2FyeXZCdHlnTWlxSmt1VlRFVk1Ta0UKNTZ0VnFsMjlXenFhRXNrbDN3VUlmczVKKzN3RzRPcWNxRDdXaGQxWUtnc0VUMjdFTWlqVXZIYzQ4TXE0bU1rPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
depends_on = [
ovh_cloud_project_kube.cluster
]
}
data "ovh_cloud_project_kube_oidc" "oidcData" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
depends_on = [
ovh_cloud_project_kube_oidc.oidc
]
}
`