From 8ddb845ca5fb8a5414192f2960a955dcb9217b33 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sun, 4 Dec 2016 14:19:17 +0200 Subject: [PATCH] Added IPv6 testcases --- api_test.go | 8 ++++++++ validation_test.go | 1 + 2 files changed, 9 insertions(+) diff --git a/api_test.go b/api_test.go index 0e7bf88..99fe655 100644 --- a/api_test.go +++ b/api_test.go @@ -228,6 +228,11 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) { t.Errorf("Could not create new user with CIDR, got error [%v]", err) } + newUserWithIP6CIDR, err := DB.Register(cidrslice{"2002:c0a8::0/32"}) + if err != nil { + t.Errorf("Could not create a new user with IP6 CIDR, got error [%v]", err) + } + for _, test := range []struct { user ACMETxt headerValue string @@ -238,6 +243,9 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) { {newUserWithCIDR, "127.0.0.1", 401}, {newUserWithCIDR, "10.0.0.1, 10.0.0.2, 192.168.1.3", 401}, {newUserWithCIDR, "10.1.1.1 ,192.168.1.2, 8.8.8.8", 200}, + {newUserWithIP6CIDR, "2002:c0a8:b4dc:0d3::0", 200}, + {newUserWithIP6CIDR, "2002:c0a7:0ff::0", 401}, + {newUserWithIP6CIDR, "2002:c0a8:d3ad:b33f:c0ff:33b4:dc0d:3b4d", 200}, } { updateJSON = map[string]interface{}{ "subdomain": test.user.Subdomain, diff --git a/validation_test.go b/validation_test.go index e6e3589..fd63cf4 100644 --- a/validation_test.go +++ b/validation_test.go @@ -114,6 +114,7 @@ func TestGetValidCIDRMasks(t *testing.T) { }{ {cidrslice{"10.0.0.1/24"}, cidrslice{"10.0.0.1/24"}}, {cidrslice{"invalid", "127.0.0.1/32"}, cidrslice{"127.0.0.1/32"}}, + {cidrslice{"2002:c0a8::0/32", "8.8.8.8/32"}, cidrslice{"2002:c0a8::0/32", "8.8.8.8/32"}}, } { ret := test.input.ValidEntries() if len(ret) == len(test.output) {