| 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 |
| rajeeranjan | e5ab2df | 2025-07-21 15:47:55 +0530 | [diff] [blame^] | 3 | #include "duplicatable_file_handle.hpp" |
| Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 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 */ |
| rajeeranjan | e5ab2df | 2025-07-21 15:47:55 +0530 | [diff] [blame^] | 17 | DuplicatableFileHandle myFile(""); |
| Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 18 | std::string cert = generateSslCertificate("TestCommonName"); |
| 19 | |
| 20 | EXPECT_FALSE(cert.empty()); |
| 21 | |
| rajeeranjan | e5ab2df | 2025-07-21 15:47:55 +0530 | [diff] [blame^] | 22 | writeCertificateToFile(myFile.filePath, cert); |
| Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 23 | |
| rajeeranjan | e5ab2df | 2025-07-21 15:47:55 +0530 | [diff] [blame^] | 24 | std::string cert2 = verifyOpensslKeyCert(myFile.filePath); |
| Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 25 | EXPECT_FALSE(cert2.empty()); |
| 26 | EXPECT_EQ(cert, cert2); |
| 27 | } |
| 28 | |
| 29 | } // namespace ensuressl |