diff options
author | Robert Guo <robert.guo@10gen.com> | 2016-03-22 17:10:50 -0400 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2016-03-29 13:08:43 -0400 |
commit | e242b49373f0a9ee39f2b02f1a766a84c2c869b6 (patch) | |
tree | 3eaf08b0a85cbfde4b041f944001232d5e55e6e6 /src/mongo/db/namespace_string_test.cpp | |
parent | ea07e34466f14b127ac97f58ec6a40e9e52ebbd5 (diff) | |
download | mongo-e242b49373f0a9ee39f2b02f1a766a84c2c869b6.tar.gz |
SERVER-22577 disallow creation of databases containing $ on mmapv1
Diffstat (limited to 'src/mongo/db/namespace_string_test.cpp')
-rw-r--r-- | src/mongo/db/namespace_string_test.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/mongo/db/namespace_string_test.cpp b/src/mongo/db/namespace_string_test.cpp index ba85cc775e3..03e2837159c 100644 --- a/src/mongo/db/namespace_string_test.cpp +++ b/src/mongo/db/namespace_string_test.cpp @@ -66,11 +66,40 @@ TEST(NamespaceStringTest, Special) { } TEST(NamespaceStringTest, DatabaseValidNames) { + ASSERT(NamespaceString::validDBName("foo", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT(NamespaceString::validDBName("foo$bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo/bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo.bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo\\bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo\"bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT(!NamespaceString::validDBName(StringData("a\0b", StringData::LiteralTag()), + NamespaceString::DollarInDbNameBehavior::Allow)); +#ifdef _WIN32 + ASSERT( + !NamespaceString::validDBName("foo*bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo<bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo>bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo:bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo|bar", NamespaceString::DollarInDbNameBehavior::Allow)); + ASSERT( + !NamespaceString::validDBName("foo?bar", NamespaceString::DollarInDbNameBehavior::Allow)); +#endif + ASSERT(NamespaceString::validDBName("foo")); + ASSERT(!NamespaceString::validDBName("foo$bar")); ASSERT(!NamespaceString::validDBName("foo/bar")); ASSERT(!NamespaceString::validDBName("foo bar")); ASSERT(!NamespaceString::validDBName("foo.bar")); - ASSERT(!NamespaceString::validDBName("foo.bar")); ASSERT(!NamespaceString::validDBName("foo\\bar")); ASSERT(!NamespaceString::validDBName("foo\"bar")); ASSERT(!NamespaceString::validDBName(StringData("a\0b", StringData::LiteralTag()))); |