diff options
author | Ed Tanous <ed@tanous.net> | 2024-06-05 18:45:25 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-06-10 18:19:46 +0300 |
commit | b7f3a82babf87c7279ebc4cb728497ade1b1d00a (patch) | |
tree | 568378e082ccbf02c8a91b1cb78c3b8d3ef8e6ef /test/include | |
parent | d5fb584a8ad7d493a3236261f727852f262271c6 (diff) | |
download | bmcweb-b7f3a82babf87c7279ebc4cb728497ade1b1d00a.tar.xz |
Break out random ID methods
The method of creating a random ID from an openssl random generator of a
particular length is something that is generally useful, and something
we can write unit tests for. Add it.
Tested:
Redfish service validator login flows work correctly in redfish service
validator.
Change-Id: Ic3b58d33f1421f3eb39e2d57585958f87f6fb8ea
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'test/include')
-rw-r--r-- | test/include/ossl_random.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/include/ossl_random.cpp b/test/include/ossl_random.cpp index 512b5c8f83..1b9a2b88da 100644 --- a/test/include/ossl_random.cpp +++ b/test/include/ossl_random.cpp @@ -6,6 +6,7 @@ namespace { +using testing::IsEmpty; using testing::MatchesRegex; TEST(Bmcweb, GetRandomUUID) @@ -18,4 +19,12 @@ TEST(Bmcweb, GetRandomUUID) "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$")); } +TEST(Bmcweb, GetRandomIdOfLength) +{ + using bmcweb::getRandomIdOfLength; + EXPECT_THAT(getRandomIdOfLength(1), MatchesRegex("^[a-zA-Z0-9]$")); + EXPECT_THAT(getRandomIdOfLength(10), MatchesRegex("^[a-zA-Z0-9]{10}$")); + EXPECT_THAT(getRandomIdOfLength(0), IsEmpty()); +} + } // namespace |