(bucketLoc, objLoc, requestHost, objectName, cb, errorDescription)
| 24 | const describeSkipIfE2E = process.env.S3_END_TO_END ? describe.skip : describe; |
| 25 | |
| 26 | function put(bucketLoc, objLoc, requestHost, objectName, cb, errorDescription) { |
| 27 | const post = bucketLoc ? '<?xml version="1.0" encoding="UTF-8"?>' + |
| 28 | '<CreateBucketConfiguration ' + |
| 29 | 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' + |
| 30 | `<LocationConstraint>${bucketLoc}</LocationConstraint>` + |
| 31 | '</CreateBucketConfiguration>' : ''; |
| 32 | const bucketPutReq = new DummyRequest({ |
| 33 | bucketName, |
| 34 | namespace, |
| 35 | headers: { host: `${bucketName}.s3.amazonaws.com` }, |
| 36 | url: '/', |
| 37 | post, |
| 38 | }); |
| 39 | if (requestHost) { |
| 40 | bucketPutReq.parsedHost = requestHost; |
| 41 | } |
| 42 | const objPutParams = { |
| 43 | bucketName, |
| 44 | namespace, |
| 45 | objectKey: objectName, |
| 46 | headers: {}, |
| 47 | url: `/${bucketName}/${objectName}`, |
| 48 | calculatedHash: 'vnR+tLdVF79rPPfF+7YvOg==', |
| 49 | }; |
| 50 | if (objLoc) { |
| 51 | objPutParams.headers = { |
| 52 | 'x-amz-meta-scal-location-constraint': `${objLoc}`, |
| 53 | }; |
| 54 | } |
| 55 | const testPutObjReq = new DummyRequest(objPutParams, body); |
| 56 | if (requestHost) { |
| 57 | testPutObjReq.parsedHost = requestHost; |
| 58 | } |
| 59 | bucketPut(authInfo, bucketPutReq, log, () => { |
| 60 | objectPut(authInfo, testPutObjReq, undefined, log, (err, |
| 61 | resHeaders) => { |
| 62 | if (errorDescription) { |
| 63 | assert.strictEqual(err.code, 400); |
| 64 | assert(err.is.InvalidArgument); |
| 65 | assert(err.description.indexOf(errorDescription) > -1); |
| 66 | } else { |
| 67 | assert.strictEqual(err, null, `Error putting object: ${err}`); |
| 68 | assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); |
| 69 | } |
| 70 | cb(); |
| 71 | }); |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | describeSkipIfE2E('objectPutAPI with multiple backends', function testSuite() { |
| 76 | this.timeout(5000); |
no test coverage detected