diff --git a/lib/client.js b/lib/client.js index ba6c1350c..9e32a66d2 100644 --- a/lib/client.js +++ b/lib/client.js @@ -222,7 +222,6 @@ async function request(params) { } else if (reqErr) { err = await this.requestError(reqErr); } - console.log('client-err', err); if (err) { if (params.customResponse && result && result.res) { // consume the response stream diff --git a/lib/common/bucket/getBucketPolicy.js b/lib/common/bucket/getBucketPolicy.js index cb2e7ab04..9135f4a0a 100644 --- a/lib/common/bucket/getBucketPolicy.js +++ b/lib/common/bucket/getBucketPolicy.js @@ -17,7 +17,7 @@ proto.getBucketPolicy = async function getBucketPolicy(bucketName, options = {}) let policy = null; if (result.res.status === 200) { - policy = JSON.parse(result.res.data.toString()); + policy = JSON.parse(result.data.toString()); } return { diff --git a/lib/common/bucket/putBucketPolicy.js b/lib/common/bucket/putBucketPolicy.js index e532a7200..7ec75f832 100644 --- a/lib/common/bucket/putBucketPolicy.js +++ b/lib/common/bucket/putBucketPolicy.js @@ -17,11 +17,10 @@ proto.putBucketPolicy = async function putBucketPolicy(bucketName, policy, optio throw new Error('policy is not Object'); } const params = this._bucketRequestParams('PUT', bucketName, 'policy', options); + params.mime = 'json'; params.content = policy2Str(policy); params.successStatuses = [200]; - // console.log('put-param', params); const result = await this.request(params); - // console.log('put-result-', result); return { status: result.status, res: result.res diff --git a/test/node/bucket.test.js b/test/node/bucket.test.js index 21decd481..7c83f1f6b 100644 --- a/test/node/bucket.test.js +++ b/test/node/bucket.test.js @@ -1274,37 +1274,34 @@ describe('test/bucket.test.js', () => { it('should put, get, delete, when policy is Object', async () => { try { const policy = { - a: 'b' - // Version: '1' - // Statement: [ - // { - // Action: ['oss:PutObject', 'oss:GetObject'], - // Effect: 'Deny', - // Principal: ['1234567890'], - // Resource: ['acs:oss:*:1234567890:*/*'] - // } - // ] + Version: '1', + Statement: [ + { + Action: ['oss:PutObject', 'oss:GetObject'], + Effect: 'Deny', + Principal: ['1234567890'], + Resource: ['acs:oss:*:1234567890:*/*'] + } + ] }; const result = await store.putBucketPolicy(bucket, policy); - console.log('rr-', result); - // assert.strictEqual(result.status, 200); - // const result1 = await store.getBucketPolicy(bucket); - // assert.deepStrictEqual(policy, result1.policy); - // const result2 = await store.deleteBucketPolicy(bucket); - // assert.strictEqual(result2.status, 204); - // const result3 = await store.getBucketPolicy(bucket); - // assert.deepStrictEqual(null, result3.policy); + assert.strictEqual(result.status, 200); + const result1 = await store.getBucketPolicy(bucket); + assert.deepStrictEqual(policy, result1.policy); + const result2 = await store.deleteBucketPolicy(bucket); + assert.strictEqual(result2.status, 204); + const result3 = await store.getBucketPolicy(bucket); + assert.deepStrictEqual(null, result3.policy); } catch (err) { - // console.log('test-err', err); assert.fail(err.message); } }); + it('should throw error, when policy is not Object', async () => { try { await store.putBucketPolicy(bucket, 'policy'); assert(false); } catch (err) { - console.log('test-errr2:', err); assert(true); } });