This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
resource_auth0_tenant_test.go
150 lines (143 loc) · 5.93 KB
/
resource_auth0_tenant_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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package auth0
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
func TestAccTenant(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep{
{
Config: testAccTenantConfigCreate,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "change_password.0.enabled", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "change_password.0.html", "<html>Change Password</html>"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "guardian_mfa_page.0.enabled", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "guardian_mfa_page.0.html", "<html>MFA</html>"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "default_audience", ""),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "default_directory", ""),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "error_page.0.html", "<html>Error Page</html>"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "error_page.0.show_log_link", "false"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "error_page.0.url", "https://mycompany.org/error"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "friendly_name", "My Test Tenant"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "picture_url", "https://mycompany.org/logo.png"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "support_email", "support@mycompany.org"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "support_url", "https://mycompany.org/support"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "allowed_logout_urls.0", "https://mycompany.org/logoutCallback"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "session_lifetime", "720"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "sandbox_version", "12"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "idle_session_lifetime", "72"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "enabled_locales.0", "en"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "enabled_locales.1", "de"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "enabled_locales.2", "fr"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.universal_login", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.disable_clickjack_protection_headers", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.enable_public_signup_user_exists_error", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.use_scope_descriptions_for_consent", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "universal_login.0.colors.0.primary", "#0059d6"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "universal_login.0.colors.0.page_background", "#000000"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "default_redirection_uri", "https://example.com/login"),
),
},
{
Config: testAccTenantConfigUpdate,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "enabled_locales.0", "de"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "enabled_locales.1", "fr"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.disable_clickjack_protection_headers", "false"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.enable_public_signup_user_exists_error", "true"),
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.use_scope_descriptions_for_consent", "false"),
),
},
},
})
}
const testAccTenantConfigCreate = `
resource "auth0_tenant" "my_tenant" {
change_password {
enabled = true
html = "<html>Change Password</html>"
}
guardian_mfa_page {
enabled = true
html = "<html>MFA</html>"
}
default_audience = ""
default_directory = ""
error_page {
html = "<html>Error Page</html>"
show_log_link = false
url = "https://mycompany.org/error"
}
friendly_name = "My Test Tenant"
picture_url = "https://mycompany.org/logo.png"
support_email = "support@mycompany.org"
support_url = "https://mycompany.org/support"
allowed_logout_urls = [
"https://mycompany.org/logoutCallback"
]
session_lifetime = 720
sandbox_version = "12"
idle_session_lifetime = 72
enabled_locales = ["en", "de", "fr"]
flags {
universal_login = true
disable_clickjack_protection_headers = true
enable_public_signup_user_exists_error = true
use_scope_descriptions_for_consent = true
}
universal_login {
colors {
primary = "#0059d6"
page_background = "#000000"
}
}
default_redirection_uri = "https://example.com/login"
}
`
const testAccTenantConfigUpdate = `
resource "auth0_tenant" "my_tenant" {
change_password {
enabled = true
html = "<html>Change Password</html>"
}
guardian_mfa_page {
enabled = true
html = "<html>MFA</html>"
}
default_audience = ""
default_directory = ""
error_page {
html = "<html>Error Page</html>"
show_log_link = false
url = "https://mycompany.org/error"
}
friendly_name = "My Test Tenant"
picture_url = "https://mycompany.org/logo.png"
support_email = "support@mycompany.org"
support_url = "https://mycompany.org/support"
allowed_logout_urls = [
"https://mycompany.org/logoutCallback"
]
session_lifetime = 720
sandbox_version = "12"
idle_session_lifetime = 72
enabled_locales = ["de", "fr"]
flags {
universal_login = true
enable_public_signup_user_exists_error = true
disable_clickjack_protection_headers = false # <---- disable and test
use_scope_descriptions_for_consent = false #
}
universal_login {
colors {
primary = "#0059d6"
page_background = "#000000"
}
}
default_redirection_uri = "https://example.com/login"
}
`