@@ -314,6 +314,234 @@ func TestAccCloudflareSpectrumApplication_BasicMinecraft(t *testing.T) {
314
314
})
315
315
}
316
316
317
+ func TestAccCloudflareSpectrumApplication_TLS (t * testing.T ) {
318
+ var spectrumApp cloudflare.SpectrumApplication
319
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
320
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
321
+ rnd := utils .GenerateRandomResourceName ()
322
+ name := "cloudflare_spectrum_application." + rnd
323
+
324
+ resource .Test (t , resource.TestCase {
325
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
326
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
327
+ Steps : []resource.TestStep {
328
+ {
329
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTLS (zoneID , domain , rnd , "flexible" ),
330
+ Check : resource .ComposeTestCheckFunc (
331
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
332
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
333
+ resource .TestCheckResourceAttr (name , "tls" , "flexible" ),
334
+ ),
335
+ },
336
+ {
337
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTLS (zoneID , domain , rnd , "full" ),
338
+ Check : resource .ComposeTestCheckFunc (
339
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
340
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
341
+ resource .TestCheckResourceAttr (name , "tls" , "full" ),
342
+ ),
343
+ },
344
+ {
345
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTLS (zoneID , domain , rnd , "strict" ),
346
+ Check : resource .ComposeTestCheckFunc (
347
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
348
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
349
+ resource .TestCheckResourceAttr (name , "tls" , "strict" ),
350
+ ),
351
+ },
352
+ },
353
+ })
354
+ }
355
+
356
+ func TestAccCloudflareSpectrumApplication_ProxyProtocol (t * testing.T ) {
357
+ var spectrumApp cloudflare.SpectrumApplication
358
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
359
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
360
+ rnd := utils .GenerateRandomResourceName ()
361
+ name := "cloudflare_spectrum_application." + rnd
362
+
363
+ resource .Test (t , resource.TestCase {
364
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
365
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
366
+ Steps : []resource.TestStep {
367
+ {
368
+ Config : testAccCheckCloudflareSpectrumApplicationConfigProxyProtocol (zoneID , domain , rnd , "v1" ),
369
+ Check : resource .ComposeTestCheckFunc (
370
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
371
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
372
+ resource .TestCheckResourceAttr (name , "proxy_protocol" , "v1" ),
373
+ ),
374
+ },
375
+ {
376
+ Config : testAccCheckCloudflareSpectrumApplicationConfigProxyProtocol (zoneID , domain , rnd , "v2" ),
377
+ Check : resource .ComposeTestCheckFunc (
378
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
379
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
380
+ resource .TestCheckResourceAttr (name , "proxy_protocol" , "v2" ),
381
+ ),
382
+ },
383
+ },
384
+ })
385
+ }
386
+
387
+ func TestAccCloudflareSpectrumApplication_IPFirewall (t * testing.T ) {
388
+ var spectrumApp cloudflare.SpectrumApplication
389
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
390
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
391
+ rnd := utils .GenerateRandomResourceName ()
392
+ name := "cloudflare_spectrum_application." + rnd
393
+
394
+ resource .Test (t , resource.TestCase {
395
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
396
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
397
+ Steps : []resource.TestStep {
398
+ {
399
+ Config : testAccCheckCloudflareSpectrumApplicationConfigIPFirewall (zoneID , domain , rnd , "true" ),
400
+ Check : resource .ComposeTestCheckFunc (
401
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
402
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
403
+ resource .TestCheckResourceAttr (name , "ip_firewall" , "true" ),
404
+ ),
405
+ },
406
+ {
407
+ Config : testAccCheckCloudflareSpectrumApplicationConfigIPFirewall (zoneID , domain , rnd , "false" ),
408
+ Check : resource .ComposeTestCheckFunc (
409
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
410
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
411
+ resource .TestCheckResourceAttr (name , "ip_firewall" , "false" ),
412
+ ),
413
+ },
414
+ },
415
+ })
416
+ }
417
+
418
+ func TestAccCloudflareSpectrumApplication_ArgoSmartRouting (t * testing.T ) {
419
+ var spectrumApp cloudflare.SpectrumApplication
420
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
421
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
422
+ rnd := utils .GenerateRandomResourceName ()
423
+ name := "cloudflare_spectrum_application." + rnd
424
+
425
+ resource .Test (t , resource.TestCase {
426
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
427
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
428
+ Steps : []resource.TestStep {
429
+ {
430
+ Config : testAccCheckCloudflareSpectrumApplicationConfigArgoSmartRouting (zoneID , domain , rnd , "true" ),
431
+ Check : resource .ComposeTestCheckFunc (
432
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
433
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
434
+ resource .TestCheckResourceAttr (name , "argo_smart_routing" , "true" ),
435
+ resource .TestCheckResourceAttr (name , "traffic_type" , "direct" ),
436
+ ),
437
+ },
438
+ {
439
+ Config : testAccCheckCloudflareSpectrumApplicationConfigArgoSmartRouting (zoneID , domain , rnd , "false" ),
440
+ Check : resource .ComposeTestCheckFunc (
441
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
442
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
443
+ resource .TestCheckResourceAttr (name , "argo_smart_routing" , "false" ),
444
+ resource .TestCheckResourceAttr (name , "traffic_type" , "direct" ),
445
+ ),
446
+ },
447
+ },
448
+ })
449
+ }
450
+
451
+ func TestAccCloudflareSpectrumApplication_TrafficType (t * testing.T ) {
452
+ var spectrumApp cloudflare.SpectrumApplication
453
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
454
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
455
+ rnd := utils .GenerateRandomResourceName ()
456
+ name := "cloudflare_spectrum_application." + rnd
457
+
458
+ resource .Test (t , resource.TestCase {
459
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
460
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
461
+ Steps : []resource.TestStep {
462
+ {
463
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTrafficType (zoneID , domain , rnd , "http" ),
464
+ Check : resource .ComposeTestCheckFunc (
465
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
466
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
467
+ resource .TestCheckResourceAttr (name , "traffic_type" , "http" ),
468
+ ),
469
+ },
470
+ {
471
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTrafficType (zoneID , domain , rnd , "https" ),
472
+ Check : resource .ComposeTestCheckFunc (
473
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
474
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
475
+ resource .TestCheckResourceAttr (name , "traffic_type" , "https" ),
476
+ ),
477
+ },
478
+ {
479
+ Config : testAccCheckCloudflareSpectrumApplicationConfigTrafficType (zoneID , domain , rnd , "direct" ),
480
+ Check : resource .ComposeTestCheckFunc (
481
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
482
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
483
+ resource .TestCheckResourceAttr (name , "traffic_type" , "direct" ),
484
+ ),
485
+ },
486
+ },
487
+ })
488
+ }
489
+
490
+ func TestAccCloudflareSpectrumApplication_IPv6Connectivity (t * testing.T ) {
491
+ var spectrumApp cloudflare.SpectrumApplication
492
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
493
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
494
+ rnd := utils .GenerateRandomResourceName ()
495
+ name := "cloudflare_spectrum_application." + rnd
496
+
497
+ resource .Test (t , resource.TestCase {
498
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
499
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
500
+ Steps : []resource.TestStep {
501
+ {
502
+ Config : testAccCheckCloudflareSpectrumApplicationConfigIPv6 (zoneID , domain , rnd ),
503
+ Check : resource .ComposeTestCheckFunc (
504
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
505
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
506
+ resource .TestCheckResourceAttr (name , "edge_ips.connectivity" , "ipv6" ),
507
+ ),
508
+ },
509
+ },
510
+ })
511
+ }
512
+
513
+ func TestAccCloudflareSpectrumApplication_UDP (t * testing.T ) {
514
+ var spectrumApp cloudflare.SpectrumApplication
515
+ domain := os .Getenv ("CLOUDFLARE_DOMAIN" )
516
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
517
+ rnd := utils .GenerateRandomResourceName ()
518
+ name := "cloudflare_spectrum_application." + rnd
519
+
520
+ resource .Test (t , resource.TestCase {
521
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
522
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
523
+ Steps : []resource.TestStep {
524
+ {
525
+ Config : testAccCheckCloudflareSpectrumApplicationConfigUDP (zoneID , domain , rnd ),
526
+ Check : resource .ComposeTestCheckFunc (
527
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
528
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
529
+ resource .TestCheckResourceAttr (name , "protocol" , "udp/53" ),
530
+ resource .TestCheckResourceAttr (name , "traffic_type" , "direct" ),
531
+ ),
532
+ },
533
+ {
534
+ Config : testAccCheckCloudflareSpectrumApplicationConfigSimpleProxyProtocol (zoneID , domain , rnd ),
535
+ Check : resource .ComposeTestCheckFunc (
536
+ testAccCheckCloudflareSpectrumApplicationExists (name , & spectrumApp ),
537
+ testAccCheckCloudflareSpectrumApplicationIDIsValid (name ),
538
+ resource .TestCheckResourceAttr (name , "proxy_protocol" , "simple" ),
539
+ ),
540
+ },
541
+ },
542
+ })
543
+ }
544
+
317
545
func testAccCheckCloudflareSpectrumApplicationExists (n string , spectrumApp * cloudflare.SpectrumApplication ) resource.TestCheckFunc {
318
546
return func (s * terraform.State ) error {
319
547
rs , ok := s .RootModule ().Resources [n ]
@@ -409,3 +637,35 @@ func testAccCheckCloudflareSpectrumApplicationConfigMultipleEdgeIPs(zoneID, zone
409
637
func testAccCheckCloudflareSpectrumApplicationConfigBasicTypes (zoneID , zoneName , ID , protocol string , port int ) string {
410
638
return acctest .LoadTestCase ("spectrumapplicationconfigbasictypes.tf" , zoneID , zoneName , ID , protocol , port )
411
639
}
640
+
641
+ func testAccCheckCloudflareSpectrumApplicationConfigTLS (zoneID , zoneName , ID , tls string ) string {
642
+ return acctest .LoadTestCase ("spectrumapplicationconfigtls.tf" , zoneID , zoneName , ID , tls )
643
+ }
644
+
645
+ func testAccCheckCloudflareSpectrumApplicationConfigProxyProtocol (zoneID , zoneName , ID , proxyProtocol string ) string {
646
+ return acctest .LoadTestCase ("spectrumapplicationconfigproxyprotocol.tf" , zoneID , zoneName , ID , proxyProtocol )
647
+ }
648
+
649
+ func testAccCheckCloudflareSpectrumApplicationConfigSimpleProxyProtocol (zoneID , zoneName , ID string ) string {
650
+ return acctest .LoadTestCase ("spectrumapplicationconfigsimpleproxyprotocol.tf" , zoneID , zoneName , ID )
651
+ }
652
+
653
+ func testAccCheckCloudflareSpectrumApplicationConfigIPFirewall (zoneID , zoneName , ID , ipFirewall string ) string {
654
+ return acctest .LoadTestCase ("spectrumapplicationconfigipfirewall.tf" , zoneID , zoneName , ID , ipFirewall )
655
+ }
656
+
657
+ func testAccCheckCloudflareSpectrumApplicationConfigArgoSmartRouting (zoneID , zoneName , ID , argoSmartRouting string ) string {
658
+ return acctest .LoadTestCase ("spectrumapplicationconfigargosmartrouting.tf" , zoneID , zoneName , ID , argoSmartRouting )
659
+ }
660
+
661
+ func testAccCheckCloudflareSpectrumApplicationConfigTrafficType (zoneID , zoneName , ID , trafficType string ) string {
662
+ return acctest .LoadTestCase ("spectrumapplicationconfigtraffictype.tf" , zoneID , zoneName , ID , trafficType )
663
+ }
664
+
665
+ func testAccCheckCloudflareSpectrumApplicationConfigIPv6 (zoneID , zoneName , ID string ) string {
666
+ return acctest .LoadTestCase ("spectrumapplicationconfigipv6.tf" , zoneID , zoneName , ID )
667
+ }
668
+
669
+ func testAccCheckCloudflareSpectrumApplicationConfigUDP (zoneID , zoneName , ID string ) string {
670
+ return acctest .LoadTestCase ("spectrumapplicationconfigudp.tf" , zoneID , zoneName , ID )
671
+ }
0 commit comments