summaryrefslogtreecommitdiff
path: root/src/mongo/idl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/idl')
-rw-r--r--src/mongo/idl/basic_types.h5
-rw-r--r--src/mongo/idl/basic_types.idl7
-rw-r--r--src/mongo/idl/server_parameter_test_util.h43
3 files changed, 44 insertions, 11 deletions
diff --git a/src/mongo/idl/basic_types.h b/src/mongo/idl/basic_types.h
index 4b77f57461d..4f93115bf0c 100644
--- a/src/mongo/idl/basic_types.h
+++ b/src/mongo/idl/basic_types.h
@@ -127,6 +127,11 @@ private:
boost::optional<bool> _value;
};
+template <typename H>
+H AbslHashValue(H h, const OptionalBool& optBool) {
+ return H::combine(std::move(h), optBool.has_value(), bool(optBool));
+}
+
/**
* Class to represent a BSON element with any type from IDL. The caller must ensure that the backing
* BSON stays alive while this type is in use.
diff --git a/src/mongo/idl/basic_types.idl b/src/mongo/idl/basic_types.idl
index 634b05d9539..e41c18b7714 100644
--- a/src/mongo/idl/basic_types.idl
+++ b/src/mongo/idl/basic_types.idl
@@ -163,6 +163,13 @@ types:
cpp_type: "std::vector<std::uint8_t>"
deserializer: "mongo::BSONElement::_binDataVector"
+ bindata_sensitive:
+ bson_serialization_type: bindata
+ bindata_subtype: sensitive
+ description: "A BSON bindata of sensitive sub type"
+ cpp_type: "std::vector<std::uint8_t>"
+ deserializer: "mongo::BSONElement::_binDataVector"
+
uuid:
bson_serialization_type: bindata
bindata_subtype: uuid
diff --git a/src/mongo/idl/server_parameter_test_util.h b/src/mongo/idl/server_parameter_test_util.h
index 566489dd1a9..f7e2ae31834 100644
--- a/src/mongo/idl/server_parameter_test_util.h
+++ b/src/mongo/idl/server_parameter_test_util.h
@@ -36,31 +36,28 @@
namespace mongo {
/**
- * Test-only RAII type that allows to set a server parameter value during the execution of a
- * unit test, or part of a unit test, and resets it to the original value on destruction.
+ * Test-only class that sets a server parameter to the specified value and allows
+ * resetting after the test completes.
*/
-class RAIIServerParameterControllerForTest {
+class ServerParameterControllerForTest {
public:
/**
* Constructor setting the server parameter to the specified value.
*/
template <typename T>
- RAIIServerParameterControllerForTest(const std::string& name, T value)
+ ServerParameterControllerForTest(const std::string& name, T value)
: _serverParam(ServerParameterSet::getNodeParameterSet()->get(name)) {
- // Save the old value
+ // Save the old value.
BSONObjBuilder bob;
_serverParam->appendSupportingRoundtrip(nullptr, bob, name);
_oldValue = bob.obj();
- // Set to the new value
+ // Set server param to the new value.
uassertStatusOK(_serverParam->set(BSON(name << value).firstElement()));
}
- /**
- * Destructor resetting the server parameter to the original value.
- */
- ~RAIIServerParameterControllerForTest() {
- // Reset to the old value
+ void reset() {
+ // Reset to the old value.
auto elem = _oldValue.firstElement();
uassertStatusOK(_serverParam->set(elem));
}
@@ -70,4 +67,28 @@ private:
BSONObj _oldValue;
};
+/**
+ * Test-only RAII type that wraps ServerParameterControllerForTest. Upon destruction, the server
+ * parameter will be set to its original value.
+ */
+class RAIIServerParameterControllerForTest {
+public:
+ /**
+ * Constructor setting the server parameter to the specified value.
+ */
+ template <typename T>
+ RAIIServerParameterControllerForTest(const std::string& name, T value)
+ : _serverParamController(ServerParameterControllerForTest(name, value)) {}
+
+ /**
+ * Destructor resetting the server parameter to the original value.
+ */
+ ~RAIIServerParameterControllerForTest() {
+ _serverParamController.reset();
+ }
+
+private:
+ ServerParameterControllerForTest _serverParamController;
+};
+
} // namespace mongo