diff options
Diffstat (limited to 'table/path_test.go')
-rw-r--r-- | table/path_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/table/path_test.go b/table/path_test.go index 6e7a3534..29a296ac 100644 --- a/table/path_test.go +++ b/table/path_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" "github.com/stretchr/testify/assert" ) @@ -331,3 +332,24 @@ func updateMsgP3() *bgp.BGPMessage { withdrawnRoutes := []*bgp.IPAddrPrefix{w1} return bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) } + +func TestRemovePrivateAS(t *testing.T) { + aspathParam := []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{64512, 64513, 1, 2})} + aspath := bgp.NewPathAttributeAsPath(aspathParam) + nlri := bgp.NewIPAddrPrefix(24, "30.30.30.0") + path := NewPath(nil, nlri, false, []bgp.PathAttributeInterface{aspath}, time.Now(), false) + path.RemovePrivateAS(10, config.REMOVE_PRIVATE_AS_OPTION_ALL) + list := path.GetAsList() + assert.Equal(t, len(list), 2) + assert.Equal(t, list[0], uint32(1)) + assert.Equal(t, list[1], uint32(2)) + + path = NewPath(nil, nlri, false, []bgp.PathAttributeInterface{aspath}, time.Now(), false) + path.RemovePrivateAS(10, config.REMOVE_PRIVATE_AS_OPTION_REPLACE) + list = path.GetAsList() + assert.Equal(t, len(list), 4) + assert.Equal(t, list[0], uint32(10)) + assert.Equal(t, list[1], uint32(10)) + assert.Equal(t, list[2], uint32(1)) + assert.Equal(t, list[3], uint32(2)) +} |