diff options
author | Ben Caimano <ben.caimano@10gen.com> | 2021-04-23 15:35:58 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-23 16:17:00 +0000 |
commit | 83f45db3ee406ae9218764170e90ac8714e05e97 (patch) | |
tree | 904da7b7cfde489cc3f7b0b7f4af7a03ebd77fe4 /src/mongo/db/auth | |
parent | 5f55799008fdcf7bd418f3dec1a4448c0801f701 (diff) | |
download | mongo-83f45db3ee406ae9218764170e90ac8714e05e97.tar.gz |
SERVER-55787 Better expose getaddrinfo errors in SockAddr
Diffstat (limited to 'src/mongo/db/auth')
-rw-r--r-- | src/mongo/db/auth/address_restriction_test.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/auth/authorization_session_test.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/auth/user_document_parser_test.cpp | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/mongo/db/auth/address_restriction_test.cpp b/src/mongo/db/auth/address_restriction_test.cpp index 574de57a0c8..56f881b8fae 100644 --- a/src/mongo/db/auth/address_restriction_test.cpp +++ b/src/mongo/db/auth/address_restriction_test.cpp @@ -211,8 +211,8 @@ TEST(AddressRestrictionTest, contains) { {{}, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", false}, }; for (const auto& p : contains) { - const SockAddr dummy; - const SockAddr addr(p.address, 1024, AF_UNSPEC); + const auto dummy = SockAddr(); + const auto addr = SockAddr::create(p.address, 1024, AF_UNSPEC); const RestrictionEnvironment rec(addr, dummy); const RestrictionEnvironment res(dummy, addr); @@ -319,8 +319,8 @@ TEST(AddressRestrictionTest, parseAndMatch) { const auto setwith = parseAddressRestrictionSet(doc); ASSERT_OK(setwith); - const RestrictionEnvironment env(SockAddr(t.client, 1024, AF_UNSPEC), - SockAddr(t.server, 1025, AF_UNSPEC)); + const RestrictionEnvironment env(SockAddr::create(t.client, 1024, AF_UNSPEC), + SockAddr::create(t.server, 1025, AF_UNSPEC)); ASSERT_EQ(setwith.getValue().validate(env).isOK(), t.valid); } } diff --git a/src/mongo/db/auth/authorization_session_test.cpp b/src/mongo/db/auth/authorization_session_test.cpp index 1c959118caa..05a275774c5 100644 --- a/src/mongo/db/auth/authorization_session_test.cpp +++ b/src/mongo/db/auth/authorization_session_test.cpp @@ -570,18 +570,18 @@ TEST_F(AuthorizationSessionTest, AcquireUserObtainsAndValidatesAuthenticationRes auto assertWorks = [this](StringData clientSource, StringData serverAddress) { - RestrictionEnvironment::set( - _session, - std::make_unique<RestrictionEnvironment>(SockAddr(clientSource, 5555, AF_UNSPEC), - SockAddr(serverAddress, 27017, AF_UNSPEC))); + RestrictionEnvironment::set(_session, + std::make_unique<RestrictionEnvironment>( + SockAddr::create(clientSource, 5555, AF_UNSPEC), + SockAddr::create(serverAddress, 27017, AF_UNSPEC))); ASSERT_OK(authzSession->addAndAuthorizeUser(_opCtx.get(), UserName("spencer", "test"))); }; auto assertFails = [this](StringData clientSource, StringData serverAddress) { - RestrictionEnvironment::set( - _session, - std::make_unique<RestrictionEnvironment>(SockAddr(clientSource, 5555, AF_UNSPEC), - SockAddr(serverAddress, 27017, AF_UNSPEC))); + RestrictionEnvironment::set(_session, + std::make_unique<RestrictionEnvironment>( + SockAddr::create(clientSource, 5555, AF_UNSPEC), + SockAddr::create(serverAddress, 27017, AF_UNSPEC))); ASSERT_NOT_OK(authzSession->addAndAuthorizeUser(_opCtx.get(), UserName("spencer", "test"))); }; diff --git a/src/mongo/db/auth/user_document_parser_test.cpp b/src/mongo/db/auth/user_document_parser_test.cpp index 44721c6570d..00ff394a222 100644 --- a/src/mongo/db/auth/user_document_parser_test.cpp +++ b/src/mongo/db/auth/user_document_parser_test.cpp @@ -488,8 +488,8 @@ TEST_F(V2UserDocumentParsing, V2AuthenticationRestrictionsExtractionAndRetreival {"127.0.0.1", "::1", false}, }; for (const auto& p : tests) { - const RestrictionEnvironment re(SockAddr(p.client, 1024, AF_UNSPEC), - SockAddr(p.server, 1025, AF_UNSPEC)); + const RestrictionEnvironment re(SockAddr::create(p.client, 1024, AF_UNSPEC), + SockAddr::create(p.server, 1025, AF_UNSPEC)); ASSERT_EQ(doc.validate(re).isOK(), p.valid); } } |