summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/authorization_manager_test.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2018-12-03 20:45:58 +0200
committerApollon Oikonomopoulos <apoikos@debian.org>2018-12-03 20:45:58 +0200
commit239aabeb53a8dcd45eac7d069e0cb0180b4bc412 (patch)
treec1642d9d026783a026d41a2ae3e1920fa31edb71 /src/mongo/db/auth/authorization_manager_test.cpp
parent3896a4a134ae19f25de14727862898cee19aa2e3 (diff)
New upstream version 3.4.18upstream/3.4.18
Diffstat (limited to 'src/mongo/db/auth/authorization_manager_test.cpp')
-rw-r--r--src/mongo/db/auth/authorization_manager_test.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/auth/authorization_manager_test.cpp b/src/mongo/db/auth/authorization_manager_test.cpp
index 50f823f014a..ea39d0834a7 100644
--- a/src/mongo/db/auth/authorization_manager_test.cpp
+++ b/src/mongo/db/auth/authorization_manager_test.cpp
@@ -32,6 +32,7 @@
*/
#include "mongo/base/status.h"
#include "mongo/bson/mutable/document.h"
+#include "mongo/config.h"
#include "mongo/db/auth/action_set.h"
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
@@ -55,6 +56,12 @@
namespace mongo {
namespace {
+// Construct a simple, structured X509 name equivalent to "CN=mongodb.com"
+SSLX509Name buildX509Name() {
+ return SSLX509Name(std::vector<std::vector<SSLX509Name::Entry>>(
+ {{{kOID_CommonName.toString(), 19 /* Printable String */, "mongodb.com"}}}));
+}
+
using std::vector;
TEST(RoleParsingTest, BuildRoleBSON) {
@@ -241,13 +248,14 @@ TEST_F(AuthorizationManagerTest, testAcquireV2User) {
authzManager->releaseUser(v2cluster);
}
+#ifdef MONGO_CONFIG_SSL
TEST_F(AuthorizationManagerTest, testLocalX509Authorization) {
ServiceContextNoop serviceContext;
transport::TransportLayerMock transportLayer{};
transport::SessionHandle session = transportLayer.createSession();
transportLayer.setX509PeerInfo(
session,
- SSLPeerInfo("CN=mongodb.com", {RoleName("read", "test"), RoleName("readWrite", "test")}));
+ SSLPeerInfo(buildX509Name(), {RoleName("read", "test"), RoleName("readWrite", "test")}));
ServiceContext::UniqueClient client = serviceContext.makeClient("testClient", session);
ServiceContext::UniqueOperationContext txn = client->makeOperationContext();
@@ -274,6 +282,7 @@ TEST_F(AuthorizationManagerTest, testLocalX509Authorization) {
authzManager->releaseUser(x509User);
}
+#endif
TEST_F(AuthorizationManagerTest, testLocalX509AuthorizationInvalidUser) {
ServiceContextNoop serviceContext;
@@ -281,7 +290,7 @@ TEST_F(AuthorizationManagerTest, testLocalX509AuthorizationInvalidUser) {
transport::SessionHandle session = transportLayer.createSession();
transportLayer.setX509PeerInfo(
session,
- SSLPeerInfo("CN=mongodb.com", {RoleName("read", "test"), RoleName("write", "test")}));
+ SSLPeerInfo(buildX509Name(), {RoleName("read", "test"), RoleName("write", "test")}));
ServiceContext::UniqueClient client = serviceContext.makeClient("testClient", session);
ServiceContext::UniqueOperationContext txn = client->makeOperationContext();