56 lines
937 B
Go
56 lines
937 B
Go
package netsplit
|
|
|
|
import (
|
|
`encoding/json`
|
|
`fmt`
|
|
`net/http`
|
|
"testing"
|
|
|
|
`github.com/go-resty/resty/v2`
|
|
`github.com/goccy/go-yaml`
|
|
)
|
|
|
|
func TestIANA(t *testing.T) {
|
|
|
|
var err error
|
|
var b []byte
|
|
var req *resty.Request
|
|
var resp *resty.Response
|
|
var reg *IANARegistry
|
|
var client *resty.Client = resty.New()
|
|
|
|
// IPv4
|
|
req = client.R()
|
|
reg = new(IANARegistry)
|
|
req.SetResult(reg)
|
|
if resp, err = req.Get(ianaSpecial4); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if resp.StatusCode() != http.StatusOK {
|
|
t.Fatal(resp.Status())
|
|
}
|
|
|
|
if b, err = json.MarshalIndent(reg, "", " "); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
|
|
// IPv6
|
|
req = client.R()
|
|
reg = new(IANARegistry)
|
|
req.SetResult(reg)
|
|
if resp, err = req.Get(ianaSpecial6); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if resp.StatusCode() != http.StatusOK {
|
|
t.Fatal(resp.Status())
|
|
}
|
|
|
|
if b, err = yaml.Marshal(reg); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
|
|
_ = b
|
|
}
|