Skip to content

Commit bd20885

Browse files
feat(DirectLink): implement BGP MD5 changes
* Provide an option to add Key Protect or HPCS key instance while creating gateways using authentication_key * Provide an option to update/clear the Key Protect or HPCS key instance while updating gateways * Added integration tests for BGP MD5 functionality
1 parent e8c71b0 commit bd20885

File tree

5 files changed

+201
-24
lines changed

5 files changed

+201
-24
lines changed

direct-link/v1.ts

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ class DirectLinkV1 extends BaseService {
283283
*
284284
* @param {Object} params - The parameters to send to the service.
285285
* @param {string} params.id - Direct Link gateway identifier.
286+
* @param {GatewayPatchTemplateAuthenticationKey} [params.authenticationKey] - The identity of the standard key to use
287+
* for BGP MD5 authentication key.
288+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters
289+
* in length.
290+
* To clear the optional `authentication_key` field patch its crn to `""`.
286291
* @param {boolean} [params.global] - Gateways with global routing (`true`) can connect to networks outside of their
287292
* associated region.
288293
* @param {string} [params.loaRejectReason] - Use this field during LOA rejection to provide the reason for the
@@ -318,6 +323,7 @@ class DirectLinkV1 extends BaseService {
318323
}
319324

320325
const body = {
326+
'authentication_key': _params.authenticationKey,
321327
'global': _params.global,
322328
'loa_reject_reason': _params.loaRejectReason,
323329
'macsec_config': _params.macsecConfig,
@@ -368,13 +374,10 @@ class DirectLinkV1 extends BaseService {
368374
* @param {Object} params - The parameters to send to the service.
369375
* @param {string} params.id - Direct Link Connect gateway identifier.
370376
* @param {string} params.action - Action request.
371-
* @param {GatewayActionTemplateAuthenticationKey} [params.authenticationKey] - BGP MD5 authentication key.
372-
*
373-
* BGP MD5 keys must be type=standard.
374-
*
377+
* @param {GatewayActionTemplateAuthenticationKey} [params.authenticationKey] - The identity of the standard key to
378+
* use for BGP MD5 authentication key.
375379
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters
376380
* in length.
377-
*
378381
* To clear the optional `authentication_key` field patch its crn to `""`.
379382
* @param {boolean} [params.global] - Required for create_gateway_approve requests to select the gateway's routing
380383
* option. Gateways with global routing (`true`) can connect to networks outside of their associated region.
@@ -1241,6 +1244,12 @@ namespace DirectLinkV1 {
12411244
export interface UpdateGatewayParams {
12421245
/** Direct Link gateway identifier. */
12431246
id: string;
1247+
/** The identity of the standard key to use for BGP MD5 authentication key.
1248+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
1249+
* characters in length.
1250+
* To clear the optional `authentication_key` field patch its crn to `""`.
1251+
*/
1252+
authenticationKey?: GatewayPatchTemplateAuthenticationKey;
12441253
/** Gateways with global routing (`true`) can connect to networks outside of their associated region. */
12451254
global?: boolean;
12461255
/** Use this field during LOA rejection to provide the reason for the rejection.
@@ -1288,13 +1297,9 @@ namespace DirectLinkV1 {
12881297
id: string;
12891298
/** Action request. */
12901299
action: CreateGatewayActionConstants.Action | string;
1291-
/** BGP MD5 authentication key.
1292-
*
1293-
* BGP MD5 keys must be type=standard.
1294-
*
1300+
/** The identity of the standard key to use for BGP MD5 authentication key.
12951301
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
12961302
* characters in length.
1297-
*
12981303
* To clear the optional `authentication_key` field patch its crn to `""`.
12991304
*/
13001305
authenticationKey?: GatewayActionTemplateAuthenticationKey;
@@ -1536,13 +1541,9 @@ namespace DirectLinkV1 {
15361541

15371542
/** gateway. */
15381543
export interface Gateway {
1539-
/** BGP MD5 authentication key.
1540-
*
1541-
* BGP MD5 keys must be type=standard.
1542-
*
1544+
/** The identity of the standard key to use for BGP MD5 authentication key.
15431545
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
15441546
* characters in length.
1545-
*
15461547
* To clear the optional `authentication_key` field patch its crn to `""`.
15471548
*/
15481549
authentication_key?: GatewayAuthenticationKey;
@@ -1551,7 +1552,7 @@ namespace DirectLinkV1 {
15511552
/** (DEPRECATED) BGP base CIDR is deprecated and no longer recognized by the Direct Link APIs.
15521553
*
15531554
* See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related information.
1554-
*
1555+
*
15551556
* Deprecated field bgp_base_cidr will be removed from the API specificiation after 15-MAR-2021.
15561557
*/
15571558
bgp_base_cidr?: string;
@@ -1623,15 +1624,21 @@ namespace DirectLinkV1 {
16231624
vlan?: number;
16241625
}
16251626

1626-
/** BGP MD5 authentication key. BGP MD5 keys must be type=standard. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1627+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
16271628
export interface GatewayActionTemplateAuthenticationKey {
1628-
/** connectivity association key crn. */
1629+
/** The CRN of the [Key Protect Standard
1630+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1631+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1632+
*/
16291633
crn: string;
16301634
}
16311635

1632-
/** BGP MD5 authentication key. BGP MD5 keys must be type=standard. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1636+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
16331637
export interface GatewayAuthenticationKey {
1634-
/** connectivity association key crn. */
1638+
/** The CRN of the [Key Protect Standard
1639+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1640+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1641+
*/
16351642
crn: string;
16361643
}
16371644

@@ -1785,6 +1792,15 @@ namespace DirectLinkV1 {
17851792
crn: string;
17861793
}
17871794

1795+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1796+
export interface GatewayPatchTemplateAuthenticationKey {
1797+
/** The CRN of the [Key Protect Standard
1798+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1799+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1800+
*/
1801+
crn: string;
1802+
}
1803+
17881804
/** gateway port for type=connect gateways. */
17891805
export interface GatewayPort {
17901806
/** Port Identifier. */
@@ -1815,6 +1831,12 @@ namespace DirectLinkV1 {
18151831

18161832
/** Create gateway template. */
18171833
export interface GatewayTemplate {
1834+
/** The identity of the standard key to use for BGP MD5 authentication key.
1835+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
1836+
* characters in length.
1837+
* To clear the optional `authentication_key` field patch its crn to `""`.
1838+
*/
1839+
authentication_key?: GatewayTemplateAuthenticationKey;
18181840
/** BGP ASN. */
18191841
bgp_asn: number;
18201842
/** (DEPRECATED) BGP base CIDR.
@@ -1863,6 +1885,33 @@ namespace DirectLinkV1 {
18631885
type: string;
18641886
}
18651887

1888+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1889+
export interface GatewayTemplateAuthenticationKey {
1890+
/** The CRN of the [Key Protect Standard
1891+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1892+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1893+
*/
1894+
crn: string;
1895+
}
1896+
1897+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1898+
export interface GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey {
1899+
/** The CRN of the [Key Protect Standard
1900+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1901+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1902+
*/
1903+
crn: string;
1904+
}
1905+
1906+
/** The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. */
1907+
export interface GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey {
1908+
/** The CRN of the [Key Protect Standard
1909+
* Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto
1910+
* Service Standard Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource.
1911+
*/
1912+
crn: string;
1913+
}
1914+
18661915
/** Virtual connection. */
18671916
export interface GatewayVirtualConnection {
18681917
/** The date and time resource was created. */
@@ -2043,12 +2092,24 @@ namespace DirectLinkV1 {
20432092

20442093
/** Gateway fields specific to type=connect gateway create. */
20452094
export interface GatewayTemplateGatewayTypeConnectTemplate extends GatewayTemplate {
2095+
/** The identity of the standard key to use for BGP MD5 authentication key.
2096+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
2097+
* characters in length.
2098+
* To clear the optional `authentication_key` field patch its crn to `""`.
2099+
*/
2100+
authentication_key?: GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey;
20462101
/** Select Port Label for new type=connect gateway. */
20472102
port: GatewayPortIdentity;
20482103
}
20492104

20502105
/** Gateway fields specific to type=dedicated gateway create. */
20512106
export interface GatewayTemplateGatewayTypeDedicatedTemplate extends GatewayTemplate {
2107+
/** The identity of the standard key to use for BGP MD5 authentication key.
2108+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
2109+
* characters in length.
2110+
* To clear the optional `authentication_key` field patch its crn to `""`.
2111+
*/
2112+
authentication_key?: GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey;
20522113
/** Carrier name. */
20532114
carrier_name: string;
20542115
/** Cross connect router. */

directlink.env.enc

0 Bytes
Binary file not shown.

test/integration/direct-link-provider.v2.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,11 @@ describe('DirectLinkProviderV2', () => {
601601
});
602602
});
603603

604-
// Skipping the below test until integration CRN is available for authentication_key
605-
describe.skip('Direct Link Provider Gateways with Client API with authenticationKey', () => {
604+
describe('Direct Link Provider Gateways with Client API with authenticationKey', () => {
606605
jest.setTimeout(timeout);
607606

608-
const gwName = 'NODE-INT-SDK-PROVIDER-' + timestamp;
607+
const time = currentDate.getTime().toString();
608+
const gwName = 'NODE-INT-SDK-PROVIDER-' + time;
609609
const speedMbps = 1000;
610610

611611
let portId = '';

test/integration/direct-link.v1.test.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,4 +1057,104 @@ describe('DirectLinkV1', () => {
10571057
}
10581058
});
10591059
});
1060+
1061+
describe('Create MD5 enabled gateway', () => {
1062+
// Save the gateway ID for update/delete
1063+
let gatewayId = '';
1064+
const time = currentDate.getTime().toString();
1065+
1066+
// GatewayTemplate for dedicated gateway
1067+
const gatewayTemplate = {
1068+
name: 'NODE-INT-SDK-DEDICATED-MD5' + time,
1069+
type: 'dedicated',
1070+
speed_mbps: 1000,
1071+
global: true,
1072+
bgp_asn: 64999,
1073+
metered: false,
1074+
carrier_name: 'myCarrierName',
1075+
customer_name: 'newCustomerName',
1076+
cross_connect_router: 'LAB-xcr01.dal09',
1077+
location_name: config.LOCATION_NAME,
1078+
authentication_key: {
1079+
crn: config.AUTHENTICATION_KEY,
1080+
},
1081+
};
1082+
1083+
it('should successfully create a gateway with authentication key', async done => {
1084+
jest.setTimeout(timeout);
1085+
1086+
const params = {
1087+
gatewayTemplate: gatewayTemplate,
1088+
};
1089+
1090+
try {
1091+
dlService.createGateway(params).then(response => {
1092+
expect(response.hasOwnProperty('status')).toBe(true);
1093+
expect(response.status).toBe(201);
1094+
if (null != response && null != response.result && null != response.result.id) {
1095+
gatewayId = response.result.id;
1096+
}
1097+
1098+
expect(response.result.id).toBeDefined();
1099+
expect(response.result.name).toBe(gatewayTemplate.name);
1100+
expect(response.result.type).toBe(gatewayTemplate.type);
1101+
expect(response.result.speed_mbps).toBe(gatewayTemplate.speed_mbps);
1102+
expect(response.result.global).toBe(gatewayTemplate.global);
1103+
expect(response.result.bgp_asn).toBe(gatewayTemplate.bgp_asn);
1104+
expect(response.result.bgp_cer_cidr).toBeDefined();
1105+
expect(response.result.bgp_ibm_cidr).toBeDefined();
1106+
expect(response.result.metered).toBe(gatewayTemplate.metered);
1107+
expect(response.result.cross_connect_router).toBe(gatewayTemplate.cross_connect_router);
1108+
expect(response.result.location_name).toBe(gatewayTemplate.location_name);
1109+
expect(response.result.location_display_name).toBe(config.LOCATION_DISPLAY_NAME);
1110+
expect(response.result.created_at).toBeDefined();
1111+
expect(response.result.link_status).toBe('down');
1112+
expect(response.result.operational_status).toBe('awaiting_loa');
1113+
expect(response.result.resource_group).toBeDefined();
1114+
expect(response.result.authentication_key.crn).toBe(config.AUTHENTICATION_KEY);
1115+
done();
1116+
});
1117+
} catch (err) {
1118+
done(err);
1119+
}
1120+
});
1121+
1122+
it('should successfully clear/update the authentication key', async done => {
1123+
const params = {
1124+
id: gatewayId,
1125+
authenticationKey: {
1126+
crn: '',
1127+
},
1128+
};
1129+
1130+
try {
1131+
dlService.updateGateway(params).then(response => {
1132+
expect(response.status).toBe(200);
1133+
expect(response.result.id).toBe(gatewayId);
1134+
expect(response.result.name).toBe(gatewayTemplate.name);
1135+
expect(response.result.type).toBe(gatewayTemplate.type);
1136+
expect(response.result.authentication_key).toBeUndefined();
1137+
done();
1138+
});
1139+
} catch (err) {
1140+
done(err);
1141+
}
1142+
});
1143+
1144+
// delete the dedicated gateway
1145+
it('Successfully delete the gateway', done => {
1146+
const params = {
1147+
id: gatewayId,
1148+
};
1149+
1150+
try {
1151+
dlService.deleteGateway(params).then(response => {
1152+
expect(response.status).toBe(204);
1153+
done();
1154+
});
1155+
} catch (err) {
1156+
done(err);
1157+
}
1158+
});
1159+
});
10601160
});

test/unit/direct-link.v1.test.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,20 @@ describe('DirectLinkV1', () => {
194194
window_size: 148809600,
195195
};
196196

197+
// GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey
198+
const gatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKeyModel = {
199+
crn:
200+
'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c',
201+
};
202+
197203
// ResourceGroupIdentity
198204
const resourceGroupIdentityModel = {
199205
id: '56969d6043e9465c883cb9f7363e78e8',
200206
};
201207

202208
// GatewayTemplateGatewayTypeDedicatedTemplate
203209
const gatewayTemplateModel = {
210+
authentication_key: gatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKeyModel,
204211
bgp_asn: 64999,
205212
bgp_base_cidr: 'testString',
206213
bgp_cer_cidr: '169.254.0.10/30',
@@ -427,6 +434,12 @@ describe('DirectLinkV1', () => {
427434
describe('positive tests', () => {
428435
// Request models needed by this operation.
429436

437+
// GatewayPatchTemplateAuthenticationKey
438+
const gatewayPatchTemplateAuthenticationKeyModel = {
439+
crn:
440+
'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c',
441+
};
442+
430443
// GatewayMacsecConfigPatchTemplateFallbackCak
431444
const gatewayMacsecConfigPatchTemplateFallbackCakModel = {
432445
crn:
@@ -450,6 +463,7 @@ describe('DirectLinkV1', () => {
450463
test('should pass the right params to createRequest', () => {
451464
// Construct the params object for operation updateGateway
452465
const id = 'testString';
466+
const authenticationKey = gatewayPatchTemplateAuthenticationKeyModel;
453467
const global = true;
454468
const loaRejectReason = 'The port mentioned was incorrect';
455469
const macsecConfig = gatewayMacsecConfigPatchTemplateModel;
@@ -459,6 +473,7 @@ describe('DirectLinkV1', () => {
459473
const speedMbps = 1000;
460474
const params = {
461475
id: id,
476+
authenticationKey: authenticationKey,
462477
global: global,
463478
loaRejectReason: loaRejectReason,
464479
macsecConfig: macsecConfig,
@@ -482,6 +497,7 @@ describe('DirectLinkV1', () => {
482497
const expectedAccept = 'application/json';
483498
const expectedContentType = 'application/json';
484499
checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType);
500+
expect(options.body['authentication_key']).toEqual(authenticationKey);
485501
expect(options.body['global']).toEqual(global);
486502
expect(options.body['loa_reject_reason']).toEqual(loaRejectReason);
487503
expect(options.body['macsec_config']).toEqual(macsecConfig);
@@ -542,7 +558,7 @@ describe('DirectLinkV1', () => {
542558
// GatewayActionTemplateAuthenticationKey
543559
const gatewayActionTemplateAuthenticationKeyModel = {
544560
crn:
545-
'crn:v1:staging:public:kms:us-south:a/3b1bd7fa2bc3406ea70ba4ade8aa3f1b:6f2b3d69-9e70-46e6-bcaa-f96ecc232cbc:key:4f9d186a-5cc1-4305-94fc-af183ddf65bc',
561+
'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c',
546562
};
547563

548564
// ResourceGroupIdentity

0 commit comments

Comments
 (0)