summaryrefslogtreecommitdiffhomepage
path: root/server/rpki_test.go
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2016-03-31 12:12:09 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-31 11:27:43 +0900
commitf4e834672ffacfd8ed02c0a5d3bc18314fe7e8a6 (patch)
tree19b8e64abcd5bfd88207fd4b11599a4a3ed78e72 /server/rpki_test.go
parent6bb6ade9f84b6aa9dd6187a4bb229495e4a33cae (diff)
server: be exportable to use as RPKI library
Diffstat (limited to 'server/rpki_test.go')
-rw-r--r--server/rpki_test.go49
1 files changed, 25 insertions, 24 deletions
diff --git a/server/rpki_test.go b/server/rpki_test.go
index aa0a85be..c51ba1ae 100644
--- a/server/rpki_test.go
+++ b/server/rpki_test.go
@@ -16,14 +16,15 @@
package server
import (
- "github.com/armon/go-radix"
- "github.com/osrg/gobgp/config"
- "github.com/osrg/gobgp/packet"
- "github.com/stretchr/testify/assert"
"net"
"strconv"
"strings"
"testing"
+
+ "github.com/armon/go-radix"
+ "github.com/osrg/gobgp/config"
+ "github.com/osrg/gobgp/packet"
+ "github.com/stretchr/testify/assert"
)
func strToASParam(str string) *bgp.PathAttributeAsPath {
@@ -60,13 +61,13 @@ func validateOne(tree *radix.Tree, cidr, aspathStr string) config.RpkiValidation
func TestValidate0(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("192.168.0.0").To4(), 24, 32, 100, ""))
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("192.168.0.0").To4(), 24, 24, 200, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "192.168.0.0/24", "100")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
@@ -89,12 +90,12 @@ func TestValidate0(t *testing.T) {
func TestValidate1(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 16, 65000, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/16", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
@@ -105,11 +106,11 @@ func TestValidate1(t *testing.T) {
func TestValidate2(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/16", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND)
@@ -120,22 +121,22 @@ func TestValidate2(t *testing.T) {
func TestValidate3(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 16, 65000, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/8", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND)
r = validateOne(tree, "10.0.0.0/17", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_INVALID)
- manager, _ = newROAManager(0, []config.RpkiServer{})
+ manager, _ = NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 65000, ""))
- tree = manager.roas[bgp.RF_IPv4_UC]
+ tree = manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/17", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
}
@@ -143,12 +144,12 @@ func TestValidate3(t *testing.T) {
func TestValidate4(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 16, 65000, ""))
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 16, 65001, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/16", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
@@ -159,12 +160,12 @@ func TestValidate4(t *testing.T) {
func TestValidate5(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 17, 17, 65000, ""))
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.128.0").To4(), 17, 17, 65000, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/16", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND)
}
@@ -172,11 +173,11 @@ func TestValidate5(t *testing.T) {
func TestValidate6(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 8, 32, 0, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/7", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND)
@@ -190,11 +191,11 @@ func TestValidate6(t *testing.T) {
func TestValidate7(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 65000, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/24", "{65000}")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND)
@@ -208,12 +209,12 @@ func TestValidate7(t *testing.T) {
func TestValidate8(t *testing.T) {
assert := assert.New(t)
- manager, _ := newROAManager(0, []config.RpkiServer{})
+ manager, _ := NewROAManager(0, []config.RpkiServer{})
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 0, ""))
manager.addROA(NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 65000, ""))
var r config.RpkiValidationResultType
- tree := manager.roas[bgp.RF_IPv4_UC]
+ tree := manager.Roas[bgp.RF_IPv4_UC]
r = validateOne(tree, "10.0.0.0/24", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)