diff --git a/src/steps/storage/__snapshots__/converters.test.ts.snap b/src/steps/storage/__snapshots__/converters.test.ts.snap index d224138b..456611d1 100644 --- a/src/steps/storage/__snapshots__/converters.test.ts.snap +++ b/src/steps/storage/__snapshots__/converters.test.ts.snap @@ -287,3 +287,54 @@ Object { "webLink": "https://console.cloud.google.com/storage/browser/customer-managed-encryption-key-bucket-1234;tab=objects?forceOnBucketsSortingFiltering=false&project=j1-gc-integration-dev-v2", } `; + +exports[`#createCloudStorageBucketEntity should set "public" to "false" if "isPublic" is "undefined" 1`] = ` +Object { + "_class": Array [ + "DataStore", + ], + "_key": "bucket:customer-managed-encryption-key-bucket-1234", + "_rawData": Array [ + Object { + "name": "default", + "rawData": Object { + "encryption": Object { + "defaultKmsKeyName": "projects/j1-gc-integration-dev-v2/locations/us/keyRings/j1-gc-integration-dev-v2-bucket-ring/cryptoKeys/j1-gc-integration-dev-v2-bucket-key", + }, + "etag": "CAE=", + "iamConfiguration": undefined, + "id": "customer-managed-encryption-key-bucket-1234", + "kind": "storage#bucket", + "location": "US", + "locationType": "multi-region", + "metageneration": "1", + "name": "customer-managed-encryption-key-bucket-1234", + "projectNumber": "1234", + "selfLink": "https://www.googleapis.com/storage/v1/b/customer-managed-encryption-key-bucket-1234", + "storageClass": "STANDARD", + "timeCreated": "2020-07-28T19:06:14.033Z", + "updated": "2020-07-28T19:06:14.033Z", + }, + }, + ], + "_type": "google_storage_bucket", + "classification": null, + "createdOn": 1595963174033, + "displayName": "customer-managed-encryption-key-bucket-1234", + "encrypted": true, + "encryptionKeyRef": "projects/j1-gc-integration-dev-v2/locations/us/keyRings/j1-gc-integration-dev-v2-bucket-ring/cryptoKeys/j1-gc-integration-dev-v2-bucket-key", + "etag": "CAE=", + "id": "customer-managed-encryption-key-bucket-1234", + "kmsKeyName": "projects/j1-gc-integration-dev-v2/locations/us/keyRings/j1-gc-integration-dev-v2-bucket-ring/cryptoKeys/j1-gc-integration-dev-v2-bucket-key", + "location": "US", + "name": "customer-managed-encryption-key-bucket-1234", + "public": false, + "retentionDate": undefined, + "retentionPeriod": undefined, + "retentionPolicyEnabled": undefined, + "storageClass": "STANDARD", + "uniformBucketLevelAccess": false, + "updatedOn": 1595963174033, + "webLink": "https://console.cloud.google.com/storage/browser/customer-managed-encryption-key-bucket-1234;tab=objects?forceOnBucketsSortingFiltering=false&project=j1-gc-integration-dev-v2", +} +`; diff --git a/src/steps/storage/converters.test.ts b/src/steps/storage/converters.test.ts index e555998a..6b43ccd4 100644 --- a/src/steps/storage/converters.test.ts +++ b/src/steps/storage/converters.test.ts @@ -69,4 +69,16 @@ describe('#createCloudStorageBucketEntity', () => { }), ).toMatchSnapshot(); }); + + test('should set "public" to "false" if "isPublic" is "undefined"', () => { + expect( + createCloudStorageBucketEntity({ + data: getMockStorageBucket({ + iamConfiguration: undefined, + }), + projectId: DEFAULT_INTEGRATION_CONFIG_PROJECT_ID, + isPublic: undefined, + }), + ).toMatchSnapshot(); + }); }); diff --git a/src/steps/storage/converters.ts b/src/steps/storage/converters.ts index 50e3e461..42eb7c71 100644 --- a/src/steps/storage/converters.ts +++ b/src/steps/storage/converters.ts @@ -51,7 +51,7 @@ export function createCloudStorageBucketEntity({ retentionPolicyEnabled: data.retentionPolicy?.isLocked, retentionPeriod: data.retentionPolicy?.retentionPeriod, retentionDate: data.retentionPolicy?.effectiveTime, - public: isPublic, + public: isPublic || false, // Rely on the value of the classification tag classification: null, etag: data.etag,