@@ -3204,17 +3204,54 @@ tests per UrlMap.`,
32043204 Required: true,
32053205 Description: `Path portion of the URL.`,
32063206 },
3207- "service": {
3208- Type: schema.TypeString,
3209- Required: true,
3210- DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
3211- Description: `The backend service or backend bucket link that should be matched by this test.`,
3212- },
32133207 "description": {
32143208 Type: schema.TypeString,
32153209 Optional: true,
32163210 Description: `Description of this test case.`,
32173211 },
3212+ "expected_output_url": {
3213+ Type: schema.TypeString,
3214+ Optional: true,
3215+ Description: `The expected output URL evaluated by the load balancer containing the scheme, host, path and query parameters.
3216+
3217+ 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.
3218+
3219+ 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.
3220+
3221+ expectedOutputUrl is optional when service is specified.`,
3222+ },
3223+ "expected_redirect_response_code": {
3224+ Type: schema.TypeInt,
3225+ Optional: true,
3226+ Description: `For rules with urlRedirect, the test passes only if expectedRedirectResponseCode matches the HTTP status code in load balancer's redirect response.
3227+
3228+ expectedRedirectResponseCode cannot be set when service is set.`,
3229+ },
3230+ "headers": {
3231+ Type: schema.TypeList,
3232+ Optional: true,
3233+ Description: `HTTP headers for this request.`,
3234+ Elem: &schema.Resource{
3235+ Schema: map[string]*schema.Schema{
3236+ "name": {
3237+ Type: schema.TypeString,
3238+ Required: true,
3239+ Description: `Header name.`,
3240+ },
3241+ "value": {
3242+ Type: schema.TypeString,
3243+ Required: true,
3244+ Description: `Header value.`,
3245+ },
3246+ },
3247+ },
3248+ },
3249+ "service": {
3250+ Type: schema.TypeString,
3251+ Optional: true,
3252+ DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
3253+ Description: `The backend service or backend bucket link that should be matched by this test.`,
3254+ },
32183255 },
32193256 },
32203257 },
@@ -6504,10 +6541,13 @@ func flattenComputeUrlMapTest(v interface{}, d *schema.ResourceData, config *tra
65046541 continue
65056542 }
65066543 transformed = append(transformed, map[string]interface{}{
6507- "description": flattenComputeUrlMapTestDescription(original["description"], d, config),
6508- "host": flattenComputeUrlMapTestHost(original["host"], d, config),
6509- "path": flattenComputeUrlMapTestPath(original["path"], d, config),
6510- "service": flattenComputeUrlMapTestService(original["service"], d, config),
6544+ "description": flattenComputeUrlMapTestDescription(original["description"], d, config),
6545+ "host": flattenComputeUrlMapTestHost(original["host"], d, config),
6546+ "path": flattenComputeUrlMapTestPath(original["path"], d, config),
6547+ "headers": flattenComputeUrlMapTestHeaders(original["headers"], d, config),
6548+ "service": flattenComputeUrlMapTestService(original["service"], d, config),
6549+ "expected_output_url": flattenComputeUrlMapTestExpectedOutputUrl(original["expectedOutputUrl"], d, config),
6550+ "expected_redirect_response_code": flattenComputeUrlMapTestExpectedRedirectResponseCode(original["expectedRedirectResponseCode"], d, config),
65116551 })
65126552 }
65136553 return transformed
@@ -6524,13 +6564,61 @@ func flattenComputeUrlMapTestPath(v interface{}, d *schema.ResourceData, config
65246564 return v
65256565}
65266566
6567+ func flattenComputeUrlMapTestHeaders(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6568+ if v == nil {
6569+ return v
6570+ }
6571+ l := v.([]interface{})
6572+ transformed := make([]interface{}, 0, len(l))
6573+ for _, raw := range l {
6574+ original := raw.(map[string]interface{})
6575+ if len(original) < 1 {
6576+ // Do not include empty json objects coming back from the api
6577+ continue
6578+ }
6579+ transformed = append(transformed, map[string]interface{}{
6580+ "name": flattenComputeUrlMapTestHeadersName(original["name"], d, config),
6581+ "value": flattenComputeUrlMapTestHeadersValue(original["value"], d, config),
6582+ })
6583+ }
6584+ return transformed
6585+ }
6586+ func flattenComputeUrlMapTestHeadersName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6587+ return v
6588+ }
6589+
6590+ func flattenComputeUrlMapTestHeadersValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6591+ return v
6592+ }
6593+
65276594func flattenComputeUrlMapTestService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
65286595 if v == nil {
65296596 return v
65306597 }
65316598 return tpgresource.ConvertSelfLinkToV1(v.(string))
65326599}
65336600
6601+ func flattenComputeUrlMapTestExpectedOutputUrl(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6602+ return v
6603+ }
6604+
6605+ func flattenComputeUrlMapTestExpectedRedirectResponseCode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6606+ // Handles the string fixed64 format
6607+ if strVal, ok := v.(string); ok {
6608+ if intVal, err := tpgresource.StringToFixed64(strVal); err == nil {
6609+ return intVal
6610+ }
6611+ }
6612+
6613+ // number values are represented as float64
6614+ if floatVal, ok := v.(float64); ok {
6615+ intVal := int(floatVal)
6616+ return intVal
6617+ }
6618+
6619+ return v // let terraform core handle it otherwise
6620+ }
6621+
65346622func flattenComputeUrlMapDefaultUrlRedirect(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
65356623 if v == nil {
65366624 return nil
@@ -11236,13 +11324,34 @@ func expandComputeUrlMapTest(v interface{}, d tpgresource.TerraformResourceData,
1123611324 transformed["path"] = transformedPath
1123711325 }
1123811326
11327+ transformedHeaders, err := expandComputeUrlMapTestHeaders(original["headers"], d, config)
11328+ if err != nil {
11329+ return nil, err
11330+ } else if val := reflect.ValueOf(transformedHeaders); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11331+ transformed["headers"] = transformedHeaders
11332+ }
11333+
1123911334 transformedService, err := expandComputeUrlMapTestService(original["service"], d, config)
1124011335 if err != nil {
1124111336 return nil, err
1124211337 } else if val := reflect.ValueOf(transformedService); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1124311338 transformed["service"] = transformedService
1124411339 }
1124511340
11341+ transformedExpectedOutputUrl, err := expandComputeUrlMapTestExpectedOutputUrl(original["expected_output_url"], d, config)
11342+ if err != nil {
11343+ return nil, err
11344+ } else if val := reflect.ValueOf(transformedExpectedOutputUrl); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11345+ transformed["expectedOutputUrl"] = transformedExpectedOutputUrl
11346+ }
11347+
11348+ transformedExpectedRedirectResponseCode, err := expandComputeUrlMapTestExpectedRedirectResponseCode(original["expected_redirect_response_code"], d, config)
11349+ if err != nil {
11350+ return nil, err
11351+ } else if val := reflect.ValueOf(transformedExpectedRedirectResponseCode); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11352+ transformed["expectedRedirectResponseCode"] = transformedExpectedRedirectResponseCode
11353+ }
11354+
1124611355 req = append(req, transformed)
1124711356 }
1124811357 return req, nil
@@ -11260,6 +11369,43 @@ func expandComputeUrlMapTestPath(v interface{}, d tpgresource.TerraformResourceD
1126011369 return v, nil
1126111370}
1126211371
11372+ func expandComputeUrlMapTestHeaders(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11373+ l := v.([]interface{})
11374+ req := make([]interface{}, 0, len(l))
11375+ for _, raw := range l {
11376+ if raw == nil {
11377+ continue
11378+ }
11379+ original := raw.(map[string]interface{})
11380+ transformed := make(map[string]interface{})
11381+
11382+ transformedName, err := expandComputeUrlMapTestHeadersName(original["name"], d, config)
11383+ if err != nil {
11384+ return nil, err
11385+ } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11386+ transformed["name"] = transformedName
11387+ }
11388+
11389+ transformedValue, err := expandComputeUrlMapTestHeadersValue(original["value"], d, config)
11390+ if err != nil {
11391+ return nil, err
11392+ } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11393+ transformed["value"] = transformedValue
11394+ }
11395+
11396+ req = append(req, transformed)
11397+ }
11398+ return req, nil
11399+ }
11400+
11401+ func expandComputeUrlMapTestHeadersName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11402+ return v, nil
11403+ }
11404+
11405+ func expandComputeUrlMapTestHeadersValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11406+ return v, nil
11407+ }
11408+
1126311409func expandComputeUrlMapTestService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1126411410 // This method returns a full self link from whatever the input is.
1126511411 if v == nil || v.(string) == "" {
@@ -11292,6 +11438,14 @@ func expandComputeUrlMapTestService(v interface{}, d tpgresource.TerraformResour
1129211438 return f.RelativeLink(), nil
1129311439}
1129411440
11441+ func expandComputeUrlMapTestExpectedOutputUrl(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11442+ return v, nil
11443+ }
11444+
11445+ func expandComputeUrlMapTestExpectedRedirectResponseCode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11446+ return v, nil
11447+ }
11448+
1129511449func expandComputeUrlMapDefaultUrlRedirect(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1129611450 l := v.([]interface{})
1129711451 if len(l) == 0 || l[0] == nil {
0 commit comments