github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/networking/v2/extensions/bgpvpns/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "context" 5 "fmt" 6 "net/http" 7 "testing" 8 9 fake "github.com/vnpaycloud-console/gophercloud/v2/openstack/networking/v2/common" 10 "github.com/vnpaycloud-console/gophercloud/v2/openstack/networking/v2/extensions/bgpvpns" 11 "github.com/vnpaycloud-console/gophercloud/v2/pagination" 12 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 13 ) 14 15 func TestList(t *testing.T) { 16 th.SetupHTTP() 17 defer th.TeardownHTTP() 18 19 filterProjectID := []string{"b7549121395844bea941bb92feb3fad9"} 20 fields := []string{"id", "name"} 21 listOpts := bgpvpns.ListOpts{ 22 Fields: fields, 23 ProjectID: filterProjectID[0], 24 } 25 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns", 26 func(w http.ResponseWriter, r *http.Request) { 27 th.TestMethod(t, r, "GET") 28 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 29 30 if err := r.ParseForm(); err != nil { 31 t.Errorf("Failed to parse request form %v", err) 32 } 33 th.AssertDeepEquals(t, r.Form["fields"], fields) 34 th.AssertDeepEquals(t, r.Form["project_id"], filterProjectID) 35 36 w.Header().Add("Content-Type", "application/json") 37 w.WriteHeader(http.StatusOK) 38 fmt.Fprint(w, ListBGPVPNsResult) 39 }) 40 count := 0 41 42 err := bgpvpns.List(fake.ServiceClient(), listOpts).EachPage( 43 context.TODO(), 44 func(_ context.Context, page pagination.Page) (bool, error) { 45 count++ 46 actual, err := bgpvpns.ExtractBGPVPNs(page) 47 if err != nil { 48 t.Errorf("Failed to extract BGP VPNs: %v", err) 49 return false, nil 50 } 51 52 expected := []bgpvpns.BGPVPN{BGPVPN} 53 th.CheckDeepEquals(t, expected, actual) 54 55 return true, nil 56 }) 57 th.AssertNoErr(t, err) 58 } 59 60 func TestGet(t *testing.T) { 61 th.SetupHTTP() 62 defer th.TeardownHTTP() 63 64 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 65 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { 66 th.TestMethod(t, r, "GET") 67 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 68 w.Header().Add("Content-Type", "application/json") 69 w.WriteHeader(http.StatusOK) 70 fmt.Fprint(w, GetBGPVPNResult) 71 }) 72 73 r, err := bgpvpns.Get(context.TODO(), fake.ServiceClient(), bgpVpnID).Extract() 74 th.AssertNoErr(t, err) 75 th.CheckDeepEquals(t, GetBGPVPN, *r) 76 } 77 78 func TestCreate(t *testing.T) { 79 th.SetupHTTP() 80 defer th.TeardownHTTP() 81 82 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns", func(w http.ResponseWriter, r *http.Request) { 83 th.TestMethod(t, r, "POST") 84 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 85 th.TestHeader(t, r, "Content-Type", "application/json") 86 th.TestHeader(t, r, "Accept", "application/json") 87 th.TestJSONRequest(t, r, CreateRequest) 88 w.Header().Add("Content-Type", "application/json") 89 w.WriteHeader(http.StatusCreated) 90 fmt.Fprint(w, CreateResponse) 91 }) 92 93 opts := bgpvpns.CreateOpts{ 94 TenantID: "b7549121395844bea941bb92feb3fad9", 95 RouteTargets: []string{ 96 "64512:1444", 97 }, 98 ImportTargets: []string{ 99 "64512:1555", 100 }, 101 ExportTargets: []string{ 102 "64512:1666", 103 }, 104 RouteDistinguishers: []string{ 105 "64512:1777", 106 "64512:1888", 107 "64512:1999", 108 }, 109 Type: "l3", 110 VNI: 1000, 111 } 112 113 r, err := bgpvpns.Create(context.TODO(), fake.ServiceClient(), opts).Extract() 114 th.AssertNoErr(t, err) 115 th.AssertDeepEquals(t, CreateBGPVPN, *r) 116 } 117 118 func TestDelete(t *testing.T) { 119 bgpVpnID := "0f9d472a-908f-40f5-8574-b4e8a63ccbf0" 120 th.SetupHTTP() 121 defer th.TeardownHTTP() 122 123 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { 124 th.TestMethod(t, r, "DELETE") 125 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 126 th.TestHeader(t, r, "Accept", "application/json") 127 128 w.Header().Add("Content-Type", "application/json") 129 w.WriteHeader(http.StatusNoContent) 130 }) 131 132 err := bgpvpns.Delete(context.TODO(), fake.ServiceClient(), bgpVpnID).ExtractErr() 133 th.AssertNoErr(t, err) 134 } 135 136 func TestUpdate(t *testing.T) { 137 bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" 138 th.SetupHTTP() 139 defer th.TeardownHTTP() 140 141 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID, func(w http.ResponseWriter, r *http.Request) { 142 th.TestMethod(t, r, "PUT") 143 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 144 th.TestHeader(t, r, "Content-Type", "application/json") 145 th.TestHeader(t, r, "Accept", "application/json") 146 th.TestJSONRequest(t, r, UpdateBGPVPNRequest) 147 148 w.Header().Add("Content-Type", "application/json") 149 w.WriteHeader(http.StatusOK) 150 151 fmt.Fprint(w, UpdateBGPVPNResponse) 152 }) 153 154 name := "foo" 155 routeTargets := []string{"64512:1444"} 156 emptyTarget := []string{} 157 opts := bgpvpns.UpdateOpts{ 158 Name: &name, 159 RouteTargets: &routeTargets, 160 ImportTargets: &emptyTarget, 161 ExportTargets: &emptyTarget, 162 } 163 164 r, err := bgpvpns.Update(context.TODO(), fake.ServiceClient(), bgpVpnID, opts).Extract() 165 th.AssertNoErr(t, err) 166 th.AssertDeepEquals(t, *opts.Name, r.Name) 167 } 168 169 func TestListNetworkAssociations(t *testing.T) { 170 th.SetupHTTP() 171 defer th.TeardownHTTP() 172 173 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 174 fields := []string{"id", "name"} 175 listOpts := bgpvpns.ListNetworkAssociationsOpts{ 176 Fields: fields, 177 } 178 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations", func(w http.ResponseWriter, r *http.Request) { 179 th.TestMethod(t, r, "GET") 180 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 181 182 if err := r.ParseForm(); err != nil { 183 t.Errorf("Failed to parse request form %v", err) 184 } 185 th.AssertDeepEquals(t, fields, r.Form["fields"]) 186 187 w.Header().Add("Content-Type", "application/json") 188 w.WriteHeader(http.StatusOK) 189 fmt.Fprint(w, ListNetworkAssociationsResult) 190 }) 191 192 count := 0 193 err := bgpvpns.ListNetworkAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( 194 context.TODO(), 195 func(_ context.Context, page pagination.Page) (bool, error) { 196 count++ 197 actual, err := bgpvpns.ExtractNetworkAssociations(page) 198 if err != nil { 199 t.Errorf("Failed to extract network associations: %v", err) 200 return false, nil 201 } 202 203 expected := []bgpvpns.NetworkAssociation{NetworkAssociation} 204 th.CheckDeepEquals(t, expected, actual) 205 206 return true, nil 207 }) 208 209 th.AssertNoErr(t, err) 210 th.AssertEquals(t, 1, count) 211 } 212 213 func TestCreateNetworkAssociation(t *testing.T) { 214 th.SetupHTTP() 215 defer th.TeardownHTTP() 216 217 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 218 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations", func(w http.ResponseWriter, r *http.Request) { 219 th.TestMethod(t, r, "POST") 220 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 221 th.TestHeader(t, r, "Content-Type", "application/json") 222 th.TestHeader(t, r, "Accept", "application/json") 223 th.TestJSONRequest(t, r, CreateNetworkAssociationRequest) 224 w.Header().Add("Content-Type", "application/json") 225 w.WriteHeader(http.StatusCreated) 226 fmt.Fprint(w, CreateNetworkAssociationResponse) 227 }) 228 229 opts := bgpvpns.CreateNetworkAssociationOpts{ 230 NetworkID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", 231 } 232 r, err := bgpvpns.CreateNetworkAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, opts).Extract() 233 th.AssertNoErr(t, err) 234 th.AssertDeepEquals(t, CreateNetworkAssociation, *r) 235 } 236 237 func TestGetNetworkAssociation(t *testing.T) { 238 th.SetupHTTP() 239 defer th.TeardownHTTP() 240 241 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 242 networkAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 243 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations/"+networkAssociationID, func(w http.ResponseWriter, r *http.Request) { 244 th.TestMethod(t, r, "GET") 245 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 246 w.Header().Add("Content-Type", "application/json") 247 w.WriteHeader(http.StatusOK) 248 fmt.Fprint(w, GetNetworkAssociationResult) 249 }) 250 251 r, err := bgpvpns.GetNetworkAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, networkAssociationID).Extract() 252 th.AssertNoErr(t, err) 253 th.CheckDeepEquals(t, GetNetworkAssociation, *r) 254 } 255 256 func TestDeleteNetworkAssociation(t *testing.T) { 257 th.SetupHTTP() 258 defer th.TeardownHTTP() 259 260 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 261 networkAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 262 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/network_associations/"+networkAssociationID, func(w http.ResponseWriter, r *http.Request) { 263 th.TestMethod(t, r, "DELETE") 264 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 265 w.WriteHeader(http.StatusNoContent) 266 }) 267 268 err := bgpvpns.DeleteNetworkAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, networkAssociationID).ExtractErr() 269 th.AssertNoErr(t, err) 270 } 271 272 func TestListRouterAssociations(t *testing.T) { 273 th.SetupHTTP() 274 defer th.TeardownHTTP() 275 276 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 277 fields := []string{"id", "name"} 278 listOpts := bgpvpns.ListRouterAssociationsOpts{ 279 Fields: fields, 280 } 281 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations", func(w http.ResponseWriter, r *http.Request) { 282 th.TestMethod(t, r, "GET") 283 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 284 285 if err := r.ParseForm(); err != nil { 286 t.Errorf("Failed to parse request form %v", err) 287 } 288 th.AssertDeepEquals(t, fields, r.Form["fields"]) 289 290 w.Header().Add("Content-Type", "application/json") 291 w.WriteHeader(http.StatusOK) 292 fmt.Fprint(w, ListRouterAssociationsResult) 293 }) 294 295 count := 0 296 err := bgpvpns.ListRouterAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( 297 context.TODO(), 298 func(_ context.Context, page pagination.Page) (bool, error) { 299 count++ 300 actual, err := bgpvpns.ExtractRouterAssociations(page) 301 if err != nil { 302 t.Errorf("Failed to extract router associations: %v", err) 303 return false, nil 304 } 305 306 expected := []bgpvpns.RouterAssociation{RouterAssociation} 307 th.CheckDeepEquals(t, expected, actual) 308 309 return true, nil 310 }) 311 312 th.AssertNoErr(t, err) 313 th.AssertEquals(t, 1, count) 314 } 315 316 func TestCreateRouterAssociation(t *testing.T) { 317 th.SetupHTTP() 318 defer th.TeardownHTTP() 319 320 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 321 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations", func(w http.ResponseWriter, r *http.Request) { 322 th.TestMethod(t, r, "POST") 323 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 324 th.TestHeader(t, r, "Content-Type", "application/json") 325 th.TestHeader(t, r, "Accept", "application/json") 326 th.TestJSONRequest(t, r, CreateRouterAssociationRequest) 327 w.Header().Add("Content-Type", "application/json") 328 w.WriteHeader(http.StatusCreated) 329 fmt.Fprint(w, CreateRouterAssociationResponse) 330 }) 331 332 opts := bgpvpns.CreateRouterAssociationOpts{ 333 RouterID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", 334 } 335 r, err := bgpvpns.CreateRouterAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, opts).Extract() 336 th.AssertNoErr(t, err) 337 th.AssertDeepEquals(t, CreateRouterAssociation, *r) 338 } 339 340 func TestGetRouterAssociation(t *testing.T) { 341 th.SetupHTTP() 342 defer th.TeardownHTTP() 343 344 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 345 routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 346 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { 347 th.TestMethod(t, r, "GET") 348 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 349 w.Header().Add("Content-Type", "application/json") 350 w.WriteHeader(http.StatusOK) 351 fmt.Fprint(w, GetRouterAssociationResult) 352 }) 353 354 r, err := bgpvpns.GetRouterAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, routerAssociationID).Extract() 355 th.AssertNoErr(t, err) 356 th.CheckDeepEquals(t, GetRouterAssociation, *r) 357 } 358 359 func TestUpdateRouterAssociation(t *testing.T) { 360 bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" 361 routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 362 th.SetupHTTP() 363 defer th.TeardownHTTP() 364 365 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { 366 th.TestMethod(t, r, "PUT") 367 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 368 th.TestHeader(t, r, "Content-Type", "application/json") 369 th.TestHeader(t, r, "Accept", "application/json") 370 th.TestJSONRequest(t, r, UpdateRouterAssociationRequest) 371 w.Header().Add("Content-Type", "application/json") 372 w.WriteHeader(http.StatusOK) 373 fmt.Fprint(w, UpdateRouterAssociationResponse) 374 }) 375 376 opts := bgpvpns.UpdateRouterAssociationOpts{ 377 AdvertiseExtraRoutes: new(bool), 378 } 379 r, err := bgpvpns.UpdateRouterAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, routerAssociationID, opts).Extract() 380 th.AssertNoErr(t, err) 381 th.AssertDeepEquals(t, UpdateRouterAssociation, *r) 382 } 383 384 func TestDeleteRouterAssociation(t *testing.T) { 385 th.SetupHTTP() 386 defer th.TeardownHTTP() 387 388 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 389 routerAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 390 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/router_associations/"+routerAssociationID, func(w http.ResponseWriter, r *http.Request) { 391 th.TestMethod(t, r, "DELETE") 392 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 393 w.WriteHeader(http.StatusNoContent) 394 }) 395 396 err := bgpvpns.DeleteRouterAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, routerAssociationID).ExtractErr() 397 th.AssertNoErr(t, err) 398 } 399 400 func TestListPortAssociations(t *testing.T) { 401 th.SetupHTTP() 402 defer th.TeardownHTTP() 403 404 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 405 fields := []string{"id", "name"} 406 listOpts := bgpvpns.ListPortAssociationsOpts{ 407 Fields: fields, 408 } 409 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations", func(w http.ResponseWriter, r *http.Request) { 410 th.TestMethod(t, r, "GET") 411 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 412 413 if err := r.ParseForm(); err != nil { 414 t.Errorf("Failed to parse request form %v", err) 415 } 416 th.AssertDeepEquals(t, fields, r.Form["fields"]) 417 418 w.Header().Add("Content-Type", "application/json") 419 w.WriteHeader(http.StatusOK) 420 fmt.Fprint(w, ListPortAssociationsResult) 421 }) 422 423 count := 0 424 err := bgpvpns.ListPortAssociations(fake.ServiceClient(), bgpVpnID, listOpts).EachPage( 425 context.TODO(), 426 func(_ context.Context, page pagination.Page) (bool, error) { 427 count++ 428 actual, err := bgpvpns.ExtractPortAssociations(page) 429 if err != nil { 430 t.Errorf("Failed to extract port associations: %v", err) 431 return false, nil 432 } 433 434 expected := []bgpvpns.PortAssociation{PortAssociation} 435 th.CheckDeepEquals(t, expected, actual) 436 437 return true, nil 438 }) 439 440 th.AssertNoErr(t, err) 441 th.AssertEquals(t, 1, count) 442 } 443 444 func TestCreatePortAssociation(t *testing.T) { 445 th.SetupHTTP() 446 defer th.TeardownHTTP() 447 448 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 449 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations", func(w http.ResponseWriter, r *http.Request) { 450 th.TestMethod(t, r, "POST") 451 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 452 th.TestHeader(t, r, "Content-Type", "application/json") 453 th.TestHeader(t, r, "Accept", "application/json") 454 th.TestJSONRequest(t, r, CreatePortAssociationRequest) 455 w.Header().Add("Content-Type", "application/json") 456 w.WriteHeader(http.StatusCreated) 457 fmt.Fprint(w, CreatePortAssociationResponse) 458 }) 459 460 opts := bgpvpns.CreatePortAssociationOpts{ 461 PortID: "8c5d88dc-60ac-4b02-a65a-36b65888ddcd", 462 } 463 r, err := bgpvpns.CreatePortAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, opts).Extract() 464 th.AssertNoErr(t, err) 465 th.AssertDeepEquals(t, CreatePortAssociation, *r) 466 } 467 468 func TestGetPortAssociation(t *testing.T) { 469 th.SetupHTTP() 470 defer th.TeardownHTTP() 471 472 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 473 portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 474 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { 475 th.TestMethod(t, r, "GET") 476 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 477 w.Header().Add("Content-Type", "application/json") 478 w.WriteHeader(http.StatusOK) 479 fmt.Fprint(w, GetPortAssociationResult) 480 }) 481 482 r, err := bgpvpns.GetPortAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, portAssociationID).Extract() 483 th.AssertNoErr(t, err) 484 th.CheckDeepEquals(t, GetPortAssociation, *r) 485 } 486 487 func TestUpdatePortAssociation(t *testing.T) { 488 bgpVpnID := "4d627abf-06dd-45ab-920b-8e61422bb984" 489 portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 490 th.SetupHTTP() 491 defer th.TeardownHTTP() 492 493 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { 494 th.TestMethod(t, r, "PUT") 495 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 496 th.TestHeader(t, r, "Content-Type", "application/json") 497 th.TestHeader(t, r, "Accept", "application/json") 498 th.TestJSONRequest(t, r, UpdatePortAssociationRequest) 499 w.Header().Add("Content-Type", "application/json") 500 w.WriteHeader(http.StatusOK) 501 fmt.Fprint(w, UpdatePortAssociationResponse) 502 }) 503 504 opts := bgpvpns.UpdatePortAssociationOpts{ 505 AdvertiseFixedIPs: new(bool), 506 } 507 r, err := bgpvpns.UpdatePortAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, portAssociationID, opts).Extract() 508 th.AssertNoErr(t, err) 509 th.AssertDeepEquals(t, UpdatePortAssociation, *r) 510 } 511 512 func TestDeletePortAssociation(t *testing.T) { 513 th.SetupHTTP() 514 defer th.TeardownHTTP() 515 516 bgpVpnID := "460ac411-3dfb-45bb-8116-ed1a7233d143" 517 portAssociationID := "73238ca1-e05d-4c7a-b4d4-70407b4b8730" 518 th.Mux.HandleFunc("/v2.0/bgpvpn/bgpvpns/"+bgpVpnID+"/port_associations/"+portAssociationID, func(w http.ResponseWriter, r *http.Request) { 519 th.TestMethod(t, r, "DELETE") 520 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 521 w.WriteHeader(http.StatusNoContent) 522 }) 523 524 err := bgpvpns.DeletePortAssociation(context.TODO(), fake.ServiceClient(), bgpVpnID, portAssociationID).ExtractErr() 525 th.AssertNoErr(t, err) 526 }