Skip to content

Commit 63945ce

Browse files
feat: add support for setting DNS Sec (#439)
1 parent ecbfc3c commit 63945ce

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

packages/google-cloud-dns/src/index.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,39 @@ export interface CreateZoneRequest {
5555
dnsName: string;
5656
description?: string;
5757
name?: string;
58+
dnssecConfig?: ManagedZoneDnsSecConfig;
59+
}
60+
61+
export interface ManagedZoneDnsSecConfig {
62+
/**
63+
* Specifies parameters for generating initial DnsKeys for this ManagedZone. Can only be changed while the state is OFF.
64+
*/
65+
defaultKeySpecs?: DnsKeySpec[];
66+
kind?: string | null;
67+
/**
68+
* Specifies the mechanism for authenticated denial-of-existence responses. Can only be changed while the state is OFF.
69+
*/
70+
nonExistence?: string | null;
71+
/**
72+
* Specifies whether DNSSEC is enabled, and what mode it is in.
73+
*/
74+
state?: 'on' | 'off' | null;
75+
}
76+
77+
export interface DnsKeySpec {
78+
/**
79+
* String mnemonic specifying the DNSSEC algorithm of this key.
80+
*/
81+
algorithm?: string | null;
82+
/**
83+
* Length of the keys in bits.
84+
*/
85+
keyLength?: number | null;
86+
/**
87+
* Specifies whether this is a key signing key (KSK) or a zone signing key (ZSK). Key signing keys have the Secure Entry Point flag set and, when active, will only be used to sign resource record sets of type DNSKEY. Zone signing keys do not have the Secure Entry Point flag set and will be used to sign all other types of resource record sets.
88+
*/
89+
keyType?: string | null;
90+
kind?: string | null;
5891
}
5992

6093
export type CreateZoneResponse = [Zone, Metadata];

packages/google-cloud-dns/system-test/dns.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,26 @@ describe('dns', () => {
115115
};
116116

117117
before(async () => {
118+
// Clean up any leaked resources
118119
const [zones] = await dns.getZones();
119-
await Promise.all(zones.map(zone => zone.delete({force: true})));
120-
await ZONE.create({dnsName: DNS_DOMAIN});
120+
await Promise.all(
121+
zones.map(async zone => {
122+
const hoursOld =
123+
(Date.now() - new Date(zone.metadata.creationTime).getTime()) /
124+
1000 /
125+
60 /
126+
60;
127+
if (hoursOld > 1) {
128+
await zone.delete({force: true});
129+
}
130+
})
131+
);
132+
await ZONE.create({
133+
dnsName: DNS_DOMAIN,
134+
dnssecConfig: {
135+
state: 'on',
136+
},
137+
});
121138
});
122139

123140
after(done => {
@@ -306,7 +323,12 @@ describe('dns', () => {
306323
it('should replace records', async () => {
307324
const name = 'test-zone-' + uuid.v4().substr(0, 18);
308325
// Do this in a new zone so no existing records are affected.
309-
const [zone] = await dns.createZone(name, {dnsName: DNS_DOMAIN});
326+
const [zone] = await dns.createZone(name, {
327+
dnsName: DNS_DOMAIN,
328+
dnssecConfig: {
329+
state: 'on',
330+
},
331+
});
310332
const [originalRecords] = await zone.getRecords('ns');
311333
const originalData = originalRecords[0].data;
312334
const newRecord = zone.record('ns', {
@@ -319,6 +341,7 @@ describe('dns', () => {
319341
const added = change.metadata.additions[0].rrdatas;
320342
assert.deepStrictEqual(deleted, originalData);
321343
assert.deepStrictEqual(added, newRecord.data);
344+
await zone.delete({force: true});
322345
});
323346
});
324347
});

packages/google-cloud-dns/test/change.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import * as promisify from '@google-cloud/promisify';
2121
import * as assert from 'assert';
2222
import {describe, it, before, beforeEach} from 'mocha';
2323
import * as proxyquire from 'proxyquire';
24-
25-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2624
import {Change} from '../src/change';
2725

2826
let promisified = false;
@@ -73,6 +71,7 @@ describe('Change', () => {
7371
it('should inherit from ServiceObject', () => {
7472
assert(change instanceof ServiceObject);
7573

74+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7675
const calledWith = (change as any).calledWith_[0];
7776

7877
assert.strictEqual(calledWith.parent, ZONE);

packages/google-cloud-dns/test/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe('DNS', () => {
123123
it('should inherit from Service', () => {
124124
assert(dns instanceof Service);
125125

126+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126127
const calledWith = (dns as any).calledWith_[0];
127128

128129
const baseUrl = 'https://dns.googleapis.com/dns/v1';

packages/google-cloud-dns/test/zone.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ describe('Zone', () => {
166166
const zone = new Zone(dnsInstance, ZONE_NAME);
167167
assert(zone instanceof ServiceObject);
168168

169+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
169170
const calledWith = (zone as any).calledWith_[0];
170171

171172
assert.strictEqual(calledWith.parent, dnsInstance);

0 commit comments

Comments
 (0)