The following issues were found
src/mongo/client/dbclient_cursor_test.cpp
1 issues
Line: 152
}
};
TEST_F(DBClientCursorTest, DBClientCursorCallsMetaDataReaderOncePerBatch) {
// Set up the DBClientCursor and a mock client connection.
DBClientConnectionForTest conn;
const NamespaceString nss("test", "coll");
DBClientCursor cursor(&conn, NamespaceStringOrUUID(nss), fromjson("{}"), 0, 0, nullptr, 0, 0);
cursor.setBatchSize(2);
Reported by Cppcheck.
src/mongo/client/dbclient_rs_test.cpp
1 issues
Line: 150
assertOneOfNodesSelected(replSet, rp, std::vector<std::string>{host.toString()});
}
TEST_F(BasicRS, QueryPrimary) {
MockReplicaSet* replSet = getReplSet();
DBClientReplicaSet replConn(replSet->getSetName(), replSet->getHosts(), StringData());
Query query;
query.readPref(mongo::ReadPreference::PrimaryOnly, BSONArray());
Reported by Cppcheck.
src/mongo/client/fetcher_test.cpp
1 issues
Line: 201
Fetcher::NextAction* nextAction,
BSONObjBuilder* getMoreBob) {}
TEST_F(FetcherTest, InvalidConstruction) {
TaskExecutor& executor = getExecutor();
// Null executor.
ASSERT_THROWS_CODE_AND_WHAT(Fetcher(nullptr, source, "db", findCmdObj, unreachableCallback),
AssertionException,
Reported by Cppcheck.
src/mongo/client/index_spec_test.cpp
1 issues
Line: 59
ASSERT_UASSERTS(IndexSpec().sparse(0).addOptions(BSON("sparse" << 1)));
}
TEST(Options, RepeatedKeysFail) {
IndexSpec spec;
spec.addKey("aField");
ASSERT_UASSERTS(spec.addKey("aField"));
Reported by Cppcheck.
src/mongo/client/mongo_uri_test.cpp
1 issues
Line: 618
ASSERT_EQ(testCase.database, result.getDatabase());
}
TEST(MongoURI, GoodTrickyURIs) {
const size_t numCases = sizeof(validCases) / sizeof(validCases[0]);
for (size_t i = 0; i != numCases; ++i) {
const URITestCase testCase = validCases[i];
testValidURIFormat(testCase);
Reported by Cppcheck.
src/mongo/client/read_preference_test.cpp
1 issues
Line: 53
ASSERT_TRUE(rps.equals(expected));
}
TEST(ReadPreferenceSetting, ParseValid) {
checkParse(BSON("mode"
<< "primary"),
ReadPreferenceSetting(ReadPreference::PrimaryOnly, TagSet::primaryOnly()));
// Check that primary with wildcard tags is accepted for backwards compatibility, but
Reported by Cppcheck.
src/mongo/client/remote_command_retry_scheduler_test.cpp
1 issues
Line: 175
HostAndPort("h1:12345"), "db1", BSON("ping" << 1), nullptr};
}
TEST_F(RemoteCommandRetrySchedulerTest, MakeSingleShotRetryPolicy) {
auto policy = RemoteCommandRetryScheduler::makeNoRetryPolicy();
ASSERT_TRUE(policy);
ASSERT_EQUALS(1U, policy->getMaximumAttempts());
ASSERT_EQUALS(executor::RemoteCommandRequest::kNoTimeout,
policy->getMaximumResponseElapsedTotal());
Reported by Cppcheck.
src/mongo/client/replica_set_monitor_integration_test.cpp
1 issues
Line: 157
size_t numNodes;
};
TEST_F(ReplicaSetMonitorFixture, StreamableRSMWireVersion) {
auto rsm = ReplicaSetMonitorManager::get()->getOrCreateMonitor(replSetUri, nullptr);
// Schedule isMaster requests and wait for the responses.
auto primaryFuture =
rsm->getHostOrRefresh(ReadPreferenceSetting(mongo::ReadPreference::PrimaryOnly),
Reported by Cppcheck.
src/mongo/client/replica_set_monitor_server_parameters_test.cpp
1 issues
Line: 84
* Checks that a ScanningReplicaSetMonitor is created when the replicaSetMonitorProtocol server
* parameter is set to 'scanning'.
*/
TEST_F(ReplicaSetMonitorProtocolTest, checkRSMProtocolParamScanning) {
ReplicaSetMonitorProtocolTestUtil::setRSMProtocol(ReplicaSetMonitorProtocol::kScanning);
auto uri = MongoURI::parse("mongodb:a,b,c/?replicaSet=name");
ASSERT_OK(uri.getStatus());
auto createdMonitor = ReplicaSetMonitor::createIfNeeded(uri.getValue());
Reported by Cppcheck.
src/mongo/client/sasl_aws_protocol_common.h
1 issues
Line: 80
Column: 32
CWE codes:
120
20
T convertFromByteString(StringData rawString) {
ConstDataRange cdr(rawString.rawData(), rawString.size());
auto clientFirstBson = cdr.read<Validated<BSONObj>>();
return T::parse(IDLParserErrorContext("sasl"), clientFirstBson);
}
/**
Reported by FlawFinder.