blob: 44da0383d113d945db372e844805a47e3766ee7a [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Ed Tanous099225c2024-03-27 22:03:05 -07003#include "file_test_utilities.hpp"
4#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 */
17 TemporaryFileHandle myFile("");
18 std::string cert = generateSslCertificate("TestCommonName");
19
20 EXPECT_FALSE(cert.empty());
21
22 writeCertificateToFile(myFile.stringPath, cert);
23
24 std::string cert2 = verifyOpensslKeyCert(myFile.stringPath);
25 EXPECT_FALSE(cert2.empty());
26 EXPECT_EQ(cert, cert2);
27}
28
29} // namespace ensuressl