Skip to content

Commit 3154930

Browse files
Merge pull request #262 from bcgov/child-bucket
allow forward slashes in child bucket sub-path
2 parents 5b74516 + 9f7d1d4 commit 3154930

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

app/src/controllers/invite.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const controller = {
3131
let resource, type;
3232

3333
try {
34-
// Reject if expiresAt is more than 7 days away
35-
const maxExpiresAt = Math.floor(Date.now() / 1000) + 691199;
34+
// Reject if expiresAt is more than 30 days away
35+
const maxExpiresAt = Math.floor(Date.now() / 1000) + 2592000;
3636
if (req.body.expiresAt && req.body.expiresAt > maxExpiresAt) {
3737
const limit = new Date(maxExpiresAt * 1000).toISOString();
3838
const msg = `"expiresAt" must be less than "${limit}"`;

app/src/docs/v1.api-spec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2411,9 +2411,9 @@ components:
24112411
example: Geospatial Maps
24122412
subKey:
24132413
type: string
2414-
description: The desired S3 child directory name. Must not include `/`.
2414+
description: a path relative to the parent bucket to the 'directory' you are mounting
24152415
maxLength: 255
2416-
example: child
2416+
example: canada/bc/maps
24172417
Request-CreateInvite:
24182418
title: Request Create Invite
24192419
type: object
@@ -2437,7 +2437,7 @@ components:
24372437
type: integer
24382438
description: >-
24392439
Optional desired unix epoch time for when this invitation should
2440-
expire. Defaults to 24 hours from now if unspecified.
2440+
expire. Defaults to 24 hours from now if unspecified. Maximum of 30 days from now.
24412441
example: 1710000000
24422442
objectId:
24432443
type: string

app/src/validators/bucket.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const schema = {
2020
createBucketChild: {
2121
body: Joi.object().keys({
2222
bucketName: Joi.string().max(255).required(),
23-
subKey: Joi.string().max(255).trim().strict().pattern(/^[^/]+$/).required()
23+
subKey: Joi.string().max(255).trim().strict().required()
2424
}).required(),
2525
params: Joi.object({
2626
bucketId: type.uuidv4

app/tests/unit/validators/bucket.spec.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('createBucketChild', () => {
157157

158158
it('trims whitespace', () => {
159159
expect(Array.isArray(subKey.rules)).toBeTruthy();
160-
expect(subKey.rules).toHaveLength(3);
160+
expect(subKey.rules).toHaveLength(2);
161161
expect(subKey.rules).toEqual(expect.arrayContaining([
162162
expect.objectContaining({
163163
args: {
@@ -170,7 +170,7 @@ describe('createBucketChild', () => {
170170

171171
it('has a max length of 255', () => {
172172
expect(Array.isArray(subKey.rules)).toBeTruthy();
173-
expect(subKey.rules).toHaveLength(3);
173+
expect(subKey.rules).toHaveLength(2);
174174
expect(subKey.rules).toEqual(expect.arrayContaining([
175175
expect.objectContaining({
176176
args: {
@@ -181,19 +181,6 @@ describe('createBucketChild', () => {
181181
]));
182182
});
183183

184-
it('has a regex', () => {
185-
expect(Array.isArray(subKey.rules)).toBeTruthy();
186-
expect(subKey.rules).toHaveLength(3);
187-
expect(subKey.rules).toEqual(expect.arrayContaining([
188-
expect.objectContaining({
189-
args: {
190-
regex: '/^[^/]+$/'
191-
},
192-
name: 'pattern'
193-
}),
194-
]));
195-
});
196-
197184
it('is strict', () => {
198185
expect(subKey.preferences).toBeTruthy();
199186
expect(subKey.preferences.convert).toBeFalsy();

0 commit comments

Comments
 (0)