summaryrefslogtreecommitdiffhomepage
path: root/server/rpki_test.go
diff options
context:
space:
mode:
authorEiichrio Watanabe <a16tochjp@gmail.com>2017-01-12 00:11:22 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-01-15 06:35:53 -0800
commit26536fdcea869e6f842ef3b19b04cc16f79f2b0c (patch)
tree8a28e6f19c791d3c890e64d16eade365ffcc6da9 /server/rpki_test.go
parent512b156be685a4d32c727554a8409453272c7c0d (diff)
Add examples for RPKI Origin Validation
Diffstat (limited to 'server/rpki_test.go')
-rw-r--r--server/rpki_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/rpki_test.go b/server/rpki_test.go
index 8405738b..fd29b04f 100644
--- a/server/rpki_test.go
+++ b/server/rpki_test.go
@@ -221,3 +221,35 @@ func TestValidate8(t *testing.T) {
r = validateOne(tree, "10.0.0.0/24", "65001")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_INVALID)
}
+
+func TestValidate9(t *testing.T) {
+ assert := assert.New(t)
+
+ manager, _ := NewROAManager(0)
+ manager.addROA(table.NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 24, 24, 65000, ""))
+ manager.addROA(table.NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 65001, ""))
+
+ var r config.RpkiValidationResultType
+ 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)
+
+ r = validateOne(tree, "10.0.0.0/24", "65001")
+ assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
+}
+
+func TestValidate10(t *testing.T) {
+ assert := assert.New(t)
+
+ manager, _ := NewROAManager(0)
+ manager.addROA(table.NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 24, 24, 0, ""))
+ manager.addROA(table.NewROA(bgp.AFI_IP, net.ParseIP("10.0.0.0").To4(), 16, 24, 65001, ""))
+
+ var r config.RpkiValidationResultType
+ tree := manager.Roas[bgp.RF_IPv4_UC]
+ r = validateOne(tree, "10.0.0.0/24", "65000")
+ assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_INVALID)
+
+ r = validateOne(tree, "10.0.0.0/24", "65001")
+ assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
+}