Skip to content

Commit 965b395

Browse files
Merge pull request #38 from IBM/md5
feat(DirectLink): add the authentication_key for BGP MD5 authentication in directlink service
2 parents a48ce10 + e8c71b0 commit 965b395

File tree

4 files changed

+179
-2
lines changed

4 files changed

+179
-2
lines changed

direct-link/v1.ts

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ class DirectLinkV1 extends BaseService {
368368
* @param {Object} params - The parameters to send to the service.
369369
* @param {string} params.id - Direct Link Connect gateway identifier.
370370
* @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+
*
375+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters
376+
* in length.
377+
*
378+
* To clear the optional `authentication_key` field patch its crn to `""`.
371379
* @param {boolean} [params.global] - Required for create_gateway_approve requests to select the gateway's routing
372380
* option. Gateways with global routing (`true`) can connect to networks outside of their associated region.
373381
* @param {boolean} [params.metered] - Required for create_gateway_approve requests to select the gateway's metered
@@ -394,6 +402,7 @@ class DirectLinkV1 extends BaseService {
394402

395403
const body = {
396404
'action': _params.action,
405+
'authentication_key': _params.authenticationKey,
397406
'global': _params.global,
398407
'metered': _params.metered,
399408
'resource_group': _params.resourceGroup,
@@ -1279,6 +1288,16 @@ namespace DirectLinkV1 {
12791288
id: string;
12801289
/** Action request. */
12811290
action: CreateGatewayActionConstants.Action | string;
1291+
/** BGP MD5 authentication key.
1292+
*
1293+
* BGP MD5 keys must be type=standard.
1294+
*
1295+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
1296+
* characters in length.
1297+
*
1298+
* To clear the optional `authentication_key` field patch its crn to `""`.
1299+
*/
1300+
authenticationKey?: GatewayActionTemplateAuthenticationKey;
12821301
/** Required for create_gateway_approve requests to select the gateway's routing option. Gateways with global
12831302
* routing (`true`) can connect to networks outside of their associated region.
12841303
*/
@@ -1517,6 +1536,16 @@ namespace DirectLinkV1 {
15171536

15181537
/** gateway. */
15191538
export interface Gateway {
1539+
/** BGP MD5 authentication key.
1540+
*
1541+
* BGP MD5 keys must be type=standard.
1542+
*
1543+
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII
1544+
* characters in length.
1545+
*
1546+
* To clear the optional `authentication_key` field patch its crn to `""`.
1547+
*/
1548+
authentication_key?: GatewayAuthenticationKey;
15201549
/** Customer BGP ASN. */
15211550
bgp_asn: number;
15221551
/** (DEPRECATED) BGP base CIDR is deprecated and no longer recognized by the Direct Link APIs.
@@ -1586,14 +1615,26 @@ namespace DirectLinkV1 {
15861615
resource_group?: ResourceGroupReference;
15871616
/** Gateway speed in megabits per second. */
15881617
speed_mbps: number;
1589-
/** Gateway type. The list of enumerated values for this property may expand in the future. Code and processes
1618+
/** Offering type. The list of enumerated values for this property may expand in the future. Code and processes
15901619
* using this field must tolerate unexpected values.
15911620
*/
15921621
type: string;
15931622
/** VLAN allocated for this gateway. Only set for type=connect gateways. */
15941623
vlan?: number;
15951624
}
15961625

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+
export interface GatewayActionTemplateAuthenticationKey {
1628+
/** connectivity association key crn. */
1629+
crn: string;
1630+
}
1631+
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 `""`. */
1633+
export interface GatewayAuthenticationKey {
1634+
/** connectivity association key crn. */
1635+
crn: string;
1636+
}
1637+
15971638
/** GatewayChangeRequest. */
15981639
export interface GatewayChangeRequest {
15991640
}
@@ -1818,7 +1859,7 @@ namespace DirectLinkV1 {
18181859
resource_group?: ResourceGroupIdentity;
18191860
/** Gateway speed in megabits per second. */
18201861
speed_mbps: number;
1821-
/** Gateway type. */
1862+
/** Offering type. */
18221863
type: string;
18231864
}
18241865

directlink.env.enc

176 Bytes
Binary file not shown.

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

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,131 @@ describe('DirectLinkProviderV2', () => {
600600
}
601601
});
602602
});
603+
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', () => {
606+
jest.setTimeout(timeout);
607+
608+
const gwName = 'NODE-INT-SDK-PROVIDER-' + timestamp;
609+
const speedMbps = 1000;
610+
611+
let portId = '';
612+
let gatewayId = '';
613+
614+
const params = {
615+
name: gwName,
616+
speedMbps,
617+
bgpAsn: 64999,
618+
metered: false,
619+
customerAccountId: config.CUSTOMER_ACCT_ID,
620+
};
621+
622+
it('should successfully get the provider port', async done => {
623+
try {
624+
const response = await dlProviderService.listProviderPorts({});
625+
expect(response).toBeDefined();
626+
expect(response.status).toEqual(200);
627+
628+
const { result } = response || {};
629+
expect(result.ports.length).toBeGreaterThan(0);
630+
portId = result.ports[0].id;
631+
done();
632+
} catch (err) {
633+
done(err);
634+
}
635+
});
636+
637+
it('should create a provider gateway', async done => {
638+
try {
639+
const response = await dlProviderService.createProviderGateway({
640+
...params,
641+
port: { id: portId },
642+
});
643+
expect(response).toBeDefined();
644+
expect(response.status).toEqual(201);
645+
gatewayId = response.result.id;
646+
done();
647+
} catch (err) {
648+
done(err);
649+
}
650+
});
651+
652+
it('should successfully approve the provider created gateway', async done => {
653+
try {
654+
const response = await dlService.createGatewayAction({
655+
id: gatewayId,
656+
action: 'create_gateway_approve',
657+
global: false,
658+
metered: false,
659+
authenticationKey: {
660+
crn: config.AUTHENTICATION_KEY,
661+
},
662+
});
663+
664+
expect(response).toBeDefined();
665+
expect(response.status).toEqual(200);
666+
const { result } = response || {};
667+
expect(result.id).toBe(gatewayId);
668+
expect(result.name).toEqual(gwName);
669+
expect(result.authentication_key.crn).toEqual(config.AUTHENTICATION_KEY);
670+
expect(result.type).toEqual('connect');
671+
expect(result.speed_mbps).toEqual(speedMbps);
672+
expect(result.bgp_asn).toEqual(params.bgpAsn);
673+
expect(result.operational_status).toEqual('create_pending');
674+
expect(result.provider_api_managed).toBeTruthy();
675+
expect(result.bgp_cer_cidr).not.toBe('');
676+
expect(result.bgp_ibm_cidr).not.toBe('');
677+
expect(result.bgp_ibm_asn).not.toBe('');
678+
expect(result.bgp_status).not.toBe('');
679+
expect(result.created_at).not.toBe('');
680+
expect(result.port.id).toBe(portId);
681+
expect(result.global).toBeFalsy();
682+
expect(result.metered).toBeFalsy();
683+
done();
684+
} catch (err) {
685+
done(err);
686+
}
687+
});
688+
689+
it('should successfully wait for the gateway to move to provisioned state', async done => {
690+
try {
691+
const result = await poll(
692+
() => dlProviderService.getProviderGateway({ id: gatewayId }),
693+
result => result.operational_status === 'provisioned',
694+
100
695+
);
696+
697+
expect(result).toBeDefined();
698+
expect(result.operational_status).toEqual('provisioned');
699+
done();
700+
} catch (err) {
701+
done(err);
702+
}
703+
});
704+
705+
it('should successfully request delete gateway using provider account', async done => {
706+
try {
707+
const response = await dlProviderService.deleteProviderGateway({ id: gatewayId });
708+
expect(response).toBeDefined();
709+
expect(response.status).toEqual(202);
710+
done();
711+
} catch (err) {
712+
done(err);
713+
}
714+
});
715+
716+
it('should successfully approve delete gayeway using client account', async done => {
717+
try {
718+
const response = await dlService.createGatewayAction({
719+
id: gatewayId,
720+
action: 'delete_gateway_approve',
721+
});
722+
expect(response).toBeDefined();
723+
expect(response.status).toEqual(204);
724+
done();
725+
} catch (err) {
726+
done(err);
727+
}
728+
});
729+
});
603730
});

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ describe('DirectLinkV1', () => {
539539
describe('positive tests', () => {
540540
// Request models needed by this operation.
541541

542+
// GatewayActionTemplateAuthenticationKey
543+
const gatewayActionTemplateAuthenticationKeyModel = {
544+
crn:
545+
'crn:v1:staging:public:kms:us-south:a/3b1bd7fa2bc3406ea70ba4ade8aa3f1b:6f2b3d69-9e70-46e6-bcaa-f96ecc232cbc:key:4f9d186a-5cc1-4305-94fc-af183ddf65bc',
546+
};
547+
542548
// ResourceGroupIdentity
543549
const resourceGroupIdentityModel = {
544550
id: '56969d6043e9465c883cb9f7363e78e8',
@@ -548,13 +554,15 @@ describe('DirectLinkV1', () => {
548554
// Construct the params object for operation createGatewayAction
549555
const id = 'testString';
550556
const action = 'create_gateway_approve';
557+
const authenticationKey = gatewayActionTemplateAuthenticationKeyModel;
551558
const global = true;
552559
const metered = false;
553560
const resourceGroup = resourceGroupIdentityModel;
554561
const updates = [{ foo: 'bar' }];
555562
const params = {
556563
id: id,
557564
action: action,
565+
authenticationKey: authenticationKey,
558566
global: global,
559567
metered: metered,
560568
resourceGroup: resourceGroup,
@@ -576,6 +584,7 @@ describe('DirectLinkV1', () => {
576584
const expectedContentType = 'application/json';
577585
checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType);
578586
expect(options.body['action']).toEqual(action);
587+
expect(options.body['authentication_key']).toEqual(authenticationKey);
579588
expect(options.body['global']).toEqual(global);
580589
expect(options.body['metered']).toEqual(metered);
581590
expect(options.body['resource_group']).toEqual(resourceGroup);

0 commit comments

Comments
 (0)