forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_me_api_oauth2_client_test.go
45 lines (41 loc) · 1.51 KB
/
data_me_api_oauth2_client_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
package ovh
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
// Tests valid configurations to create oauth2 clients
func TestAccMeApiOauth2Client_data(t *testing.T) {
const resourceName = "ovh_me_api_oauth2_client.service_account_1"
// Successful test with app required parameters,
// that validates the use of the data instruction
const okConfigClientCredentials = `
resource "ovh_me_api_oauth2_client" "service_account_1" {
description = "tf acc test client credentials"
name = "tf acc test client credentials"
flow = "CLIENT_CREDENTIALS"
}
data "ovh_me_api_oauth2_client" "service_account_1" {
client_id = ovh_me_api_oauth2_client.service_account_1.client_id
depends_on = [ovh_me_api_oauth2_client.service_account_1]
}
output "oauth2_client_name" {
value = data.ovh_me_api_oauth2_client.service_account_1.name
}`
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckCredentials(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
// Create the object, check that the client secret is not empty after creation
{
Config: okConfigClientCredentials,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrWith(resourceName, "client_id", apiOauth2ClientStringNotEmpty),
resource.TestCheckResourceAttrWith(resourceName, "client_secret", apiOauth2ClientStringNotEmpty),
resource.TestCheckOutput(
"oauth2_client_name", "tf acc test client credentials",
),
),
},
},
})
}