Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #617 from JupiterOne/INT-8173/expose-cloud-logging
Browse files Browse the repository at this point in the history
INT-8173: change cloud logging status type
  • Loading branch information
Michell Ayala authored Jul 13, 2023
2 parents c903d79 + 12d60ea commit 5d56d6c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/steps/dns/__snapshots__/converters.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Object {
},
],
"_type": "google_dns_managed_zone",
"cloudLoggingStatus": false,
"cloudLoggingStatus": "disabled",
"createdOn": 1611334107272,
"description": "",
"displayName": "example-zone",
Expand Down Expand Up @@ -77,7 +77,7 @@ Object {
},
],
"_type": "google_dns_managed_zone",
"cloudLoggingStatus": true,
"cloudLoggingStatus": "enabled",
"createdOn": 1611334107272,
"description": "",
"displayName": "example-zone",
Expand Down Expand Up @@ -135,7 +135,7 @@ Object {
},
],
"_type": "google_dns_managed_zone",
"cloudLoggingStatus": false,
"cloudLoggingStatus": "disabled",
"createdOn": 1611334107272,
"description": "",
"displayName": "example-zone",
Expand Down Expand Up @@ -193,7 +193,7 @@ Object {
},
],
"_type": "google_dns_managed_zone",
"cloudLoggingStatus": false,
"cloudLoggingStatus": "disabled",
"createdOn": 1611334107272,
"description": "",
"displayName": "example-zone",
Expand Down
2 changes: 1 addition & 1 deletion src/steps/dns/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Object {
},
],
"_type": "google_dns_managed_zone",
"cloudLoggingStatus": false,
"cloudLoggingStatus": "disabled",
"createdOn": 1613606661953,
"description": "Example DNS zone",
"displayName": "example-public-zone",
Expand Down
22 changes: 11 additions & 11 deletions src/steps/dns/cloudLoggingConfigParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ import { cloudLoggingConfigParser } from './cloudLoggingConfigParser';
describe('CloudLoggingConfigParser', () => {
describe('parseEnableLoggingStatus()', () => {
describe('given undefined as argument', () => {
it('should return false', () => {
it('should return "disabled"', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus();
expect(result).toEqual(false);
expect(result).toEqual('disabled');
});
});

describe('given null as argument', () => {
it('should return false', () => {
it('should return "disabled"', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus();
expect(result).toEqual(false);
expect(result).toEqual('disabled');
});
});

describe('given enableLogging equal to undefined', () => {
it('should return false', () => {
it('should return "disabled"', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus({});
expect(result).toEqual(false);
expect(result).toEqual('disabled');
});
});

describe('given enableLogging equal to null', () => {
it('should return false', () => {
it('should return "disabled"', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus({
enableLogging: null,
});
expect(result).toEqual(false);
expect(result).toEqual('disabled');
});
});

describe('given enableLogging equal to false', () => {
it('should return false', () => {
it('should return "disabled"', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus({
enableLogging: false,
});
expect(result).toEqual(false);
expect(result).toEqual('disabled');
});
});

Expand All @@ -46,7 +46,7 @@ describe('CloudLoggingConfigParser', () => {
const result = cloudLoggingConfigParser.parseEnableLoggingStatus({
enableLogging: true,
});
expect(result).toEqual(true);
expect(result).toEqual('enabled');
});
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/steps/dns/cloudLoggingConfigParser.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { dns_v1 } from 'googleapis';

type ManagedZoneCloudLoggingConfigStatus = 'disabled' | 'enabled';

const parseEnableLoggingStatus = (
cloudLoggingConfig?: dns_v1.Schema$ManagedZoneCloudLoggingConfig,
): boolean => {
): ManagedZoneCloudLoggingConfigStatus => {
if (cloudLoggingConfig === undefined || cloudLoggingConfig === null) {
return false;
return 'disabled';
}

if (
cloudLoggingConfig.enableLogging === undefined ||
cloudLoggingConfig.enableLogging === null
) {
return false;
return 'disabled';
}

return cloudLoggingConfig.enableLogging;
return cloudLoggingConfig.enableLogging ? 'enabled' : 'disabled';
};

export const cloudLoggingConfigParser = {
Expand Down
2 changes: 1 addition & 1 deletion src/steps/dns/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('#fetchDNSManagedZones', () => {
keySigningAlgorithm: { type: 'string' },
zoneSigningAlgorithm: { type: 'string' },
createdOn: { type: 'number' },
cloudLoggingStatus: { type: 'boolean' },
cloudLoggingStatus: { type: 'string' },
},
},
});
Expand Down

0 comments on commit 5d56d6c

Please sign in to comment.