Skip to content

Commit 440da80

Browse files
Merge pull request #30 from IBM/md5
feat(DirectLink): implement the BGP MD5 changes for Direct Link gateway
2 parents 87e6bf1 + 0a7b542 commit 440da80

35 files changed

+726
-117
lines changed

dl.env.enc

0 Bytes
Binary file not shown.

ibm_cloud_networking_services/direct_link_v1.py

Lines changed: 360 additions & 24 deletions
Large diffs are not rendered by default.

test/integration/test_caching_api_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
class TestCachingApiV1(unittest.TestCase):
2323
""" Test class to call Caching API functions """
2424

25+
@unittest.skip("skipping")
26+
2527
def setUp(self):
2628
if not os.path.exists(configFile):
2729
raise unittest.SkipTest(

test/integration/test_cis_ip_api_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020

2121
class TestCisIpApiV1 (unittest.TestCase):
22+
@unittest.skip("skipping")
23+
2224
def setUp(self):
2325
""" test case setup """
2426
if not os.path.exists(configFile):

test/integration/test_custom_pages_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
class TestCustomPagesV1(unittest.TestCase):
2323
""" Custom Pages test class """
2424

25+
@unittest.skip("skipping")
26+
2527
def setUp(self):
2628
if not os.path.exists(configFile):
2729
raise unittest.SkipTest(

test/integration/test_direct_link_provider_v2.py

Lines changed: 93 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -384,75 +384,100 @@ def test_provider_gateway_actions_with_client_api(self):
384384

385385
################## Direct Link Provider Gateways with Client API MD5 Auth ############################
386386

387-
# Commenting the test key till Key Protect instance is ready in INT environment
388-
# def test_provider_gateway_actions_with_client_api_md5(self):
389-
# timestamp = time.time()
390-
# name = os.getenv("DL_PROVIDER_SERVICES_GW_NAME") + "-" + str(int(timestamp))
391-
# bgpAsn = 64999
392-
# customerAccount = os.getenv("DL_PROVIDER_SERVICES_CUSTOMER_ACCT_ID")
393-
# speedMbps = 1000
394-
# authenticationKeyCRN = os.getenv("DL_SERVICES_AUTHENTICATION_KEY")
395-
# authenticationKey = GatewayActionTemplateAuthenticationKey(authenticationKeyCRN)
396-
397-
# """ successfully get a provider port id """
398-
# response = self.dl_provider.list_provider_ports()
399-
# assert response is not None
400-
401-
# port_id = response.get_result().get("ports")[0].get("id")
402-
# port = ProviderGatewayPortIdentity(id=port_id)
403-
404-
# #created provider gateway
405-
# response = self.dl_provider.create_provider_gateway(bgp_asn=bgpAsn,
406-
# customer_account_id=customerAccount,
407-
# name=name,
408-
# port=port,
409-
# speed_mbps=speedMbps)
410-
# assert response is not None
411-
# assert response.get_status_code() == 201
412-
# gateway_id = response.get_result().get("id")
413-
414-
# #verfiy client account can see the provider created gateway
415-
# response = self.dl.get_gateway(id=gateway_id)
416-
# assert response is not None
417-
# assert response.get_status_code() == 200
418-
# assert response.get_result().get("id") == gateway_id
419-
# assert response.get_result().get("name") == name
420-
# assert response.get_result().get("speed_mbps") == speedMbps
421-
# assert response.get_result().get("provider_api_managed") == True
422-
# assert response.get_result().get("operational_status") == "create_pending"
423-
# assert response.get_result().get("type") == "connect"
424-
# assert "change_request" in response.get_result()
425-
426-
# #successfully approve the gateway create using client account
427-
# response = self.dl.create_gateway_action(id=gateway_id,
428-
# action="create_gateway_approve",
429-
# metered=False,
430-
# global_=False,
431-
# authentication_key=authenticationKey)
432-
# assert response is not None
433-
# assert response.get_status_code() == 200
434-
# result = response.get_result()
435-
# assert result['id'] == gateway_id
436-
# assert result['name'] == name
437-
# assert result['authentication_key']['crn'] == authenticationKeyCRN
438-
439-
# #verfiy client account can see the authentication key
440-
# response = self.dl.get_gateway(id=gateway_id)
441-
# assert response is not None
442-
# assert response.get_status_code() == 200
443-
# assert result['id'] == gateway_id
444-
# assert result['name'] == name
445-
# assert result['authentication_key']['crn'] == authenticationKeyCRN
387+
def test_provider_gateway_actions_with_client_api_md5(self):
388+
timestamp = time.time()
389+
name = os.getenv("DL_PROVIDER_SERVICES_GW_NAME") + "-md5-" + str(int(timestamp))
390+
bgpAsn = 64999
391+
customerAccount = os.getenv("DL_PROVIDER_SERVICES_CUSTOMER_ACCT_ID")
392+
speedMbps = 1000
393+
authenticationKeyCRN = os.getenv("DL_SERVICES_AUTHENTICATION_KEY")
394+
authenticationKey = GatewayActionTemplateAuthenticationKey(authenticationKeyCRN)
395+
396+
""" successfully get a provider port id """
397+
response = self.dl_provider.list_provider_ports()
398+
assert response is not None
399+
400+
port_id = response.get_result().get("ports")[0].get("id")
401+
port = ProviderGatewayPortIdentity(id=port_id)
402+
403+
#created provider gateway
404+
response = self.dl_provider.create_provider_gateway(bgp_asn=bgpAsn,
405+
customer_account_id=customerAccount,
406+
name=name,
407+
port=port,
408+
speed_mbps=speedMbps)
409+
assert response is not None
410+
assert response.get_status_code() == 201
411+
gateway_id = response.get_result().get("id")
412+
413+
#verfiy client account can see the provider created gateway
414+
response = self.dl.get_gateway(id=gateway_id)
415+
assert response is not None
416+
assert response.get_status_code() == 200
417+
assert response.get_result().get("id") == gateway_id
418+
assert response.get_result().get("name") == name
419+
assert response.get_result().get("speed_mbps") == speedMbps
420+
assert response.get_result().get("provider_api_managed") == True
421+
assert response.get_result().get("operational_status") == "create_pending"
422+
assert response.get_result().get("type") == "connect"
423+
assert "change_request" in response.get_result()
424+
425+
#successfully approve the gateway create using client account
426+
response = self.dl.create_gateway_action(id=gateway_id,
427+
action="create_gateway_approve",
428+
metered=False,
429+
global_=False,
430+
authentication_key=authenticationKey)
431+
assert response is not None
432+
assert response.get_status_code() == 200
433+
result = response.get_result()
434+
assert result['id'] == gateway_id
435+
assert result['name'] == name
436+
assert result['authentication_key']['crn'] == authenticationKeyCRN
437+
438+
# wait until gateway moves to provisioned state
439+
count = 0
440+
while True:
441+
response = None
442+
response = self.dl.get_gateway(id=gateway_id)
443+
operationalStatus = response.get_result().get("operational_status")
444+
445+
if (response is not None) and (response.get_result().get("operational_status") == "provisioned"):
446+
assert response is not None
447+
assert response.get_status_code() == 200
448+
assert response.get_result().get("id") == gateway_id
449+
assert response.get_result().get("name") == name
450+
assert response.get_result().get("speed_mbps") == speedMbps
451+
assert response.get_result().get("provider_api_managed") == True
452+
assert response.get_result().get("operational_status") == "provisioned"
453+
assert response.get_result().get("type") == "connect"
454+
break
455+
456+
if count > 24:
457+
assert response.get_result().get("operational_status") == "provisioned"
458+
else:
459+
time.sleep(10)
460+
count += 1
461+
462+
#verfiy client account can see the authentication key
463+
response = self.dl.get_gateway(id=gateway_id)
464+
assert response is not None
465+
assert response.get_status_code() == 200
466+
result = response.get_result()
467+
assert result['id'] == gateway_id
468+
assert result['name'] == name
469+
assert result['authentication_key']['crn'] == authenticationKeyCRN
470+
446471

447-
# #successfully re-request delete using provider account
448-
# response = self.dl_provider.delete_provider_gateway(id=gateway_id)
449-
# assert response is not None
450-
# assert response.get_status_code() == 202
451-
452-
# #successfully approve delete gateway using client account
453-
# response = self.dl.create_gateway_action(id=gateway_id, action="delete_gateway_approve")
454-
# assert response is not None
455-
# assert response.get_status_code() == 204
472+
#successfully request delete using provider account
473+
response = self.dl_provider.delete_provider_gateway(id=gateway_id)
474+
assert response is not None
475+
assert response.get_status_code() == 202
476+
477+
#successfully approve delete gateway using client account
478+
response = self.dl.create_gateway_action(id=gateway_id, action="delete_gateway_approve")
479+
assert response is not None
480+
assert response.get_status_code() == 204
456481

457482
if __name__ == '__main__':
458483
unittest.main()

test/integration/test_direct_link_v1.py

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
2626
from ibm_cloud_networking_services import DirectLinkV1
2727
from ibm_cloud_networking_services.direct_link_v1 import (
28-
GatewayTemplateGatewayTypeDedicatedTemplate)
28+
GatewayTemplateGatewayTypeDedicatedTemplate,
29+
GatewayTemplateAuthenticationKey,
30+
GatewayPatchTemplateAuthenticationKey
31+
)
2932
# from ibm_cloud_networking_services.direct_link_v1 import (
3033
# GatewayMacsecConfigTemplate)
3134
# from ibm_cloud_networking_services.direct_link_v1 import (
@@ -139,7 +142,7 @@ def delete_connection(self, gateway_id, conn_id):
139142

140143
################## DirectLink Gateways ######################################
141144

142-
def test_1_gateway_actions(self):
145+
def test_gateway_crud_actions(self):
143146
bgpAsn = 64999
144147
bgpBaseCidr = "169.254.0.0/16"
145148
crossConnectRouter = "LAB-xcr01.dal09"
@@ -232,7 +235,7 @@ def test_1_gateway_actions(self):
232235
# self.delete_gateway(gateway_id)
233236

234237
################### Ports ############################
235-
def test_1_list_get_ports(self):
238+
def test_list_get_ports(self):
236239
response = self.dl.list_ports()
237240
assert response is not None
238241

@@ -244,15 +247,15 @@ def test_1_list_get_ports(self):
244247

245248

246249
################## Offering Types ###########################################
247-
def test1_offering_type_locations(self):
250+
def test_offering_type_locations(self):
248251
""" test getting all locations by offering type """
249252
response = self.dl.list_offering_type_locations(
250253
offering_type="dedicated")
251254
assert response is not None
252255
assert response.get_status_code() == 200
253256
assert response.get_result() is not None
254257

255-
def test1_offering_type_locations_cross_connect_router(self):
258+
def test_offering_type_locations_cross_connect_router_short_name(self):
256259
""" test getting location info by short name """
257260
locationName = os.getenv("DL_SERVICES_LOCATION_NAME")
258261
response = self.dl.list_offering_type_location_cross_connect_routers(
@@ -261,7 +264,7 @@ def test1_offering_type_locations_cross_connect_router(self):
261264
assert response.get_status_code() == 200
262265
assert response.get_result() is not None
263266

264-
def test2_offering_type_locations_cross_connect_router(self):
267+
def test_offering_type_locations_cross_connect_router_long_name(self):
265268
""" test getting location info by long name """
266269
locationLongName = os.getenv("DL_SERVICES_LOCATION_LONG_NAME")
267270
response = self.dl.list_offering_type_location_cross_connect_routers(
@@ -270,7 +273,7 @@ def test2_offering_type_locations_cross_connect_router(self):
270273
assert response.get_status_code() == 200
271274
assert response.get_result() is not None
272275

273-
def test1_offering_type_speeds(self):
276+
def test_offering_type_speeds(self):
274277
""" test getting all sppeds by offering type """
275278
response = self.dl.list_offering_type_speeds(
276279
offering_type="dedicated")
@@ -283,7 +286,7 @@ def test1_offering_type_speeds(self):
283286

284287

285288
################## Virtual Connections ######################################
286-
def test_1_gateway_vc_actions(self):
289+
def test_gateway_vc_actions(self):
287290
""" test create/get/update/delete gateway connections success """
288291
bgpAsn = 64999
289292
bgpBaseCidr = "169.254.0.0/16"
@@ -354,7 +357,7 @@ def test_1_gateway_vc_actions(self):
354357
# - PUT a completion notice to the gw. It will fail with a 412 error because the GH issue and GW status are in the wrong state due to no manual interaction
355358
# - GET CN for a gw. It will expect a 404 since the CN could not be uploaded
356359

357-
def test_1_loa_and_completion(self):
360+
def test_loa_and_completion(self):
358361
bgpAsn = 64999
359362
bgpBaseCidr = "169.254.0.0/16"
360363
crossConnectRouter = "LAB-xcr01.dal09"
@@ -404,6 +407,53 @@ def test_1_loa_and_completion(self):
404407

405408
# delete gateway
406409
self.delete_gateway(gateway_id)
410+
411+
################## Direct Link Gateways with Customer API MD5 Auth ############################
412+
413+
def test_gateway_with_md5(self):
414+
bgpAsn = 64999
415+
crossConnectRouter = "LAB-xcr01.dal09"
416+
global_bool = True
417+
locationName = os.getenv("DL_SERVICES_LOCATION_NAME")
418+
speedMbps = 1000
419+
metered = False
420+
carrierName = "carrier1"
421+
customerName = "customer1"
422+
gatewayType = "dedicated"
423+
authKeyCrn = os.getenv("DL_SERVICES_AUTHENTICATION_KEY")
424+
authKey = GatewayTemplateAuthenticationKey(crn= authKeyCrn)
425+
426+
""" test create/update/delete gateway with authentication ket success """
427+
# create gateway with authentication key
428+
name = os.getenv("DL_SERVICES_GW_NAME") + str(int(time.time()))
429+
gtw_template = GatewayTemplateGatewayTypeDedicatedTemplate(name=name,
430+
type=gatewayType, speed_mbps=speedMbps, global_=global_bool,
431+
bgp_asn=bgpAsn, metered=metered,
432+
carrier_name=carrierName, cross_connect_router=crossConnectRouter,
433+
customer_name=customerName, location_name=locationName,
434+
authentication_key=authKey)
435+
response = self.dl.create_gateway(gateway_template=gtw_template)
436+
assert response is not None
437+
assert response.get_status_code() == 201
438+
gateway_id = response.get_result().get("id")
439+
440+
res = response.get_result()
441+
assert res["name"] == name
442+
assert res["authentication_key"]["crn"] == authKeyCrn
443+
assert response.get_result().get("authentication_key") is not None
444+
445+
# clear the authentication for the created gateway\
446+
updAuthKey = GatewayPatchTemplateAuthenticationKey(crn="")
447+
response = self.dl.update_gateway(id=gateway_id,
448+
authentication_key=updAuthKey)
449+
assert response is not None
450+
assert response.get_status_code() == 200
451+
assert response.get_result()["name"] == name
452+
assert response.get_result()["id"] == gateway_id
453+
assert response.get_result().get("authentication_key") is None
454+
455+
# delete gateway
456+
self.delete_gateway(gateway_id)
407457

408458

409459
if __name__ == '__main__':

test/integration/test_dns_record_bulk_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
class TestDnsRecordBulkV1(unittest.TestCase):
2424
""" DNS Record Bulk API test class """
2525

26+
@unittest.skip("skipping")
27+
2628
def setUp(self):
2729
if not os.path.exists(configFile):
2830
raise unittest.SkipTest(

test/integration/test_dns_records_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
class TestDnsRecordV1(unittest.TestCase):
2323
""" Test class to call dns record sdk functions """
2424

25+
@unittest.skip("skipping")
26+
2527
def setUp(self):
2628
""" test case setup """
2729
if not os.path.exists(configFile):

test/integration/test_dns_zones_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
class TestZonesV1(unittest.TestCase):
2323
"""The DNS Zones V1 service test class."""
2424

25+
@unittest.skip("skipping")
26+
2527
def setUp(self):
2628
""" test case setup """
2729
if not os.path.exists(configFile):

0 commit comments

Comments
 (0)