Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 3 | #include "file_test_utilities.hpp" |
| 4 | #include "ssl_key_handler.hpp" |
| 5 | |
Ed Tanous | 41fe81c | 2024-09-02 15:08:41 -0700 | [diff] [blame] | 6 | #include <string> |
| 7 | |
Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | namespace ensuressl |
| 11 | { |
| 12 | |
| 13 | TEST(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 |