(t *testing.T)
| 1130 | } |
| 1131 | |
| 1132 | func TestAsPathConditionEvaluate(t *testing.T) { |
| 1133 | // setup |
| 1134 | // create path |
| 1135 | peer := &PeerInfo{AS: 65001, Address: netip.MustParseAddr("10.0.0.1")} |
| 1136 | origin := bgp.NewPathAttributeOrigin(0) |
| 1137 | aspathParam1 := []bgp.AsPathParamInterface{ |
| 1138 | bgp.NewAsPathParam(2, []uint16{65001, 65000, 65010, 65004, 65005}), |
| 1139 | } |
| 1140 | aspath := bgp.NewPathAttributeAsPath(aspathParam1) |
| 1141 | nexthop, _ := bgp.NewPathAttributeNextHop(netip.MustParseAddr("10.0.0.1")) |
| 1142 | med := bgp.NewPathAttributeMultiExitDisc(0) |
| 1143 | pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} |
| 1144 | nlri, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.10.0.101/24")) |
| 1145 | updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, []bgp.PathNLRI{{NLRI: nlri}}) |
| 1146 | UpdatePathAttrs4ByteAs(logger, updateMsg1.Body.(*bgp.BGPUpdate)) |
| 1147 | path1 := ProcessMessage(updateMsg1, peer, time.Now(), false)[0] |
| 1148 | |
| 1149 | aspathParam2 := []bgp.AsPathParamInterface{ |
| 1150 | bgp.NewAsPathParam(2, []uint16{65010}), |
| 1151 | } |
| 1152 | aspath2 := bgp.NewPathAttributeAsPath(aspathParam2) |
| 1153 | pathAttributes = []bgp.PathAttributeInterface{origin, aspath2, nexthop, med} |
| 1154 | updateMsg2 := bgp.NewBGPUpdateMessage(nil, pathAttributes, []bgp.PathNLRI{{NLRI: nlri}}) |
| 1155 | UpdatePathAttrs4ByteAs(logger, updateMsg2.Body.(*bgp.BGPUpdate)) |
| 1156 | path2 := ProcessMessage(updateMsg2, peer, time.Now(), false)[0] |
| 1157 | |
| 1158 | // create match condition |
| 1159 | asPathSet1 := oc.AsPathSet{ |
| 1160 | AsPathSetName: "asset1", |
| 1161 | AsPathList: []string{"^65001"}, |
| 1162 | } |
| 1163 | |
| 1164 | asPathSet2 := oc.AsPathSet{ |
| 1165 | AsPathSetName: "asset2", |
| 1166 | AsPathList: []string{"65005$"}, |
| 1167 | } |
| 1168 | |
| 1169 | asPathSet3 := oc.AsPathSet{ |
| 1170 | AsPathSetName: "asset3", |
| 1171 | AsPathList: []string{"65004", "65005$"}, |
| 1172 | } |
| 1173 | |
| 1174 | asPathSet4 := oc.AsPathSet{ |
| 1175 | AsPathSetName: "asset4", |
| 1176 | AsPathList: []string{"65000$"}, |
| 1177 | } |
| 1178 | |
| 1179 | asPathSet5 := oc.AsPathSet{ |
| 1180 | AsPathSetName: "asset5", |
| 1181 | AsPathList: []string{"65010"}, |
| 1182 | } |
| 1183 | |
| 1184 | asPathSet6 := oc.AsPathSet{ |
| 1185 | AsPathSetName: "asset6", |
| 1186 | AsPathList: []string{"^65010$"}, |
| 1187 | } |
| 1188 | |
| 1189 | m := make(map[string]DefinedSet) |
nothing calls this directly
no test coverage detected
searching dependent graphs…