Create Bucket
This commit is contained in:
parent
3443e2cd48
commit
088cf26b46
|
@ -37,6 +37,13 @@ module AwsMock {
|
||||||
Contents: {},
|
Contents: {},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
this.createBucket = jest.fn(
|
||||||
|
response({
|
||||||
|
Contents: {},
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
aws.DynamoDB = { DocumentClient }
|
aws.DynamoDB = { DocumentClient }
|
||||||
|
|
|
@ -131,22 +131,10 @@ module S3Module {
|
||||||
"public-read",
|
"public-read",
|
||||||
"public-read-write",
|
"public-read-write",
|
||||||
"authenticated-read",
|
"authenticated-read",
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
objectOwnership: {
|
|
||||||
required: false,
|
|
||||||
displayName: "Object ownership",
|
|
||||||
type: DatasourceFieldType.LIST,
|
|
||||||
data: {
|
|
||||||
create: [
|
|
||||||
"BucketOwnerPreferred",
|
|
||||||
"ObjectWriter",
|
|
||||||
"BucketOwnerEnforced",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class S3Integration implements IntegrationBase {
|
class S3Integration implements IntegrationBase {
|
||||||
|
@ -165,33 +153,33 @@ module S3Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(query: {
|
async create(query: {
|
||||||
bucket: string,
|
bucket: string
|
||||||
location: string,
|
location: string
|
||||||
grantFullControl: string,
|
grantFullControl: string
|
||||||
grantRead: string,
|
grantRead: string
|
||||||
grantReadAcp: string,
|
grantReadAcp: string
|
||||||
grantWrite: string,
|
grantWrite: string
|
||||||
grantWriteAcp: string,
|
grantWriteAcp: string
|
||||||
extra: {
|
extra: {
|
||||||
acl: string,
|
acl: string
|
||||||
objectOwnership: string,
|
}
|
||||||
}}) {
|
}) {
|
||||||
const response = await this.client.createBucket({
|
let params: any = {
|
||||||
Bucket: query.bucket,
|
Bucket: query.bucket,
|
||||||
// ACL: query.extra?.acl,
|
ACL: query.extra?.acl,
|
||||||
CreateBucketConfiguration: {
|
|
||||||
LocationConstraint: query.location
|
|
||||||
},
|
|
||||||
GrantFullControl: query.grantFullControl,
|
GrantFullControl: query.grantFullControl,
|
||||||
GrantRead: query.grantRead,
|
GrantRead: query.grantRead,
|
||||||
GrantReadACP: query.grantReadAcp,
|
GrantReadACP: query.grantReadAcp,
|
||||||
GrantWrite: query.grantWrite,
|
GrantWrite: query.grantWrite,
|
||||||
GrantWriteACP: query.grantWriteAcp,
|
GrantWriteACP: query.grantWriteAcp,
|
||||||
}, (err: any) => {
|
}
|
||||||
console.log("ERR ", err)
|
if (query.location) {
|
||||||
})
|
params["CreateBucketConfiguration"] = {
|
||||||
.promise()
|
LocationConstraint: query.location,
|
||||||
return response.Contents
|
}
|
||||||
|
}
|
||||||
|
const response = await this.client.createBucket(params).promise()
|
||||||
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
async read(query: {
|
async read(query: {
|
||||||
|
|
|
@ -41,10 +41,10 @@ describe("S3 Integration", () => {
|
||||||
grantReadAcp: "her",
|
grantReadAcp: "her",
|
||||||
grantWrite: "she",
|
grantWrite: "she",
|
||||||
grantWriteAcp: "he",
|
grantWriteAcp: "he",
|
||||||
objectLockEnabledForBucket: true
|
objectLockEnabledForBucket: true,
|
||||||
}, {
|
extra: {
|
||||||
acl: "private",
|
acl: "private"
|
||||||
objectOwnership: "BucketOwnerPreferred"
|
}
|
||||||
})
|
})
|
||||||
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
||||||
Bucket: "test",
|
Bucket: "test",
|
||||||
|
@ -53,12 +53,25 @@ describe("S3 Integration", () => {
|
||||||
},
|
},
|
||||||
GrantFullControl: "me",
|
GrantFullControl: "me",
|
||||||
GrantRead: "him",
|
GrantRead: "him",
|
||||||
GrantReadAcp: "her",
|
GrantReadACP: "her",
|
||||||
GrantWrite: "she",
|
GrantWrite: "she",
|
||||||
GrantWriteAcp: "he",
|
GrantWriteACP: "he",
|
||||||
ObjectLockEnabledForBucket: true,
|
|
||||||
ACL: "private",
|
ACL: "private",
|
||||||
ObjectOwnership: "BucketOwnerPreferred"
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("does not add undefined location constraint when calling the create method", async () => {
|
||||||
|
await config.integration.create({
|
||||||
|
bucket: "test"
|
||||||
|
})
|
||||||
|
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
||||||
|
Bucket: "test",
|
||||||
|
GrantFullControl: undefined,
|
||||||
|
GrantRead: undefined,
|
||||||
|
GrantReadACP: undefined,
|
||||||
|
GrantWrite: undefined,
|
||||||
|
GrantWriteACP: undefined,
|
||||||
|
ACL: undefined,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
Reference in New Issue