@@ -82,7 +82,7 @@ func TestAccKongUpstream(t *testing.T) {
8282 ),
8383 },
8484 {
85- Config : testUpdateUpstreamConfig ,
85+ Config : fmt . Sprintf ( testUpdateUpstreamConfig , testCert1 , testKey1 ) ,
8686 Check : resource .ComposeTestCheckFunc (
8787 testAccCheckKongUpstreamExists ("kong_upstream.upstream" ),
8888 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "name" , "MyUpstream" ),
@@ -94,6 +94,33 @@ func TestAccKongUpstream(t *testing.T) {
9494 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "hash_on_cookie" , "CookieName" ),
9595 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "hash_on_cookie_path" , "/path" ),
9696
97+ resource .TestCheckResourceAttr ("kong_upstream.upstream" , "host_header" , "x-host" ),
98+ resource .TestCheckResourceAttr ("kong_upstream.upstream" , "tags.#" , "2" ),
99+ resource .TestCheckResourceAttr ("kong_upstream.upstream" , "tags.0" , "a" ),
100+ resource .TestCheckResourceAttr ("kong_upstream.upstream" , "tags.1" , "b" ),
101+ func (s * terraform.State ) error {
102+ module := s .RootModule ()
103+ cert , ok := module .Resources ["kong_certificate.certificate" ]
104+ if ! ok {
105+ return fmt .Errorf ("could not find certificate resource" )
106+ }
107+
108+ service , ok := module .Resources ["kong_upstream.upstream" ]
109+ if ! ok {
110+ return fmt .Errorf ("could not find upstream resource" )
111+ }
112+
113+ v , ok := service .Primary .Attributes ["client_certificate_id" ]
114+ if ! ok {
115+ return fmt .Errorf ("could not find client_certificate_id property" )
116+ }
117+
118+ if v != cert .Primary .ID {
119+ return fmt .Errorf ("client_certificate_id does not match certificate id" )
120+ }
121+ return nil
122+ },
123+
97124 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "healthchecks.0.active.0.type" , "https" ),
98125 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "healthchecks.0.active.0.timeout" , "10" ),
99126 resource .TestCheckResourceAttr ("kong_upstream.upstream" , "healthchecks.0.active.0.concurrency" , "20" ),
@@ -1048,6 +1075,16 @@ resource "kong_upstream" "upstream" {
10481075}
10491076`
10501077const testUpdateUpstreamConfig = `
1078+ resource "kong_certificate" "certificate" {
1079+ certificate = <<EOF
1080+ %s
1081+ EOF
1082+ private_key = <<EOF
1083+ %s
1084+ EOF
1085+ snis = ["foo.com"]
1086+ }
1087+
10511088resource "kong_upstream" "upstream" {
10521089 name = "MyUpstream"
10531090 slots = 20
@@ -1057,6 +1094,10 @@ resource "kong_upstream" "upstream" {
10571094 hash_fallback_header = "FallbackHeaderName"
10581095 hash_on_cookie = "CookieName"
10591096 hash_on_cookie_path = "/path"
1097+ host_header = "x-host"
1098+ tags = ["a", "b"]
1099+ client_certificate_id = kong_certificate.certificate.id
1100+
10601101 healthchecks {
10611102 active {
10621103 type = "https"
0 commit comments