@@ -2838,17 +2838,54 @@ tests per UrlMap.`,
2838
2838
Required : true ,
2839
2839
Description : `Path portion of the URL.` ,
2840
2840
},
2841
- "service" : {
2842
- Type : schema .TypeString ,
2843
- Required : true ,
2844
- DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
2845
- Description : `The backend service or backend bucket link that should be matched by this test.` ,
2846
- },
2847
2841
"description" : {
2848
2842
Type : schema .TypeString ,
2849
2843
Optional : true ,
2850
2844
Description : `Description of this test case.` ,
2851
2845
},
2846
+ "expected_output_url" : {
2847
+ Type : schema .TypeString ,
2848
+ Optional : true ,
2849
+ Description : `The expected output URL evaluated by the load balancer containing the scheme, host, path and query parameters.
2850
+
2851
+ For rules that forward requests to backends, the test passes only when expectedOutputUrl matches the request forwarded by the load balancer to backends. For rules with urlRewrite, the test verifies that the forwarded request matches hostRewrite and pathPrefixRewrite in the urlRewrite action. When service is specified, expectedOutputUrl's scheme is ignored.
2852
+
2853
+ For rules with urlRedirect, the test passes only if expectedOutputUrl matches the URL in the load balancer's redirect response. If urlRedirect specifies httpsRedirect, the test passes only if the scheme in expectedOutputUrl is also set to HTTPS. If urlRedirect specifies stripQuery, the test passes only if expectedOutputUrl does not contain any query parameters.
2854
+
2855
+ expectedOutputUrl is optional when service is specified.` ,
2856
+ },
2857
+ "expected_redirect_response_code" : {
2858
+ Type : schema .TypeInt ,
2859
+ Optional : true ,
2860
+ Description : `For rules with urlRedirect, the test passes only if expectedRedirectResponseCode matches the HTTP status code in load balancer's redirect response.
2861
+
2862
+ expectedRedirectResponseCode cannot be set when service is set.` ,
2863
+ },
2864
+ "headers" : {
2865
+ Type : schema .TypeList ,
2866
+ Optional : true ,
2867
+ Description : `HTTP headers for this request.` ,
2868
+ Elem : & schema.Resource {
2869
+ Schema : map [string ]* schema.Schema {
2870
+ "name" : {
2871
+ Type : schema .TypeString ,
2872
+ Required : true ,
2873
+ Description : `Header name.` ,
2874
+ },
2875
+ "value" : {
2876
+ Type : schema .TypeString ,
2877
+ Required : true ,
2878
+ Description : `Header value.` ,
2879
+ },
2880
+ },
2881
+ },
2882
+ },
2883
+ "service" : {
2884
+ Type : schema .TypeString ,
2885
+ Optional : true ,
2886
+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
2887
+ Description : `The backend service or backend bucket link that should be matched by this test.` ,
2888
+ },
2852
2889
},
2853
2890
},
2854
2891
},
@@ -5768,10 +5805,13 @@ func flattenComputeUrlMapTest(v interface{}, d *schema.ResourceData, config *tra
5768
5805
continue
5769
5806
}
5770
5807
transformed = append (transformed , map [string ]interface {}{
5771
- "description" : flattenComputeUrlMapTestDescription (original ["description" ], d , config ),
5772
- "host" : flattenComputeUrlMapTestHost (original ["host" ], d , config ),
5773
- "path" : flattenComputeUrlMapTestPath (original ["path" ], d , config ),
5774
- "service" : flattenComputeUrlMapTestService (original ["service" ], d , config ),
5808
+ "description" : flattenComputeUrlMapTestDescription (original ["description" ], d , config ),
5809
+ "host" : flattenComputeUrlMapTestHost (original ["host" ], d , config ),
5810
+ "path" : flattenComputeUrlMapTestPath (original ["path" ], d , config ),
5811
+ "headers" : flattenComputeUrlMapTestHeaders (original ["headers" ], d , config ),
5812
+ "service" : flattenComputeUrlMapTestService (original ["service" ], d , config ),
5813
+ "expected_output_url" : flattenComputeUrlMapTestExpectedOutputUrl (original ["expectedOutputUrl" ], d , config ),
5814
+ "expected_redirect_response_code" : flattenComputeUrlMapTestExpectedRedirectResponseCode (original ["expectedRedirectResponseCode" ], d , config ),
5775
5815
})
5776
5816
}
5777
5817
return transformed
@@ -5788,13 +5828,61 @@ func flattenComputeUrlMapTestPath(v interface{}, d *schema.ResourceData, config
5788
5828
return v
5789
5829
}
5790
5830
5831
+ func flattenComputeUrlMapTestHeaders (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5832
+ if v == nil {
5833
+ return v
5834
+ }
5835
+ l := v .([]interface {})
5836
+ transformed := make ([]interface {}, 0 , len (l ))
5837
+ for _ , raw := range l {
5838
+ original := raw .(map [string ]interface {})
5839
+ if len (original ) < 1 {
5840
+ // Do not include empty json objects coming back from the api
5841
+ continue
5842
+ }
5843
+ transformed = append (transformed , map [string ]interface {}{
5844
+ "name" : flattenComputeUrlMapTestHeadersName (original ["name" ], d , config ),
5845
+ "value" : flattenComputeUrlMapTestHeadersValue (original ["value" ], d , config ),
5846
+ })
5847
+ }
5848
+ return transformed
5849
+ }
5850
+ func flattenComputeUrlMapTestHeadersName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5851
+ return v
5852
+ }
5853
+
5854
+ func flattenComputeUrlMapTestHeadersValue (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5855
+ return v
5856
+ }
5857
+
5791
5858
func flattenComputeUrlMapTestService (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5792
5859
if v == nil {
5793
5860
return v
5794
5861
}
5795
5862
return tpgresource .ConvertSelfLinkToV1 (v .(string ))
5796
5863
}
5797
5864
5865
+ func flattenComputeUrlMapTestExpectedOutputUrl (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5866
+ return v
5867
+ }
5868
+
5869
+ func flattenComputeUrlMapTestExpectedRedirectResponseCode (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5870
+ // Handles the string fixed64 format
5871
+ if strVal , ok := v .(string ); ok {
5872
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
5873
+ return intVal
5874
+ }
5875
+ }
5876
+
5877
+ // number values are represented as float64
5878
+ if floatVal , ok := v .(float64 ); ok {
5879
+ intVal := int (floatVal )
5880
+ return intVal
5881
+ }
5882
+
5883
+ return v // let terraform core handle it otherwise
5884
+ }
5885
+
5798
5886
func flattenComputeUrlMapDefaultUrlRedirect (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
5799
5887
if v == nil {
5800
5888
return nil
@@ -10018,13 +10106,34 @@ func expandComputeUrlMapTest(v interface{}, d tpgresource.TerraformResourceData,
10018
10106
transformed ["path" ] = transformedPath
10019
10107
}
10020
10108
10109
+ transformedHeaders , err := expandComputeUrlMapTestHeaders (original ["headers" ], d , config )
10110
+ if err != nil {
10111
+ return nil , err
10112
+ } else if val := reflect .ValueOf (transformedHeaders ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10113
+ transformed ["headers" ] = transformedHeaders
10114
+ }
10115
+
10021
10116
transformedService , err := expandComputeUrlMapTestService (original ["service" ], d , config )
10022
10117
if err != nil {
10023
10118
return nil , err
10024
10119
} else if val := reflect .ValueOf (transformedService ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10025
10120
transformed ["service" ] = transformedService
10026
10121
}
10027
10122
10123
+ transformedExpectedOutputUrl , err := expandComputeUrlMapTestExpectedOutputUrl (original ["expected_output_url" ], d , config )
10124
+ if err != nil {
10125
+ return nil , err
10126
+ } else if val := reflect .ValueOf (transformedExpectedOutputUrl ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10127
+ transformed ["expectedOutputUrl" ] = transformedExpectedOutputUrl
10128
+ }
10129
+
10130
+ transformedExpectedRedirectResponseCode , err := expandComputeUrlMapTestExpectedRedirectResponseCode (original ["expected_redirect_response_code" ], d , config )
10131
+ if err != nil {
10132
+ return nil , err
10133
+ } else if val := reflect .ValueOf (transformedExpectedRedirectResponseCode ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10134
+ transformed ["expectedRedirectResponseCode" ] = transformedExpectedRedirectResponseCode
10135
+ }
10136
+
10028
10137
req = append (req , transformed )
10029
10138
}
10030
10139
return req , nil
@@ -10042,6 +10151,43 @@ func expandComputeUrlMapTestPath(v interface{}, d tpgresource.TerraformResourceD
10042
10151
return v , nil
10043
10152
}
10044
10153
10154
+ func expandComputeUrlMapTestHeaders (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10155
+ l := v .([]interface {})
10156
+ req := make ([]interface {}, 0 , len (l ))
10157
+ for _ , raw := range l {
10158
+ if raw == nil {
10159
+ continue
10160
+ }
10161
+ original := raw .(map [string ]interface {})
10162
+ transformed := make (map [string ]interface {})
10163
+
10164
+ transformedName , err := expandComputeUrlMapTestHeadersName (original ["name" ], d , config )
10165
+ if err != nil {
10166
+ return nil , err
10167
+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10168
+ transformed ["name" ] = transformedName
10169
+ }
10170
+
10171
+ transformedValue , err := expandComputeUrlMapTestHeadersValue (original ["value" ], d , config )
10172
+ if err != nil {
10173
+ return nil , err
10174
+ } else if val := reflect .ValueOf (transformedValue ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
10175
+ transformed ["value" ] = transformedValue
10176
+ }
10177
+
10178
+ req = append (req , transformed )
10179
+ }
10180
+ return req , nil
10181
+ }
10182
+
10183
+ func expandComputeUrlMapTestHeadersName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10184
+ return v , nil
10185
+ }
10186
+
10187
+ func expandComputeUrlMapTestHeadersValue (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10188
+ return v , nil
10189
+ }
10190
+
10045
10191
func expandComputeUrlMapTestService (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10046
10192
// This method returns a full self link from whatever the input is.
10047
10193
if v == nil || v .(string ) == "" {
@@ -10074,6 +10220,14 @@ func expandComputeUrlMapTestService(v interface{}, d tpgresource.TerraformResour
10074
10220
return f .RelativeLink (), nil
10075
10221
}
10076
10222
10223
+ func expandComputeUrlMapTestExpectedOutputUrl (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10224
+ return v , nil
10225
+ }
10226
+
10227
+ func expandComputeUrlMapTestExpectedRedirectResponseCode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10228
+ return v , nil
10229
+ }
10230
+
10077
10231
func expandComputeUrlMapDefaultUrlRedirect (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10078
10232
l := v .([]interface {})
10079
10233
if len (l ) == 0 || l [0 ] == nil {
0 commit comments