summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/validate_test.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-09-26 16:05:49 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-09-29 15:05:43 +0900
commitba395457213966dd8a49b5836b2341434f4025b9 (patch)
treee86f3ade4e0a24fa96dd610025bdbeb574599db0 /packet/bgp/validate_test.go
parentf70827b68c190e3793ace65f116fef8c7c36e752 (diff)
packet/bgp: Add Unit Tests for Revised Error Handling
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'packet/bgp/validate_test.go')
-rw-r--r--packet/bgp/validate_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/packet/bgp/validate_test.go b/packet/bgp/validate_test.go
index 05b2fed7..2620fbb7 100644
--- a/packet/bgp/validate_test.go
+++ b/packet/bgp/validate_test.go
@@ -157,6 +157,7 @@ func Test_Validate_duplicate_attribute(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_ATTRIBUTE_DISCARD, e.ErrorHandling)
assert.Nil(e.Data)
}
@@ -170,6 +171,7 @@ func Test_Validate_mandatory_missing(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_MISSING_WELL_KNOWN_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
missing, _ := binary.Uvarint(e.Data)
assert.Equal(uint64(1), missing)
}
@@ -200,6 +202,7 @@ func Test_Validate_invalid_origin(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_INVALID_ORIGIN_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Equal(originBytes, e.Data)
}
@@ -221,6 +224,7 @@ func Test_Validate_invalid_nexthop_zero(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Equal(nexthopBytes, e.Data)
}
@@ -242,6 +246,7 @@ func Test_Validate_invalid_nexthop_lo(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Equal(nexthopBytes, e.Data)
}
@@ -263,6 +268,7 @@ func Test_Validate_invalid_nexthop_de(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_INVALID_NEXT_HOP_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Equal(nexthopBytes, e.Data)
}
@@ -283,6 +289,7 @@ func Test_Validate_unrecognized_well_known(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_SESSION_RESET, e.ErrorHandling)
assert.Equal(unknownBytes, e.Data)
}
@@ -316,6 +323,7 @@ func Test_Validate_aspath(t *testing.T) {
e := err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_MALFORMED_AS_PATH), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Nil(e.Data)
// CONFED_SEQ
@@ -339,6 +347,7 @@ func Test_Validate_aspath(t *testing.T) {
e = err.(*MessageError)
assert.Equal(uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR), e.TypeCode)
assert.Equal(uint8(BGP_ERROR_SUB_MALFORMED_AS_PATH), e.SubTypeCode)
+ assert.Equal(ERROR_HANDLING_TREAT_AS_WITHDRAW, e.ErrorHandling)
assert.Nil(e.Data)
}