summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_parser_test.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-12-14 18:22:01 -0500
committerDavid Storch <david.storch@10gen.com>2015-12-22 10:13:40 -0500
commit26bcf4ddd7e86885448e981f86aaf51fba0e2539 (patch)
tree5d9cd1de1193f8c52f8d1eae3dd3e35a3bffd3f0 /src/mongo/db/matcher/expression_parser_test.cpp
parent3663e004dfc2f73b82b3d88b5fa1ac6b7dcd1d33 (diff)
downloadmongo-26bcf4ddd7e86885448e981f86aaf51fba0e2539.tar.gz
SERVER-21407 explicitly disallow $text/$where extensions during MatchExpression parsing
Diffstat (limited to 'src/mongo/db/matcher/expression_parser_test.cpp')
-rw-r--r--src/mongo/db/matcher/expression_parser_test.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/matcher/expression_parser_test.cpp b/src/mongo/db/matcher/expression_parser_test.cpp
index 4927cd29229..8bad5986891 100644
--- a/src/mongo/db/matcher/expression_parser_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_test.cpp
@@ -36,12 +36,14 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
+#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
namespace mongo {
TEST(MatchExpressionParserTest, SimpleEQ1) {
BSONObj query = BSON("x" << 2);
- StatusWithMatchExpression result = MatchExpressionParser::parse(query);
+ StatusWithMatchExpression result =
+ MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions());
ASSERT_TRUE(result.isOK());
ASSERT(result.getValue()->matchesBSON(BSON("x" << 2)));
@@ -50,7 +52,8 @@ TEST(MatchExpressionParserTest, SimpleEQ1) {
TEST(MatchExpressionParserTest, Multiple1) {
BSONObj query = BSON("x" << 5 << "y" << BSON("$gt" << 5 << "$lt" << 8));
- StatusWithMatchExpression result = MatchExpressionParser::parse(query);
+ StatusWithMatchExpression result =
+ MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions());
ASSERT_TRUE(result.isOK());
ASSERT(result.getValue()->matchesBSON(BSON("x" << 5 << "y" << 7)));
@@ -62,15 +65,16 @@ TEST(MatchExpressionParserTest, Multiple1) {
TEST(AtomicMatchExpressionTest, Simple1) {
BSONObj query = BSON("x" << 5 << "$atomic" << BSON("$gt" << 5 << "$lt" << 8));
- StatusWithMatchExpression result = MatchExpressionParser::parse(query);
+ StatusWithMatchExpression result =
+ MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions());
ASSERT_TRUE(result.isOK());
query = BSON("x" << 5 << "$isolated" << 1);
- result = MatchExpressionParser::parse(query);
+ result = MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions());
ASSERT_TRUE(result.isOK());
query = BSON("x" << 5 << "y" << BSON("$isolated" << 1));
- result = MatchExpressionParser::parse(query);
+ result = MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions());
ASSERT_FALSE(result.isOK());
}