Skip to content

Commit

Permalink
test: upgrade urllib fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
csg01123119 committed Jul 19, 2023
1 parent 91b1d69 commit bcda03e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
1 change: 0 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/common/bucket/getBucketPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions lib/common/bucket/putBucketPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 17 additions & 20 deletions test/node/bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down

0 comments on commit bcda03e

Please sign in to comment.