Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/api/apiUtils/bucket/parseLikeExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function parseLikeExpression(regex) {
}
const pattern = split.slice(1, split.length - 1).join('/');
const regexOpt = split[split.length - 1];
return { $regex: pattern, $options: regexOpt };
return { $regex: new RegExp(pattern), $options: regexOpt };
}

module.exports = parseLikeExpression;
11 changes: 10 additions & 1 deletion lib/api/bucketGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,16 @@ function bucketGet(authInfo, request, log, callback) {
}
if (params.search !== undefined) {
log.info('performaing search listing', { search: params.search });
listParams.mongifiedSearch = parseWhere(validatedAst);
try {
listParams.mongifiedSearch = parseWhere(validatedAst);
} catch (err) {
log.debug(err.message, {
stack: err.stack,
});
return callback(errors.InvalidArgument
.customizeDescription('Invalid sql where clause ' +
'sent as search query'));
}
}
return services.getObjectListing(bucketName, listParams, log,
(err, list) => {
Expand Down
14 changes: 7 additions & 7 deletions tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ then

killandsleep 8000

# Run with mongdb backend ; run ft_tests
# Run with mongdb backend ; run ft_tests

S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_awssdk.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file npm run ft_awssdk
S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_awssdk.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file S3METADATA=mongodb npm run ft_awssdk

killandsleep 8000

S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_s3cmd.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file npm run ft_s3cmd
S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_s3cmd.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file S3METADATA=mongodb npm run ft_s3cmd

killandsleep 8000
S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_s3curl.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file npm run ft_s3curl

S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_s3curl.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file S3METADATA=mongodb npm run ft_s3curl

killandsleep 8000

S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_healthchecks.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file npm run ft_healthchecks
S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_healthchecks.txt & bash wait_for_local_port.bash 8000 40 && S3DATA=file S3METADATA=mongodb npm run ft_healthchecks

killandsleep 8000

S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_management.txt & bash wait_for_local_port.bash 8000 40 && npm run ft_management
S3BACKEND=mem MPU_TESTING=yes S3METADATA=mongodb npm start > $CIRCLE_ARTIFACTS/server_mongodb_management.txt & bash wait_for_local_port.bash 8000 40 && S3METADATA=mongodb npm run ft_management

killandsleep 8000

Expand Down
16 changes: 3 additions & 13 deletions tests/functional/aws-node-sdk/test/mdSearch/basicSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ runIfMongo('Search when no objects in bucket', () => {
});

runIfMongo('Invalid regular expression searches', () => {
const bucketName = `noobjectbucket${Date.now()}`;
const bucketName = `badregex-${Date.now()}`;
before(done => {
s3Client.createBucket({ Bucket: bucketName }, done);
});
Expand All @@ -132,18 +132,8 @@ runIfMongo('Invalid regular expression searches', () => {
it('should return error if pattern is invalid', done => {
const encodedSearch = encodeURIComponent('key LIKE "/((helloworld/"');
const testError = {
code: 'InternalError',
message: 'We encountered an internal error. Please try again.',
};
return runAndCheckSearch(s3Client, bucketName,
encodedSearch, testError, done);
});

it('should return error if regex flag is invalid', done => {
const encodedSearch = encodeURIComponent('key LIKE "/((helloworld/ii"');
const testError = {
code: 'InternalError',
message: 'We encountered an internal error. Please try again.',
code: 'InvalidArgument',
message: 'Invalid sql where clause sent as search query',
};
return runAndCheckSearch(s3Client, bucketName,
encodedSearch, testError, done);
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/api/parseLikeExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ describe('parseLikeExpression', () => {
},
{
input: '/ice-cream-cone/',
output: { $regex: 'ice-cream-cone', $options: '' },
output: { $regex: /ice-cream-cone/, $options: '' },
},
{
input: '/ice-cream-cone/i',
output: { $regex: 'ice-cream-cone', $options: 'i' },
output: { $regex: /ice-cream-cone/, $options: 'i' },
},
{
input: 'an/ice-cream-cone/',
output: { $regex: 'an/ice-cream-cone/' },
},
{
input: '///',
output: { $regex: '/', $options: '' },
output: { $regex: /\//, $options: '' },
},
];
tests.forEach(test => it('should return correct MongoDB query object: ' +
Expand Down