@@ -194,3 +194,85 @@ func TestRemoveBGPPeer(t *testing.T) {
194194 err := speakers .RemoveBGPPeer (fake .ServiceClient (), bgpSpeakerID , opts ).ExtractErr ()
195195 th .AssertEquals (t , err , io .EOF )
196196}
197+
198+ func TestGetAdvertisedRoutes (t * testing.T ) {
199+ th .SetupHTTP ()
200+ defer th .TeardownHTTP ()
201+
202+ bgpSpeakerID := "ab01ade1-ae62-43c9-8a1f-3c24225b96d8"
203+ th .Mux .HandleFunc ("/v2.0/bgp-speakers/" + bgpSpeakerID + "/get_advertised_routes" , func (w http.ResponseWriter , r * http.Request ) {
204+ th .TestMethod (t , r , "GET" )
205+ th .TestHeader (t , r , "X-Auth-Token" , fake .TokenID )
206+ w .Header ().Add ("Content-Type" , "application/json" )
207+ w .WriteHeader (http .StatusOK )
208+ fmt .Fprintf (w , GetAdvertisedRoutesResult )
209+ })
210+
211+ count := 0
212+ speakers .GetAdvertisedRoutes (fake .ServiceClient (), bgpSpeakerID ).EachPage (
213+ func (page pagination.Page ) (bool , error ) {
214+ count ++
215+ actual , err := speakers .ExtractAdvertisedRoutes (page )
216+
217+ if err != nil {
218+ t .Errorf ("Failed to extract Advertised route: %v" , err )
219+ return false , nil
220+ }
221+
222+ expected := []speakers.AdvertisedRoute {
223+ speakers.AdvertisedRoute {NextHop : "172.17.128.212" , Destination : "172.17.129.192/27" },
224+ speakers.AdvertisedRoute {NextHop : "172.17.128.218" , Destination : "172.17.129.0/27" },
225+ speakers.AdvertisedRoute {NextHop : "172.17.128.231" , Destination : "172.17.129.160/27" },
226+ }
227+ th .CheckDeepEquals (t , count , 1 )
228+ th .CheckDeepEquals (t , expected , actual )
229+ return true , nil
230+ })
231+ }
232+
233+ func TestAddGatewayNetwork (t * testing.T ) {
234+ th .SetupHTTP ()
235+ defer th .TeardownHTTP ()
236+
237+ bgpSpeakerID := "ab01ade1-ae62-43c9-8a1f-3c24225b96d8"
238+ networkID := "ac13bb26-6219-49c3-a880-08847f6830b7"
239+ th .Mux .HandleFunc ("/v2.0/bgp-speakers/" + bgpSpeakerID + "/add_gateway_network" , func (w http.ResponseWriter , r * http.Request ) {
240+ th .TestMethod (t , r , "PUT" )
241+ th .TestHeader (t , r , "X-Auth-Token" , fake .TokenID )
242+ th .TestHeader (t , r , "Content-Type" , "application/json" )
243+ th .TestHeader (t , r , "Accept" , "application/json" )
244+ th .TestJSONRequest (t , r , AddRemoveGatewayNetworkJSON )
245+
246+ w .Header ().Add ("Content-Type" , "application/json" )
247+ w .WriteHeader (http .StatusOK )
248+ fmt .Fprintf (w , AddRemoveGatewayNetworkJSON )
249+ })
250+
251+ opts := speakers.AddGatewayNetworkOpts {NetworkID : networkID }
252+ r , err := speakers .AddGatewayNetwork (fake .ServiceClient (), bgpSpeakerID , opts ).Extract ()
253+ th .AssertNoErr (t , err )
254+ th .AssertEquals (t , r .NetworkID , networkID )
255+ }
256+
257+ func TestRemoveGatewayNetwork (t * testing.T ) {
258+ th .SetupHTTP ()
259+ defer th .TeardownHTTP ()
260+
261+ bgpSpeakerID := "ab01ade1-ae62-43c9-8a1f-3c24225b96d8"
262+ networkID := "ac13bb26-6219-49c3-a880-08847f6830b7"
263+ th .Mux .HandleFunc ("/v2.0/bgp-speakers/" + bgpSpeakerID + "/remove_gateway_network" , func (w http.ResponseWriter , r * http.Request ) {
264+ th .TestMethod (t , r , "PUT" )
265+ th .TestHeader (t , r , "X-Auth-Token" , fake .TokenID )
266+ th .TestHeader (t , r , "Content-Type" , "application/json" )
267+ th .TestHeader (t , r , "Accept" , "application/json" )
268+ th .TestJSONRequest (t , r , AddRemoveGatewayNetworkJSON )
269+
270+ w .Header ().Add ("Content-Type" , "application/json" )
271+ w .WriteHeader (http .StatusOK )
272+ fmt .Fprintf (w , "" )
273+ })
274+
275+ opts := speakers.RemoveGatewayNetworkOpts {NetworkID : networkID }
276+ err := speakers .RemoveGatewayNetwork (fake .ServiceClient (), bgpSpeakerID , opts ).ExtractErr ()
277+ th .AssertEquals (t , err , io .EOF )
278+ }
0 commit comments