github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/aws/cloudfront_distribution_configuration_structure_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/aws/aws-sdk-go/aws"
     8  	"github.com/hashicorp/terraform/helper/schema"
     9  )
    10  
    11  func defaultCacheBehaviorConf() map[string]interface{} {
    12  	return map[string]interface{}{
    13  		"viewer_protocol_policy": "allow-all",
    14  		"target_origin_id":       "myS3Origin",
    15  		"forwarded_values":       schema.NewSet(forwardedValuesHash, []interface{}{forwardedValuesConf()}),
    16  		"min_ttl":                86400,
    17  		"trusted_signers":        trustedSignersConf(),
    18  		"max_ttl":                365000000,
    19  		"smooth_streaming":       false,
    20  		"default_ttl":            86400,
    21  		"allowed_methods":        allowedMethodsConf(),
    22  		"cached_methods":         cachedMethodsConf(),
    23  		"compress":               true,
    24  	}
    25  }
    26  
    27  func cacheBehaviorConf1() map[string]interface{} {
    28  	cb := defaultCacheBehaviorConf()
    29  	cb["path_pattern"] = "/path1"
    30  	return cb
    31  }
    32  
    33  func cacheBehaviorConf2() map[string]interface{} {
    34  	cb := defaultCacheBehaviorConf()
    35  	cb["path_pattern"] = "/path2"
    36  	return cb
    37  }
    38  
    39  func cacheBehaviorsConf() *schema.Set {
    40  	return schema.NewSet(cacheBehaviorHash, []interface{}{cacheBehaviorConf1(), cacheBehaviorConf2()})
    41  }
    42  
    43  func trustedSignersConf() []interface{} {
    44  	return []interface{}{"1234567890EX", "1234567891EX"}
    45  }
    46  
    47  func forwardedValuesConf() map[string]interface{} {
    48  	return map[string]interface{}{
    49  		"query_string": true,
    50  		"cookies":      schema.NewSet(cookiePreferenceHash, []interface{}{cookiePreferenceConf()}),
    51  		"headers":      headersConf(),
    52  	}
    53  }
    54  
    55  func headersConf() []interface{} {
    56  	return []interface{}{"X-Example1", "X-Example2"}
    57  }
    58  
    59  func cookiePreferenceConf() map[string]interface{} {
    60  	return map[string]interface{}{
    61  		"forward":           "whitelist",
    62  		"whitelisted_names": cookieNamesConf(),
    63  	}
    64  }
    65  
    66  func cookieNamesConf() []interface{} {
    67  	return []interface{}{"Example1", "Example2"}
    68  }
    69  
    70  func allowedMethodsConf() []interface{} {
    71  	return []interface{}{"DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"}
    72  }
    73  
    74  func cachedMethodsConf() []interface{} {
    75  	return []interface{}{"GET", "HEAD", "OPTIONS"}
    76  }
    77  
    78  func originCustomHeadersConf() *schema.Set {
    79  	return schema.NewSet(originCustomHeaderHash, []interface{}{originCustomHeaderConf1(), originCustomHeaderConf2()})
    80  }
    81  
    82  func originCustomHeaderConf1() map[string]interface{} {
    83  	return map[string]interface{}{
    84  		"name":  "X-Custom-Header1",
    85  		"value": "samplevalue",
    86  	}
    87  }
    88  
    89  func originCustomHeaderConf2() map[string]interface{} {
    90  	return map[string]interface{}{
    91  		"name":  "X-Custom-Header2",
    92  		"value": "samplevalue",
    93  	}
    94  }
    95  
    96  func customOriginConf() map[string]interface{} {
    97  	return map[string]interface{}{
    98  		"origin_protocol_policy": "http-only",
    99  		"http_port":              80,
   100  		"https_port":             443,
   101  		"origin_ssl_protocols":   customOriginSslProtocolsConf(),
   102  	}
   103  }
   104  
   105  func customOriginSslProtocolsConf() []interface{} {
   106  	return []interface{}{"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}
   107  }
   108  
   109  func s3OriginConf() map[string]interface{} {
   110  	return map[string]interface{}{
   111  		"origin_access_identity": "origin-access-identity/cloudfront/E127EXAMPLE51Z",
   112  	}
   113  }
   114  
   115  func originWithCustomConf() map[string]interface{} {
   116  	return map[string]interface{}{
   117  		"origin_id":            "CustomOrigin",
   118  		"domain_name":          "www.example.com",
   119  		"origin_path":          "/",
   120  		"custom_origin_config": schema.NewSet(customOriginConfigHash, []interface{}{customOriginConf()}),
   121  		"custom_header":        originCustomHeadersConf(),
   122  	}
   123  }
   124  func originWithS3Conf() map[string]interface{} {
   125  	return map[string]interface{}{
   126  		"origin_id":        "S3Origin",
   127  		"domain_name":      "s3.example.com",
   128  		"origin_path":      "/",
   129  		"s3_origin_config": schema.NewSet(s3OriginConfigHash, []interface{}{s3OriginConf()}),
   130  		"custom_header":    originCustomHeadersConf(),
   131  	}
   132  }
   133  
   134  func multiOriginConf() *schema.Set {
   135  	return schema.NewSet(originHash, []interface{}{originWithCustomConf(), originWithS3Conf()})
   136  }
   137  
   138  func geoRestrictionWhitelistConf() map[string]interface{} {
   139  	return map[string]interface{}{
   140  		"restriction_type": "whitelist",
   141  		"locations":        []interface{}{"CA", "GB", "US"},
   142  	}
   143  }
   144  
   145  func geoRestrictionsConf() map[string]interface{} {
   146  	return map[string]interface{}{
   147  		"geo_restriction": schema.NewSet(geoRestrictionHash, []interface{}{geoRestrictionWhitelistConf()}),
   148  	}
   149  }
   150  
   151  func geoRestrictionConfNoItems() map[string]interface{} {
   152  	return map[string]interface{}{
   153  		"restriction_type": "none",
   154  	}
   155  }
   156  
   157  func customErrorResponsesConf() []interface{} {
   158  	return []interface{}{
   159  		map[string]interface{}{
   160  			"error_code":            404,
   161  			"error_caching_min_ttl": 30,
   162  			"response_code":         200,
   163  			"response_page_path":    "/error-pages/404.html",
   164  		},
   165  		map[string]interface{}{
   166  			"error_code":            403,
   167  			"error_caching_min_ttl": 15,
   168  			"response_code":         404,
   169  			"response_page_path":    "/error-pages/404.html",
   170  		},
   171  	}
   172  }
   173  
   174  func aliasesConf() *schema.Set {
   175  	return schema.NewSet(aliasesHash, []interface{}{"example.com", "www.example.com"})
   176  }
   177  
   178  func loggingConfigConf() map[string]interface{} {
   179  	return map[string]interface{}{
   180  		"include_cookies": false,
   181  		"bucket":          "mylogs.s3.amazonaws.com",
   182  		"prefix":          "myprefix",
   183  	}
   184  }
   185  
   186  func customErrorResponsesConfSet() *schema.Set {
   187  	return schema.NewSet(customErrorResponseHash, customErrorResponsesConf())
   188  }
   189  
   190  func customErrorResponsesConfFirst() map[string]interface{} {
   191  	return customErrorResponsesConf()[0].(map[string]interface{})
   192  }
   193  
   194  func customErrorResponseConfNoResponseCode() map[string]interface{} {
   195  	er := customErrorResponsesConf()[0].(map[string]interface{})
   196  	er["response_code"] = 0
   197  	er["response_page_path"] = ""
   198  	return er
   199  }
   200  
   201  func viewerCertificateConfSetCloudFrontDefault() map[string]interface{} {
   202  	return map[string]interface{}{
   203  		"acm_certificate_arn":            "",
   204  		"cloudfront_default_certificate": true,
   205  		"iam_certificate_id":             "",
   206  		"minimum_protocol_version":       "",
   207  		"ssl_support_method":             "",
   208  	}
   209  }
   210  
   211  func viewerCertificateConfSetIAM() map[string]interface{} {
   212  	return map[string]interface{}{
   213  		"acm_certificate_arn":            "",
   214  		"cloudfront_default_certificate": false,
   215  		"iam_certificate_id":             "iamcert-01234567",
   216  		"ssl_support_method":             "vip",
   217  		"minimum_protocol_version":       "TLSv1",
   218  	}
   219  }
   220  
   221  func viewerCertificateConfSetACM() map[string]interface{} {
   222  	return map[string]interface{}{
   223  		"acm_certificate_arn":            "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012",
   224  		"cloudfront_default_certificate": false,
   225  		"iam_certificate_id":             "",
   226  		"ssl_support_method":             "sni-only",
   227  		"minimum_protocol_version":       "TLSv1",
   228  	}
   229  }
   230  
   231  func TestCloudFrontStructure_expandDefaultCacheBehavior(t *testing.T) {
   232  	data := defaultCacheBehaviorConf()
   233  	dcb := expandDefaultCacheBehavior(data)
   234  	if *dcb.Compress != true {
   235  		t.Fatalf("Expected Compress to be true, got %v", *dcb.Compress)
   236  	}
   237  	if *dcb.ViewerProtocolPolicy != "allow-all" {
   238  		t.Fatalf("Expected ViewerProtocolPolicy to be allow-all, got %v", *dcb.ViewerProtocolPolicy)
   239  	}
   240  	if *dcb.TargetOriginId != "myS3Origin" {
   241  		t.Fatalf("Expected TargetOriginId to be allow-all, got %v", *dcb.TargetOriginId)
   242  	}
   243  	if reflect.DeepEqual(dcb.ForwardedValues.Headers.Items, expandStringList(headersConf())) != true {
   244  		t.Fatalf("Expected Items to be %v, got %v", headersConf(), dcb.ForwardedValues.Headers.Items)
   245  	}
   246  	if *dcb.MinTTL != 86400 {
   247  		t.Fatalf("Expected MinTTL to be 86400, got %v", *dcb.MinTTL)
   248  	}
   249  	if reflect.DeepEqual(dcb.TrustedSigners.Items, expandStringList(trustedSignersConf())) != true {
   250  		t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", trustedSignersConf(), dcb.TrustedSigners.Items)
   251  	}
   252  	if *dcb.MaxTTL != 365000000 {
   253  		t.Fatalf("Expected MaxTTL to be 86400, got %v", *dcb.MaxTTL)
   254  	}
   255  	if *dcb.SmoothStreaming != false {
   256  		t.Fatalf("Expected SmoothStreaming to be false, got %v", *dcb.SmoothStreaming)
   257  	}
   258  	if *dcb.DefaultTTL != 86400 {
   259  		t.Fatalf("Expected DefaultTTL to be 86400, got %v", *dcb.DefaultTTL)
   260  	}
   261  	if reflect.DeepEqual(dcb.AllowedMethods.Items, expandStringList(allowedMethodsConf())) != true {
   262  		t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", allowedMethodsConf(), dcb.AllowedMethods.Items)
   263  	}
   264  	if reflect.DeepEqual(dcb.AllowedMethods.CachedMethods.Items, expandStringList(cachedMethodsConf())) != true {
   265  		t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", cachedMethodsConf(), dcb.AllowedMethods.CachedMethods.Items)
   266  	}
   267  }
   268  
   269  func TestCloudFrontStructure_flattenDefaultCacheBehavior(t *testing.T) {
   270  	in := defaultCacheBehaviorConf()
   271  	dcb := expandDefaultCacheBehavior(in)
   272  	out := flattenDefaultCacheBehavior(dcb)
   273  	diff := schema.NewSet(defaultCacheBehaviorHash, []interface{}{in}).Difference(out)
   274  
   275  	if len(diff.List()) > 0 {
   276  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   277  	}
   278  }
   279  
   280  func TestCloudFrontStructure_expandCacheBehavior(t *testing.T) {
   281  	data := cacheBehaviorConf1()
   282  	cb := expandCacheBehavior(data)
   283  	if *cb.Compress != true {
   284  		t.Fatalf("Expected Compress to be true, got %v", *cb.Compress)
   285  	}
   286  	if *cb.ViewerProtocolPolicy != "allow-all" {
   287  		t.Fatalf("Expected ViewerProtocolPolicy to be allow-all, got %v", *cb.ViewerProtocolPolicy)
   288  	}
   289  	if *cb.TargetOriginId != "myS3Origin" {
   290  		t.Fatalf("Expected TargetOriginId to be myS3Origin, got %v", *cb.TargetOriginId)
   291  	}
   292  	if reflect.DeepEqual(cb.ForwardedValues.Headers.Items, expandStringList(headersConf())) != true {
   293  		t.Fatalf("Expected Items to be %v, got %v", headersConf(), cb.ForwardedValues.Headers.Items)
   294  	}
   295  	if *cb.MinTTL != 86400 {
   296  		t.Fatalf("Expected MinTTL to be 86400, got %v", *cb.MinTTL)
   297  	}
   298  	if reflect.DeepEqual(cb.TrustedSigners.Items, expandStringList(trustedSignersConf())) != true {
   299  		t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", trustedSignersConf(), cb.TrustedSigners.Items)
   300  	}
   301  	if *cb.MaxTTL != 365000000 {
   302  		t.Fatalf("Expected MaxTTL to be 365000000, got %v", *cb.MaxTTL)
   303  	}
   304  	if *cb.SmoothStreaming != false {
   305  		t.Fatalf("Expected SmoothStreaming to be false, got %v", *cb.SmoothStreaming)
   306  	}
   307  	if *cb.DefaultTTL != 86400 {
   308  		t.Fatalf("Expected DefaultTTL to be 86400, got %v", *cb.DefaultTTL)
   309  	}
   310  	if reflect.DeepEqual(cb.AllowedMethods.Items, expandStringList(allowedMethodsConf())) != true {
   311  		t.Fatalf("Expected AllowedMethods.Items to be %v, got %v", allowedMethodsConf(), cb.AllowedMethods.Items)
   312  	}
   313  	if reflect.DeepEqual(cb.AllowedMethods.CachedMethods.Items, expandStringList(cachedMethodsConf())) != true {
   314  		t.Fatalf("Expected AllowedMethods.CachedMethods.Items to be %v, got %v", cachedMethodsConf(), cb.AllowedMethods.CachedMethods.Items)
   315  	}
   316  	if *cb.PathPattern != "/path1" {
   317  		t.Fatalf("Expected PathPattern to be /path1, got %v", *cb.PathPattern)
   318  	}
   319  }
   320  
   321  func TestCloudFrontStructure_flattenCacheBehavior(t *testing.T) {
   322  	in := cacheBehaviorConf1()
   323  	cb := expandCacheBehavior(in)
   324  	out := flattenCacheBehavior(cb)
   325  	var diff *schema.Set
   326  	if out["compress"] != true {
   327  		t.Fatalf("Expected out[compress] to be true, got %v", out["compress"])
   328  	}
   329  	if out["viewer_protocol_policy"] != "allow-all" {
   330  		t.Fatalf("Expected out[viewer_protocol_policy] to be allow-all, got %v", out["viewer_protocol_policy"])
   331  	}
   332  	if out["target_origin_id"] != "myS3Origin" {
   333  		t.Fatalf("Expected out[target_origin_id] to be myS3Origin, got %v", out["target_origin_id"])
   334  	}
   335  	diff = out["forwarded_values"].(*schema.Set).Difference(in["forwarded_values"].(*schema.Set))
   336  	if len(diff.List()) > 0 {
   337  		t.Fatalf("Expected out[forwarded_values] to be %v, got %v, diff: %v", out["forwarded_values"], in["forwarded_values"], diff)
   338  	}
   339  	if out["min_ttl"] != int(86400) {
   340  		t.Fatalf("Expected out[min_ttl] to be 86400 (int), got %v", out["forwarded_values"])
   341  	}
   342  	if reflect.DeepEqual(out["trusted_signers"], in["trusted_signers"]) != true {
   343  		t.Fatalf("Expected out[trusted_signers] to be %v, got %v", in["trusted_signers"], out["trusted_signers"])
   344  	}
   345  	if out["max_ttl"] != int(365000000) {
   346  		t.Fatalf("Expected out[max_ttl] to be 365000000 (int), got %v", out["max_ttl"])
   347  	}
   348  	if out["smooth_streaming"] != false {
   349  		t.Fatalf("Expected out[smooth_streaming] to be false, got %v", out["smooth_streaming"])
   350  	}
   351  	if out["default_ttl"] != int(86400) {
   352  		t.Fatalf("Expected out[default_ttl] to be 86400 (int), got %v", out["default_ttl"])
   353  	}
   354  	if reflect.DeepEqual(out["allowed_methods"], in["allowed_methods"]) != true {
   355  		t.Fatalf("Expected out[allowed_methods] to be %v, got %v", in["allowed_methods"], out["allowed_methods"])
   356  	}
   357  	if reflect.DeepEqual(out["cached_methods"], in["cached_methods"]) != true {
   358  		t.Fatalf("Expected out[cached_methods] to be %v, got %v", in["cached_methods"], out["cached_methods"])
   359  	}
   360  	if out["path_pattern"] != "/path1" {
   361  		t.Fatalf("Expected out[path_pattern] to be /path1, got %v", out["path_pattern"])
   362  	}
   363  }
   364  
   365  func TestCloudFrontStructure_expandCacheBehaviors(t *testing.T) {
   366  	data := cacheBehaviorsConf()
   367  	cbs := expandCacheBehaviors(data)
   368  	if *cbs.Quantity != 2 {
   369  		t.Fatalf("Expected Quantity to be 2, got %v", *cbs.Quantity)
   370  	}
   371  	if *cbs.Items[0].TargetOriginId != "myS3Origin" {
   372  		t.Fatalf("Expected first Item's TargetOriginId to be 	myS3Origin, got %v", *cbs.Items[0].TargetOriginId)
   373  	}
   374  }
   375  
   376  func TestCloudFrontStructure_flattenCacheBehaviors(t *testing.T) {
   377  	in := cacheBehaviorsConf()
   378  	cbs := expandCacheBehaviors(in)
   379  	out := flattenCacheBehaviors(cbs)
   380  	diff := in.Difference(out)
   381  
   382  	if len(diff.List()) > 0 {
   383  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   384  	}
   385  }
   386  
   387  func TestCloudFrontStructure_expandTrustedSigners(t *testing.T) {
   388  	data := trustedSignersConf()
   389  	ts := expandTrustedSigners(data)
   390  	if *ts.Quantity != 2 {
   391  		t.Fatalf("Expected Quantity to be 2, got %v", *ts.Quantity)
   392  	}
   393  	if *ts.Enabled != true {
   394  		t.Fatalf("Expected Enabled to be true, got %v", *ts.Enabled)
   395  	}
   396  	if reflect.DeepEqual(ts.Items, expandStringList(data)) != true {
   397  		t.Fatalf("Expected Items to be %v, got %v", data, ts.Items)
   398  	}
   399  }
   400  
   401  func TestCloudFrontStructure_flattenTrustedSigners(t *testing.T) {
   402  	in := trustedSignersConf()
   403  	ts := expandTrustedSigners(in)
   404  	out := flattenTrustedSigners(ts)
   405  
   406  	if reflect.DeepEqual(in, out) != true {
   407  		t.Fatalf("Expected out to be %v, got %v", in, out)
   408  	}
   409  }
   410  
   411  func TestCloudFrontStructure_expandTrustedSigners_empty(t *testing.T) {
   412  	data := []interface{}{}
   413  	ts := expandTrustedSigners(data)
   414  	if *ts.Quantity != 0 {
   415  		t.Fatalf("Expected Quantity to be 2, got %v", *ts.Quantity)
   416  	}
   417  	if *ts.Enabled != false {
   418  		t.Fatalf("Expected Enabled to be true, got %v", *ts.Enabled)
   419  	}
   420  	if ts.Items != nil {
   421  		t.Fatalf("Expected Items to be nil, got %v", ts.Items)
   422  	}
   423  }
   424  
   425  func TestCloudFrontStructure_expandForwardedValues(t *testing.T) {
   426  	data := forwardedValuesConf()
   427  	fv := expandForwardedValues(data)
   428  	if *fv.QueryString != true {
   429  		t.Fatalf("Expected QueryString to be true, got %v", *fv.QueryString)
   430  	}
   431  	if reflect.DeepEqual(fv.Cookies.WhitelistedNames.Items, expandStringList(cookieNamesConf())) != true {
   432  		t.Fatalf("Expected Cookies.WhitelistedNames.Items to be %v, got %v", cookieNamesConf(), fv.Cookies.WhitelistedNames.Items)
   433  	}
   434  	if reflect.DeepEqual(fv.Headers.Items, expandStringList(headersConf())) != true {
   435  		t.Fatalf("Expected Headers.Items to be %v, got %v", headersConf(), fv.Headers.Items)
   436  	}
   437  }
   438  
   439  func TestCloudFrontStructure_flattenForwardedValues(t *testing.T) {
   440  	in := forwardedValuesConf()
   441  	fv := expandForwardedValues(in)
   442  	out := flattenForwardedValues(fv)
   443  
   444  	if out["query_string"] != true {
   445  		t.Fatalf("Expected out[query_string] to be true, got %v", out["query_string"])
   446  	}
   447  	if out["cookies"].(*schema.Set).Equal(in["cookies"].(*schema.Set)) != true {
   448  		t.Fatalf("Expected out[cookies] to be %v, got %v", in["cookies"], out["cookies"])
   449  	}
   450  	if reflect.DeepEqual(out["headers"], in["headers"]) != true {
   451  		t.Fatalf("Expected out[headers] to be %v, got %v", in["headers"], out["headers"])
   452  	}
   453  }
   454  
   455  func TestCloudFrontStructure_expandHeaders(t *testing.T) {
   456  	data := headersConf()
   457  	h := expandHeaders(data)
   458  	if *h.Quantity != 2 {
   459  		t.Fatalf("Expected Quantity to be 2, got %v", *h.Quantity)
   460  	}
   461  	if reflect.DeepEqual(h.Items, expandStringList(data)) != true {
   462  		t.Fatalf("Expected Items to be %v, got %v", data, h.Items)
   463  	}
   464  }
   465  
   466  func TestCloudFrontStructure_flattenHeaders(t *testing.T) {
   467  	in := headersConf()
   468  	h := expandHeaders(in)
   469  	out := flattenHeaders(h)
   470  
   471  	if reflect.DeepEqual(in, out) != true {
   472  		t.Fatalf("Expected out to be %v, got %v", in, out)
   473  	}
   474  }
   475  
   476  func TestCloudFrontStructure_expandCookiePreference(t *testing.T) {
   477  	data := cookiePreferenceConf()
   478  	cp := expandCookiePreference(data)
   479  	if *cp.Forward != "whitelist" {
   480  		t.Fatalf("Expected Forward to be whitelist, got %v", *cp.Forward)
   481  	}
   482  	if reflect.DeepEqual(cp.WhitelistedNames.Items, expandStringList(cookieNamesConf())) != true {
   483  		t.Fatalf("Expected WhitelistedNames.Items to be %v, got %v", cookieNamesConf(), cp.WhitelistedNames.Items)
   484  	}
   485  }
   486  
   487  func TestCloudFrontStructure_flattenCookiePreference(t *testing.T) {
   488  	in := cookiePreferenceConf()
   489  	cp := expandCookiePreference(in)
   490  	out := flattenCookiePreference(cp)
   491  
   492  	if reflect.DeepEqual(in, out) != true {
   493  		t.Fatalf("Expected out to be %v, got %v", in, out)
   494  	}
   495  }
   496  
   497  func TestCloudFrontStructure_expandCookieNames(t *testing.T) {
   498  	data := cookieNamesConf()
   499  	cn := expandCookieNames(data)
   500  	if *cn.Quantity != 2 {
   501  		t.Fatalf("Expected Quantity to be 2, got %v", *cn.Quantity)
   502  	}
   503  	if reflect.DeepEqual(cn.Items, expandStringList(data)) != true {
   504  		t.Fatalf("Expected Items to be %v, got %v", data, cn.Items)
   505  	}
   506  }
   507  
   508  func TestCloudFrontStructure_flattenCookieNames(t *testing.T) {
   509  	in := cookieNamesConf()
   510  	cn := expandCookieNames(in)
   511  	out := flattenCookieNames(cn)
   512  
   513  	if reflect.DeepEqual(in, out) != true {
   514  		t.Fatalf("Expected out to be %v, got %v", in, out)
   515  	}
   516  }
   517  
   518  func TestCloudFrontStructure_expandAllowedMethods(t *testing.T) {
   519  	data := allowedMethodsConf()
   520  	am := expandAllowedMethods(data)
   521  	if *am.Quantity != 7 {
   522  		t.Fatalf("Expected Quantity to be 3, got %v", *am.Quantity)
   523  	}
   524  	if reflect.DeepEqual(am.Items, expandStringList(data)) != true {
   525  		t.Fatalf("Expected Items to be %v, got %v", data, am.Items)
   526  	}
   527  }
   528  
   529  func TestCloudFrontStructure_flattenAllowedMethods(t *testing.T) {
   530  	in := allowedMethodsConf()
   531  	am := expandAllowedMethods(in)
   532  	out := flattenAllowedMethods(am)
   533  
   534  	if reflect.DeepEqual(in, out) != true {
   535  		t.Fatalf("Expected out to be %v, got %v", in, out)
   536  	}
   537  }
   538  
   539  func TestCloudFrontStructure_expandCachedMethods(t *testing.T) {
   540  	data := cachedMethodsConf()
   541  	cm := expandCachedMethods(data)
   542  	if *cm.Quantity != 3 {
   543  		t.Fatalf("Expected Quantity to be 3, got %v", *cm.Quantity)
   544  	}
   545  	if reflect.DeepEqual(cm.Items, expandStringList(data)) != true {
   546  		t.Fatalf("Expected Items to be %v, got %v", data, cm.Items)
   547  	}
   548  }
   549  
   550  func TestCloudFrontStructure_flattenCachedMethods(t *testing.T) {
   551  	in := cachedMethodsConf()
   552  	cm := expandCachedMethods(in)
   553  	out := flattenCachedMethods(cm)
   554  
   555  	if reflect.DeepEqual(in, out) != true {
   556  		t.Fatalf("Expected out to be %v, got %v", in, out)
   557  	}
   558  }
   559  
   560  func TestCloudFrontStructure_expandOrigins(t *testing.T) {
   561  	data := multiOriginConf()
   562  	origins := expandOrigins(data)
   563  	if *origins.Quantity != 2 {
   564  		t.Fatalf("Expected Quantity to be 2, got %v", *origins.Quantity)
   565  	}
   566  	if *origins.Items[0].OriginPath != "/" {
   567  		t.Fatalf("Expected first Item's OriginPath to be /, got %v", *origins.Items[0].OriginPath)
   568  	}
   569  }
   570  
   571  func TestCloudFrontStructure_flattenOrigins(t *testing.T) {
   572  	in := multiOriginConf()
   573  	origins := expandOrigins(in)
   574  	out := flattenOrigins(origins)
   575  	diff := in.Difference(out)
   576  
   577  	if len(diff.List()) > 0 {
   578  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   579  	}
   580  }
   581  
   582  func TestCloudFrontStructure_expandOrigin(t *testing.T) {
   583  	data := originWithCustomConf()
   584  	or := expandOrigin(data)
   585  	if *or.Id != "CustomOrigin" {
   586  		t.Fatalf("Expected Id to be CustomOrigin, got %v", *or.Id)
   587  	}
   588  	if *or.DomainName != "www.example.com" {
   589  		t.Fatalf("Expected DomainName to be www.example.com, got %v", *or.DomainName)
   590  	}
   591  	if *or.OriginPath != "/" {
   592  		t.Fatalf("Expected OriginPath to be /, got %v", *or.OriginPath)
   593  	}
   594  	if *or.CustomOriginConfig.OriginProtocolPolicy != "http-only" {
   595  		t.Fatalf("Expected CustomOriginConfig.OriginProtocolPolicy to be http-only, got %v", *or.CustomOriginConfig.OriginProtocolPolicy)
   596  	}
   597  	if *or.CustomHeaders.Items[0].HeaderValue != "samplevalue" {
   598  		t.Fatalf("Expected CustomHeaders.Items[0].HeaderValue to be samplevalue, got %v", *or.CustomHeaders.Items[0].HeaderValue)
   599  	}
   600  }
   601  
   602  func TestCloudFrontStructure_flattenOrigin(t *testing.T) {
   603  	in := originWithCustomConf()
   604  	or := expandOrigin(in)
   605  	out := flattenOrigin(or)
   606  
   607  	if out["origin_id"] != "CustomOrigin" {
   608  		t.Fatalf("Expected out[origin_id] to be CustomOrigin, got %v", out["origin_id"])
   609  	}
   610  	if out["domain_name"] != "www.example.com" {
   611  		t.Fatalf("Expected out[domain_name] to be www.example.com, got %v", out["domain_name"])
   612  	}
   613  	if out["origin_path"] != "/" {
   614  		t.Fatalf("Expected out[origin_path] to be /, got %v", out["origin_path"])
   615  	}
   616  	if out["custom_origin_config"].(*schema.Set).Equal(in["custom_origin_config"].(*schema.Set)) != true {
   617  		t.Fatalf("Expected out[custom_origin_config] to be %v, got %v", in["custom_origin_config"], out["custom_origin_config"])
   618  	}
   619  }
   620  
   621  func TestCloudFrontStructure_expandCustomHeaders(t *testing.T) {
   622  	in := originCustomHeadersConf()
   623  	chs := expandCustomHeaders(in)
   624  	if *chs.Quantity != 2 {
   625  		t.Fatalf("Expected Quantity to be 2, got %v", *chs.Quantity)
   626  	}
   627  	if *chs.Items[0].HeaderValue != "samplevalue" {
   628  		t.Fatalf("Expected first Item's HeaderValue to be samplevalue, got %v", *chs.Items[0].HeaderValue)
   629  	}
   630  }
   631  
   632  func TestCloudFrontStructure_flattenCustomHeaders(t *testing.T) {
   633  	in := originCustomHeadersConf()
   634  	chs := expandCustomHeaders(in)
   635  	out := flattenCustomHeaders(chs)
   636  	diff := in.Difference(out)
   637  
   638  	if len(diff.List()) > 0 {
   639  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   640  	}
   641  }
   642  
   643  func TestCloudFrontStructure_flattenOriginCustomHeader(t *testing.T) {
   644  	in := originCustomHeaderConf1()
   645  	och := expandOriginCustomHeader(in)
   646  	out := flattenOriginCustomHeader(och)
   647  
   648  	if out["name"] != "X-Custom-Header1" {
   649  		t.Fatalf("Expected out[name] to be X-Custom-Header1, got %v", out["name"])
   650  	}
   651  	if out["value"] != "samplevalue" {
   652  		t.Fatalf("Expected out[value] to be samplevalue, got %v", out["value"])
   653  	}
   654  }
   655  
   656  func TestCloudFrontStructure_expandOriginCustomHeader(t *testing.T) {
   657  	in := originCustomHeaderConf1()
   658  	och := expandOriginCustomHeader(in)
   659  
   660  	if *och.HeaderName != "X-Custom-Header1" {
   661  		t.Fatalf("Expected HeaderName to be X-Custom-Header1, got %v", *och.HeaderName)
   662  	}
   663  	if *och.HeaderValue != "samplevalue" {
   664  		t.Fatalf("Expected HeaderValue to be samplevalue, got %v", *och.HeaderValue)
   665  	}
   666  }
   667  
   668  func TestCloudFrontStructure_expandCustomOriginConfig(t *testing.T) {
   669  	data := customOriginConf()
   670  	co := expandCustomOriginConfig(data)
   671  	if *co.OriginProtocolPolicy != "http-only" {
   672  		t.Fatalf("Expected OriginProtocolPolicy to be http-only, got %v", *co.OriginProtocolPolicy)
   673  	}
   674  	if *co.HTTPPort != 80 {
   675  		t.Fatalf("Expected HTTPPort to be 80, got %v", *co.HTTPPort)
   676  	}
   677  	if *co.HTTPSPort != 443 {
   678  		t.Fatalf("Expected HTTPSPort to be 443, got %v", *co.HTTPSPort)
   679  	}
   680  }
   681  
   682  func TestCloudFrontStructure_flattenCustomOriginConfig(t *testing.T) {
   683  	in := customOriginConf()
   684  	co := expandCustomOriginConfig(in)
   685  	out := flattenCustomOriginConfig(co)
   686  
   687  	if reflect.DeepEqual(in, out) != true {
   688  		t.Fatalf("Expected out to be %v, got %v", in, out)
   689  	}
   690  }
   691  
   692  func TestCloudFrontStructure_expandCustomOriginConfigSSL(t *testing.T) {
   693  	in := customOriginSslProtocolsConf()
   694  	ocs := expandCustomOriginConfigSSL(in)
   695  	if *ocs.Quantity != 4 {
   696  		t.Fatalf("Expected Quantity to be 4, got %v", *ocs.Quantity)
   697  	}
   698  	if *ocs.Items[0] != "SSLv3" {
   699  		t.Fatalf("Expected first Item to be SSLv3, got %v", *ocs.Items[0])
   700  	}
   701  }
   702  
   703  func TestCloudFrontStructure_flattenCustomOriginConfigSSL(t *testing.T) {
   704  	in := customOriginSslProtocolsConf()
   705  	ocs := expandCustomOriginConfigSSL(in)
   706  	out := flattenCustomOriginConfigSSL(ocs)
   707  
   708  	if reflect.DeepEqual(in, out) != true {
   709  		t.Fatalf("Expected out to be %v, got %v", in, out)
   710  	}
   711  }
   712  
   713  func TestCloudFrontStructure_expandS3OriginConfig(t *testing.T) {
   714  	data := s3OriginConf()
   715  	s3o := expandS3OriginConfig(data)
   716  	if *s3o.OriginAccessIdentity != "origin-access-identity/cloudfront/E127EXAMPLE51Z" {
   717  		t.Fatalf("Expected OriginAccessIdentity to be origin-access-identity/cloudfront/E127EXAMPLE51Z, got %v", *s3o.OriginAccessIdentity)
   718  	}
   719  }
   720  
   721  func TestCloudFrontStructure_flattenS3OriginConfig(t *testing.T) {
   722  	in := s3OriginConf()
   723  	s3o := expandS3OriginConfig(in)
   724  	out := flattenS3OriginConfig(s3o)
   725  
   726  	if reflect.DeepEqual(in, out) != true {
   727  		t.Fatalf("Expected out to be %v, got %v", in, out)
   728  	}
   729  }
   730  
   731  func TestCloudFrontStructure_expandCustomErrorResponses(t *testing.T) {
   732  	data := customErrorResponsesConfSet()
   733  	ers := expandCustomErrorResponses(data)
   734  	if *ers.Quantity != 2 {
   735  		t.Fatalf("Expected Quantity to be 2, got %v", *ers.Quantity)
   736  	}
   737  	if *ers.Items[0].ResponsePagePath != "/error-pages/404.html" {
   738  		t.Fatalf("Expected ResponsePagePath in first Item to be /error-pages/404.html, got %v", *ers.Items[0].ResponsePagePath)
   739  	}
   740  }
   741  
   742  func TestCloudFrontStructure_flattenCustomErrorResponses(t *testing.T) {
   743  	in := customErrorResponsesConfSet()
   744  	ers := expandCustomErrorResponses(in)
   745  	out := flattenCustomErrorResponses(ers)
   746  
   747  	if in.Equal(out) != true {
   748  		t.Fatalf("Expected out to be %v, got %v", in, out)
   749  	}
   750  }
   751  
   752  func TestCloudFrontStructure_expandCustomErrorResponse(t *testing.T) {
   753  	data := customErrorResponsesConfFirst()
   754  	er := expandCustomErrorResponse(data)
   755  	if *er.ErrorCode != 404 {
   756  		t.Fatalf("Expected ErrorCode to be 404, got %v", *er.ErrorCode)
   757  	}
   758  	if *er.ErrorCachingMinTTL != 30 {
   759  		t.Fatalf("Expected ErrorCachingMinTTL to be 30, got %v", *er.ErrorCachingMinTTL)
   760  	}
   761  	if *er.ResponseCode != "200" {
   762  		t.Fatalf("Expected ResponseCode to be 200 (as string), got %v", *er.ResponseCode)
   763  	}
   764  	if *er.ResponsePagePath != "/error-pages/404.html" {
   765  		t.Fatalf("Expected ResponsePagePath to be /error-pages/404.html, got %v", *er.ResponsePagePath)
   766  	}
   767  }
   768  
   769  func TestCloudFrontStructure_expandCustomErrorResponse_emptyResponseCode(t *testing.T) {
   770  	data := customErrorResponseConfNoResponseCode()
   771  	er := expandCustomErrorResponse(data)
   772  	if *er.ResponseCode != "" {
   773  		t.Fatalf("Expected ResponseCode to be empty string, got %v", *er.ResponseCode)
   774  	}
   775  	if *er.ResponsePagePath != "" {
   776  		t.Fatalf("Expected ResponsePagePath to be empty string, got %v", *er.ResponsePagePath)
   777  	}
   778  }
   779  
   780  func TestCloudFrontStructure_flattenCustomErrorResponse(t *testing.T) {
   781  	in := customErrorResponsesConfFirst()
   782  	er := expandCustomErrorResponse(in)
   783  	out := flattenCustomErrorResponse(er)
   784  
   785  	if reflect.DeepEqual(in, out) != true {
   786  		t.Fatalf("Expected out to be %v, got %v", in, out)
   787  	}
   788  }
   789  
   790  func TestCloudFrontStructure_expandLoggingConfig(t *testing.T) {
   791  	data := loggingConfigConf()
   792  
   793  	lc := expandLoggingConfig(data)
   794  	if *lc.Enabled != true {
   795  		t.Fatalf("Expected Enabled to be true, got %v", *lc.Enabled)
   796  	}
   797  	if *lc.Prefix != "myprefix" {
   798  		t.Fatalf("Expected Prefix to be myprefix, got %v", *lc.Prefix)
   799  	}
   800  	if *lc.Bucket != "mylogs.s3.amazonaws.com" {
   801  		t.Fatalf("Expected Bucket to be mylogs.s3.amazonaws.com, got %v", *lc.Bucket)
   802  	}
   803  	if *lc.IncludeCookies != false {
   804  		t.Fatalf("Expected IncludeCookies to be false, got %v", *lc.IncludeCookies)
   805  	}
   806  }
   807  
   808  func TestCloudFrontStructure_expandLoggingConfig_nilValue(t *testing.T) {
   809  	lc := expandLoggingConfig(nil)
   810  	if *lc.Enabled != false {
   811  		t.Fatalf("Expected Enabled to be false, got %v", *lc.Enabled)
   812  	}
   813  	if *lc.Prefix != "" {
   814  		t.Fatalf("Expected Prefix to be blank, got %v", *lc.Prefix)
   815  	}
   816  	if *lc.Bucket != "" {
   817  		t.Fatalf("Expected Bucket to be blank, got %v", *lc.Bucket)
   818  	}
   819  	if *lc.IncludeCookies != false {
   820  		t.Fatalf("Expected IncludeCookies to be false, got %v", *lc.IncludeCookies)
   821  	}
   822  }
   823  
   824  func TestCloudFrontStructure_flattenLoggingConfig(t *testing.T) {
   825  	in := loggingConfigConf()
   826  	lc := expandLoggingConfig(in)
   827  	out := flattenLoggingConfig(lc)
   828  	diff := schema.NewSet(loggingConfigHash, []interface{}{in}).Difference(out)
   829  
   830  	if len(diff.List()) > 0 {
   831  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   832  	}
   833  }
   834  
   835  func TestCloudFrontStructure_expandAliases(t *testing.T) {
   836  	data := aliasesConf()
   837  	a := expandAliases(data)
   838  	if *a.Quantity != 2 {
   839  		t.Fatalf("Expected Quantity to be 2, got %v", *a.Quantity)
   840  	}
   841  	if reflect.DeepEqual(a.Items, expandStringList(data.List())) != true {
   842  		t.Fatalf("Expected Items to be [example.com www.example.com], got %v", a.Items)
   843  	}
   844  }
   845  
   846  func TestCloudFrontStructure_flattenAliases(t *testing.T) {
   847  	in := aliasesConf()
   848  	a := expandAliases(in)
   849  	out := flattenAliases(a)
   850  	diff := in.Difference(out)
   851  
   852  	if len(diff.List()) > 0 {
   853  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   854  	}
   855  }
   856  
   857  func TestCloudFrontStructure_expandRestrictions(t *testing.T) {
   858  	data := geoRestrictionsConf()
   859  	r := expandRestrictions(data)
   860  	if *r.GeoRestriction.RestrictionType != "whitelist" {
   861  		t.Fatalf("Expected GeoRestriction.RestrictionType to be whitelist, got %v", *r.GeoRestriction.RestrictionType)
   862  	}
   863  }
   864  
   865  func TestCloudFrontStructure_flattenRestrictions(t *testing.T) {
   866  	in := geoRestrictionsConf()
   867  	r := expandRestrictions(in)
   868  	out := flattenRestrictions(r)
   869  	diff := schema.NewSet(restrictionsHash, []interface{}{in}).Difference(out)
   870  
   871  	if len(diff.List()) > 0 {
   872  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   873  	}
   874  }
   875  
   876  func TestCloudFrontStructure_expandGeoRestriction_whitelist(t *testing.T) {
   877  	data := geoRestrictionWhitelistConf()
   878  	gr := expandGeoRestriction(data)
   879  	if *gr.RestrictionType != "whitelist" {
   880  		t.Fatalf("Expected RestrictionType to be whitelist, got %v", *gr.RestrictionType)
   881  	}
   882  	if *gr.Quantity != 3 {
   883  		t.Fatalf("Expected Quantity to be 3, got %v", *gr.Quantity)
   884  	}
   885  	if reflect.DeepEqual(gr.Items, aws.StringSlice([]string{"CA", "GB", "US"})) != true {
   886  		t.Fatalf("Expected Items be [CA, GB, US], got %v", gr.Items)
   887  	}
   888  }
   889  
   890  func TestCloudFrontStructure_flattenGeoRestriction_whitelist(t *testing.T) {
   891  	in := geoRestrictionWhitelistConf()
   892  	gr := expandGeoRestriction(in)
   893  	out := flattenGeoRestriction(gr)
   894  
   895  	if reflect.DeepEqual(in, out) != true {
   896  		t.Fatalf("Expected out to be %v, got %v", in, out)
   897  	}
   898  }
   899  
   900  func TestCloudFrontStructure_expandGeoRestriction_no_items(t *testing.T) {
   901  	data := geoRestrictionConfNoItems()
   902  	gr := expandGeoRestriction(data)
   903  	if *gr.RestrictionType != "none" {
   904  		t.Fatalf("Expected RestrictionType to be none, got %v", *gr.RestrictionType)
   905  	}
   906  	if *gr.Quantity != 0 {
   907  		t.Fatalf("Expected Quantity to be 0, got %v", *gr.Quantity)
   908  	}
   909  	if gr.Items != nil {
   910  		t.Fatalf("Expected Items to not be set, got %v", gr.Items)
   911  	}
   912  }
   913  
   914  func TestCloudFrontStructure_flattenGeoRestriction_no_items(t *testing.T) {
   915  	in := geoRestrictionConfNoItems()
   916  	gr := expandGeoRestriction(in)
   917  	out := flattenGeoRestriction(gr)
   918  
   919  	if reflect.DeepEqual(in, out) != true {
   920  		t.Fatalf("Expected out to be %v, got %v", in, out)
   921  	}
   922  }
   923  
   924  func TestCloudFrontStructure_expandViewerCertificate_cloudfront_default_certificate(t *testing.T) {
   925  	data := viewerCertificateConfSetCloudFrontDefault()
   926  	vc := expandViewerCertificate(data)
   927  	if vc.ACMCertificateArn != nil {
   928  		t.Fatalf("Expected ACMCertificateArn to be unset, got %v", *vc.ACMCertificateArn)
   929  	}
   930  	if *vc.CloudFrontDefaultCertificate != true {
   931  		t.Fatalf("Expected CloudFrontDefaultCertificate to be true, got %v", *vc.CloudFrontDefaultCertificate)
   932  	}
   933  	if vc.IAMCertificateId != nil {
   934  		t.Fatalf("Expected IAMCertificateId to not be set, got %v", *vc.IAMCertificateId)
   935  	}
   936  	if vc.SSLSupportMethod != nil {
   937  		t.Fatalf("Expected IAMCertificateId to not be set, got %v", *vc.SSLSupportMethod)
   938  	}
   939  	if vc.MinimumProtocolVersion != nil {
   940  		t.Fatalf("Expected IAMCertificateId to not be set, got %v", *vc.MinimumProtocolVersion)
   941  	}
   942  }
   943  
   944  func TestCloudFrontStructure_flattenViewerCertificate_cloudfront_default_certificate(t *testing.T) {
   945  	in := viewerCertificateConfSetCloudFrontDefault()
   946  	vc := expandViewerCertificate(in)
   947  	out := flattenViewerCertificate(vc)
   948  	diff := schema.NewSet(viewerCertificateHash, []interface{}{in}).Difference(out)
   949  
   950  	if len(diff.List()) > 0 {
   951  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
   952  	}
   953  }
   954  
   955  func TestCloudFrontStructure_expandViewerCertificate_iam_certificate_id(t *testing.T) {
   956  	data := viewerCertificateConfSetIAM()
   957  	vc := expandViewerCertificate(data)
   958  	if vc.ACMCertificateArn != nil {
   959  		t.Fatalf("Expected ACMCertificateArn to be unset, got %v", *vc.ACMCertificateArn)
   960  	}
   961  	if vc.CloudFrontDefaultCertificate != nil {
   962  		t.Fatalf("Expected CloudFrontDefaultCertificate to be unset, got %v", *vc.CloudFrontDefaultCertificate)
   963  	}
   964  	if *vc.IAMCertificateId != "iamcert-01234567" {
   965  		t.Fatalf("Expected IAMCertificateId to be iamcert-01234567, got %v", *vc.IAMCertificateId)
   966  	}
   967  	if *vc.SSLSupportMethod != "vip" {
   968  		t.Fatalf("Expected IAMCertificateId to be vip, got %v", *vc.SSLSupportMethod)
   969  	}
   970  	if *vc.MinimumProtocolVersion != "TLSv1" {
   971  		t.Fatalf("Expected IAMCertificateId to be TLSv1, got %v", *vc.MinimumProtocolVersion)
   972  	}
   973  }
   974  
   975  func TestCloudFrontStructure_expandViewerCertificate_acm_certificate_arn(t *testing.T) {
   976  	data := viewerCertificateConfSetACM()
   977  	vc := expandViewerCertificate(data)
   978  	if *vc.ACMCertificateArn != "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012" {
   979  		t.Fatalf("Expected ACMCertificateArn to be arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012, got %v", *vc.ACMCertificateArn)
   980  	}
   981  	if vc.CloudFrontDefaultCertificate != nil {
   982  		t.Fatalf("Expected CloudFrontDefaultCertificate to be unset, got %v", *vc.CloudFrontDefaultCertificate)
   983  	}
   984  	if vc.IAMCertificateId != nil {
   985  		t.Fatalf("Expected IAMCertificateId to be unset, got %v", *vc.IAMCertificateId)
   986  	}
   987  	if *vc.SSLSupportMethod != "sni-only" {
   988  		t.Fatalf("Expected IAMCertificateId to be sni-only, got %v", *vc.SSLSupportMethod)
   989  	}
   990  	if *vc.MinimumProtocolVersion != "TLSv1" {
   991  		t.Fatalf("Expected IAMCertificateId to be TLSv1, got %v", *vc.MinimumProtocolVersion)
   992  	}
   993  }
   994  
   995  func TestCloudFrontStructure_falttenViewerCertificate_iam_certificate_id(t *testing.T) {
   996  	in := viewerCertificateConfSetIAM()
   997  	vc := expandViewerCertificate(in)
   998  	out := flattenViewerCertificate(vc)
   999  	diff := schema.NewSet(viewerCertificateHash, []interface{}{in}).Difference(out)
  1000  
  1001  	if len(diff.List()) > 0 {
  1002  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
  1003  	}
  1004  }
  1005  
  1006  func TestCloudFrontStructure_falttenViewerCertificate_acm_certificate_arn(t *testing.T) {
  1007  	in := viewerCertificateConfSetACM()
  1008  	vc := expandViewerCertificate(in)
  1009  	out := flattenViewerCertificate(vc)
  1010  	diff := schema.NewSet(viewerCertificateHash, []interface{}{in}).Difference(out)
  1011  
  1012  	if len(diff.List()) > 0 {
  1013  		t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
  1014  	}
  1015  }
  1016  
  1017  func TestCloudFrontStructure_viewerCertificateHash_IAM(t *testing.T) {
  1018  	in := viewerCertificateConfSetIAM()
  1019  	out := viewerCertificateHash(in)
  1020  	expected := 1157261784
  1021  
  1022  	if expected != out {
  1023  		t.Fatalf("Expected %v, got %v", expected, out)
  1024  	}
  1025  }
  1026  
  1027  func TestCloudFrontStructure_viewerCertificateHash_ACM(t *testing.T) {
  1028  	in := viewerCertificateConfSetACM()
  1029  	out := viewerCertificateHash(in)
  1030  	expected := 2883600425
  1031  
  1032  	if expected != out {
  1033  		t.Fatalf("Expected %v, got %v", expected, out)
  1034  	}
  1035  }
  1036  
  1037  func TestCloudFrontStructure_viewerCertificateHash_default(t *testing.T) {
  1038  	in := viewerCertificateConfSetCloudFrontDefault()
  1039  	out := viewerCertificateHash(in)
  1040  	expected := 69840937
  1041  
  1042  	if expected != out {
  1043  		t.Fatalf("Expected %v, got %v", expected, out)
  1044  	}
  1045  }