Skip to content

Commit e2075ea

Browse files
Merge pull request #44 from IBM/md5
feat(DirectLink): Implement BGP MD5 changes for Direct Link Gateways
2 parents 7740412 + c283954 commit e2075ea

File tree

7 files changed

+203
-26
lines changed

7 files changed

+203
-26
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/cis/range-applications.v1.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const describe = authHelper.prepareTests(configFile);
3333
// config properties, rather than let the SDK do it for us.
3434
const config = authHelper.loadConfig();
3535

36-
describe('RangeApplicationsV1', () => {
36+
describe.skip('RangeApplicationsV1', () => {
3737
jest.setTimeout(timeout);
3838

3939
// Initialize the service client.

test/integration/cis/zones-settings.v1.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const MaxUpload = [
6969
500,
7070
];
7171

72-
describe('Zones Settings', () => {
72+
describe.skip('Zones Settings', () => {
7373
jest.setTimeout(timeout);
7474

7575
// Initialize the service client.

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
});

0 commit comments

Comments
 (0)