@@ -2,6 +2,7 @@ package cloudflare
22
33import (
44 "fmt"
5+ "net"
56 "net/http"
67 "testing"
78 "time"
@@ -400,3 +401,70 @@ func TestSpectrumApplicationProxyProtocolDeprecations(t *testing.T) {
400401 teardown ()
401402 }
402403}
404+
405+ func TestSpectrumApplicationEdgeIPs (t * testing.T ) {
406+ setup ()
407+ defer teardown ()
408+
409+ handler := func (w http.ResponseWriter , r * http.Request ) {
410+ assert .Equal (t , r .Method , "GET" , "Expected method 'GET', got %s" , r .Method )
411+ w .Header ().Set ("content-type" , "application/json" )
412+ fmt .Fprint (w , `{
413+ "result": {
414+ "id": "f68579455bd947efb65ffa1bcf33b52c",
415+ "protocol": "tcp/22",
416+ "ipv4": true,
417+ "dns": {
418+ "type": "CNAME",
419+ "name": "spectrum.example.com"
420+ },
421+ "origin_direct": [
422+ "tcp://192.0.2.1:22"
423+ ],
424+ "ip_firewall": true,
425+ "proxy_protocol": "off",
426+ "tls": "off",
427+ "edge_ips": {
428+ "type": "static",
429+ "ips": [
430+ "192.0.2.1",
431+ "2001:db8::1"
432+ ]
433+ },
434+ "created_on": "2018-03-28T21:25:55.643771Z",
435+ "modified_on": "2018-03-28T21:25:55.643771Z"
436+ },
437+ "success": true,
438+ "errors": [],
439+ "messages": []
440+ }` )
441+ }
442+
443+ mux .HandleFunc ("/zones/01a7362d577a6c3019a474fd6f485823/spectrum/apps/f68579455bd947efb65ffa1bcf33b52c" , handler )
444+ createdOn , _ := time .Parse (time .RFC3339 , "2018-03-28T21:25:55.643771Z" )
445+ modifiedOn , _ := time .Parse (time .RFC3339 , "2018-03-28T21:25:55.643771Z" )
446+ want := SpectrumApplication {
447+ ID : "f68579455bd947efb65ffa1bcf33b52c" ,
448+ CreatedOn : & createdOn ,
449+ ModifiedOn : & modifiedOn ,
450+ Protocol : "tcp/22" ,
451+ IPv4 : true ,
452+ DNS : SpectrumApplicationDNS {
453+ Name : "spectrum.example.com" ,
454+ Type : "CNAME" ,
455+ },
456+ OriginDirect : []string {"tcp://192.0.2.1:22" },
457+ IPFirewall : true ,
458+ ProxyProtocol : "off" ,
459+ TLS : "off" ,
460+ EdgeIPs : & EdgeIPs {
461+ Type : STATIC ,
462+ IPs : []net.IP {net .ParseIP ("192.0.2.1" ), net .ParseIP ("2001:db8::1" )},
463+ },
464+ }
465+
466+ actual , err := client .SpectrumApplication ("01a7362d577a6c3019a474fd6f485823" , "f68579455bd947efb65ffa1bcf33b52c" )
467+ if assert .NoError (t , err ) {
468+ assert .Equal (t , want , actual )
469+ }
470+ }
0 commit comments