Skip to content

Commit 29ebf3f

Browse files
author
Will Toozs
committed
fixup: fn test 405 not allowed error
1 parent 3aadbde commit 29ebf3f

File tree

1 file changed

+47
-0
lines changed
  • tests/functional/aws-node-sdk/test/object

1 file changed

+47
-0
lines changed

tests/functional/aws-node-sdk/test/object/post.js

+47
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,53 @@ describe('POST object', () => {
928928
});
929929
});
930930

931+
it('should return 405 Method Not Allowed if objectKey is present with a non-matching query parameter', done => {
932+
const { url } = testContext;
933+
const objectKey = 'someObjectKey';
934+
const queryParam = '?nonMatchingParam=true';
935+
const invalidUrl = `${url}/${objectKey}${queryParam}`;
936+
const fields = calculateFields(ak, sk);
937+
938+
const formData = new FormData();
939+
940+
fields.forEach(field => {
941+
formData.append(field.name, field.value);
942+
});
943+
944+
formData.append('file', fileBuffer, filename);
945+
946+
return formData.getLength((err, length) => {
947+
if (err) {
948+
return done(err);
949+
}
950+
951+
return axios.post(invalidUrl, formData, {
952+
headers: {
953+
...formData.getHeaders(),
954+
'Content-Length': length,
955+
},
956+
})
957+
.then(() => {
958+
done(new Error('Request should not succeed with a non-matching query parameter'));
959+
})
960+
.catch(err => {
961+
assert.ok(err.response, 'Error should be returned by axios');
962+
963+
xml2js.parseString(err.response.data, (err, result) => {
964+
if (err) {
965+
return done(err);
966+
}
967+
968+
const error = result.Error;
969+
assert.equal(error.Code[0], 'MethodNotAllowed');
970+
assert.equal(error.Message[0], 'The specified method is not allowed against this resource.');
971+
return done();
972+
});
973+
});
974+
});
975+
});
976+
977+
931978
it('should successfully upload an object with bucket versioning enabled and verify version ID', done => {
932979
const { url } = testContext;
933980

0 commit comments

Comments
 (0)