Use openssl random number generator
We already have a generator class. We should use it. Wrap this into a
function that can be unit tested, and add unit tests.
Note, some files also needed to change name, because random.hpp
conflicts with the built in random, and causes circular build problems.
This commit changes it to ossl_random.
Tested: Unit tests pass. Now has coverage.
Redfish service validator passes.
Change-Id: I5f8eee1af5f4843a352c6fd0e26d67fd3320ef53
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/test/include/ossl_random.cpp b/test/include/ossl_random.cpp
new file mode 100644
index 0000000..22935e7
--- /dev/null
+++ b/test/include/ossl_random.cpp
@@ -0,0 +1,23 @@
+#include "ossl_random.hpp"
+
+#include <string>
+
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+namespace
+{
+
+using testing::MatchesRegex;
+
+TEST(Bmcweb, GetRandomUUID)
+{
+ using bmcweb::getRandomUUID;
+ // 78e96a4b-62fe-48d8-ac09-7f75a94671e0
+ EXPECT_THAT(
+ getRandomUUID(),
+ MatchesRegex(
+ "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"));
+}
+
+} // namespace