@@ -39,6 +39,35 @@ func TestAccConsumerKeyAuth(t *testing.T) {
39
39
})
40
40
}
41
41
42
+ func TestAccConsumerKeyAuthComputed (t * testing.T ) {
43
+
44
+ resource .Test (t , resource.TestCase {
45
+ Providers : testAccProviders ,
46
+ CheckDestroy : testAccCheckConsumerKeyAuthDestroy ,
47
+ Steps : []resource.TestStep {
48
+ {
49
+ Config : testCreateConsumerKeyAuthConfigKeyComputed ,
50
+ Check : resource .ComposeTestCheckFunc (
51
+ testAccCheckConsumerKeyAuthExists ("kong_consumer_key_auth.consumer_key_auth" ),
52
+ resource .TestCheckResourceAttrSet ("kong_consumer_key_auth.consumer_key_auth" , "key" ),
53
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "tags.#" , "1" ),
54
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "tags.0" , "myTag" ),
55
+ ),
56
+ },
57
+ {
58
+ Config : testUpdateConsumerKeyAuthConfig ,
59
+ Check : resource .ComposeTestCheckFunc (
60
+ testAccCheckConsumerKeyAuthExists ("kong_consumer_key_auth.consumer_key_auth" ),
61
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "key" , "foo_updated" ),
62
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "tags.#" , "2" ),
63
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "tags.0" , "myTag" ),
64
+ resource .TestCheckResourceAttr ("kong_consumer_key_auth.consumer_key_auth" , "tags.1" , "anotherTag" ),
65
+ ),
66
+ },
67
+ },
68
+ })
69
+ }
70
+
42
71
func testAccCheckConsumerKeyAuthDestroy (state * terraform.State ) error {
43
72
44
73
client := testAccProvider .Meta ().(* config ).adminClient .KeyAuths
@@ -125,3 +154,18 @@ resource "kong_consumer_key_auth" "consumer_key_auth" {
125
154
tags = ["myTag", "anotherTag"]
126
155
}
127
156
`
157
+ const testCreateConsumerKeyAuthConfigKeyComputed = `
158
+ resource "kong_consumer" "my_consumer" {
159
+ username = "User1"
160
+ custom_id = "123"
161
+ }
162
+
163
+ resource "kong_plugin" "key_auth_plugin" {
164
+ name = "key-auth"
165
+ }
166
+
167
+ resource "kong_consumer_key_auth" "consumer_key_auth" {
168
+ consumer_id = "${kong_consumer.my_consumer.id}"
169
+ tags = ["myTag"]
170
+ }
171
+ `
0 commit comments