blob: 0680dcc27a4f5a3b3c3628511f6974ffc9ad0b61 [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
rajeeranjane5ab2df2025-07-21 15:47:55 +05303#include "duplicatable_file_handle.hpp"
Ed Tanous099225c2024-03-27 22:03:05 -07004#include "ssl_key_handler.hpp"
5
Ed Tanous41fe81c2024-09-02 15:08:41 -07006#include <string>
7
Ed Tanous099225c2024-03-27 22:03:05 -07008#include <gtest/gtest.h>
9
10namespace ensuressl
11{
12
13TEST(SSLKeyHandler, GenerateVerifyRoundTrip)
14{
15 /* Verifies that we can generate a certificate, then read back in the
16 * certificate that was read */
rajeeranjane5ab2df2025-07-21 15:47:55 +053017 DuplicatableFileHandle myFile("");
Ed Tanous099225c2024-03-27 22:03:05 -070018 std::string cert = generateSslCertificate("TestCommonName");
19
20 EXPECT_FALSE(cert.empty());
21
rajeeranjane5ab2df2025-07-21 15:47:55 +053022 writeCertificateToFile(myFile.filePath, cert);
Ed Tanous099225c2024-03-27 22:03:05 -070023
rajeeranjane5ab2df2025-07-21 15:47:55 +053024 std::string cert2 = verifyOpensslKeyCert(myFile.filePath);
Ed Tanous099225c2024-03-27 22:03:05 -070025 EXPECT_FALSE(cert2.empty());
26 EXPECT_EQ(cert, cert2);
27}
28
29} // namespace ensuressl