diff --git a/package.json b/package.json index cf99313f35..83d958f8fb 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "homepage": "https://github.com/scality/S3#readme", "dependencies": { "@hapi/joi": "^17.1.0", - "arsenal": "git+https://github.com/scality/arsenal#7.10.47", + "arsenal": "git+https://github.com/scality/arsenal#73c6f41fa3bf52947e2f9a33ac2cb40233309ab5", "async": "~2.5.0", "aws-sdk": "2.905.0", "azure-storage": "^2.1.0", diff --git a/tests/functional/aws-node-sdk/test/bucket/putBucketPolicy.js b/tests/functional/aws-node-sdk/test/bucket/putBucketPolicy.js index 4cc009a6f3..191409f8ab 100644 --- a/tests/functional/aws-node-sdk/test/bucket/putBucketPolicy.js +++ b/tests/functional/aws-node-sdk/test/bucket/putBucketPolicy.js @@ -30,6 +30,23 @@ function getPolicyParams(paramToChange) { }; } +function getPolicyParamsWithId(paramToChange, policyId) { + const newParam = {}; + const bucketPolicy = { + Version: '2012-10-17', + Id: policyId, + Statement: [basicStatement], + }; + if (paramToChange) { + newParam[paramToChange.key] = paramToChange.value; + bucketPolicy.Statement[0] = Object.assign({}, basicStatement, newParam); + } + return { + Bucket: bucket, + Policy: JSON.stringify(bucketPolicy), + }; +} + // Check for the expected error response code and status code. function assertError(err, expectedErr, cb) { if (expectedErr === null) { @@ -102,5 +119,25 @@ describe('aws-sdk test put bucket policy', () => { s3.putBucketPolicy(params, err => assertError(err, 'MalformedPolicy', done)); }); + + it('should return MalformedPolicy because Id is not a string', + done => { + const params = getPolicyParamsWithId(null, 59); + s3.putBucketPolicy(params, err => + assertError(err, 'MalformedPolicy', done)); + }); + + it('should put a bucket policy on bucket since Id is a string', + done => { + const params = getPolicyParamsWithId(null, 'cd3ad3d9-2776-4ef1-a904-4c229d1642e'); + s3.putBucketPolicy(params, err => + assertError(err, null, done)); + }); + + it('should allow bucket policy with pincipal arn less than 2048', done => { + const params = getPolicyParams({ key: 'Principal', value: { AWS: 'arn:aws:iam::767707094035:user/user2/TENANT_USER/null/5417be27-8709-48bd-adfb-865ebc58b9f0/1a464be02ea631bdaf2a9ee884434233374a457460e925bf10d9e4665f8fa796/c1d83067-a3f3-41a4-bd45-d6bf47270bd0' } }); // eslint-disable-line max-len + s3.putBucketPolicy(params, err => + assertError(err, null, done)); + }); }); }); diff --git a/yarn.lock b/yarn.lock index cb135a5930..043a0254c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -488,9 +488,9 @@ arraybuffer.slice@~0.0.7: optionalDependencies: ioctl "^2.0.2" -"arsenal@git+https://github.com/scality/arsenal#7.10.47": +"arsenal@git+https://github.com/scality/arsenal#73c6f41fa3bf52947e2f9a33ac2cb40233309ab5": version "7.10.47" - resolved "git+https://github.com/scality/arsenal#3f24336b83581d121f52146b8003e0a68d9ce876" + resolved "git+https://github.com/scality/arsenal#73c6f41fa3bf52947e2f9a33ac2cb40233309ab5" dependencies: "@types/async" "^3.2.12" "@types/utf8" "^3.0.1" @@ -506,7 +506,7 @@ arraybuffer.slice@~0.0.7: bson "4.0.0" debug "~2.6.9" diskusage "^1.1.1" - fcntl "github:scality/node-fcntl#0.2.0" + fcntl "github:scality/node-fcntl#0.2.2" hdclient scality/hdclient#1.1.0 https-proxy-agent "^2.2.0" ioredis "^4.28.5" @@ -1918,6 +1918,14 @@ fast-levenshtein@~2.0.6: nan "^2.3.2" node-gyp "^8.0.0" +"fcntl@github:scality/node-fcntl#0.2.2": + version "0.2.1" + resolved "https://codeload.github.com/scality/node-fcntl/tar.gz/b1335ca204c6265cedc50c26020c4d63aabe920e" + dependencies: + bindings "^1.1.1" + nan "^2.3.2" + node-gyp "^8.0.0" + fecha@^4.2.0: version "4.2.3" resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.3.tgz#4d9ccdbc61e8629b259fdca67e65891448d569fd"