Skip to content

Commit

Permalink
updated test variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdeye committed Jul 23, 2024
1 parent e4e283d commit b0479b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
7 changes: 1 addition & 6 deletions tool-openssl/x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,7 @@ bool X509Tool(const args_list_t &args) {
}

if (!noout && !in_path.empty() && !checkend && parsed_args.count("-out")==0) {
bssl::uniquePtr<BIO> bio_out(BIO_new_fp(stdout, BIO_NOCLOSE));
if (!PEM_write_bio_X509(bio_out, x509.get())) {
BIO_free(bio_out);
return false;
}
BIO_free(bio_out);
bssl::UniquePtr<BIO> bio_out(BIO_new_fp(stdout, BIO_NOCLOSE));
}
}
return true;
Expand Down
24 changes: 12 additions & 12 deletions tool-openssl/x509_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class X509ComparisonTest : public ::testing::Test {
// Skip gtests if env variables not set
tool_executable_path = getenv("AWSLC_TOOL_PATH");
openssl_executable_path = getenv("OPENSSL_TOOL_PATH");
if (tool_executable_path == nullptr || openssl_executable_path == nullptr) {
if (tool_executable_path.empty() || openssl_executable_path.empty()) {
GTEST_SKIP() << "Skipping test: AWSLC_TOOL_PATH and/or OPENSSL_TOOL_PATH environment variables are not set";
}

Expand Down Expand Up @@ -296,7 +296,7 @@ class X509ComparisonTest : public ::testing::Test {
}

void TearDown() override {
if (tool_executable_path != nullptr && openssl_executable_path != nullptr) {
if (!tool_executable_path.empty() && !openssl_executable_path.empty()) {
RemoveFile(in_path);
RemoveFile(csr_path);
RemoveFile(out_path_tool);
Expand All @@ -312,8 +312,8 @@ class X509ComparisonTest : public ::testing::Test {
char signkey_path[PATH_MAX];
bssl::UniquePtr<X509> x509;
bssl::UniquePtr<X509_REQ> csr;
const char* tool_executable_path;
const char* openssl_executable_path;
std::string tool_executable_path;
std::string openssl_executable_path;
std::string tool_output_str;
std::string openssl_output_str;
};
Expand All @@ -334,8 +334,8 @@ const std::string CERT_END = "-----END CERTIFICATE-----";

// Test against OpenSSL output "openssl x509 -in file -modulus"
TEST_F(X509ComparisonTest, X509ToolCompareModulusOpenSSL) {
std::string tool_command = std::string(tool_executable_path) + " x509 -in " + std::string(in_path) + " -modulus > " + out_path_tool;
std::string openssl_command = std::string(openssl_executable_path) + " x509 -in " + std::string(in_path) + " -modulus > " + out_path_openssl;
std::string tool_command = tool_executable_path + " x509 -in " + in_path + " -modulus > " + out_path_tool;
std::string openssl_command = openssl_executable_path + " x509 -in " + in_path + " -modulus > " + out_path_openssl;

RunCommandsAndCompareOutput(tool_command, openssl_command);

Expand All @@ -344,8 +344,8 @@ TEST_F(X509ComparisonTest, X509ToolCompareModulusOpenSSL) {

// Test against OpenSSL output "openssl x509 -in in_file -checkend 0"
TEST_F(X509ComparisonTest, X509ToolCompareCheckendOpenSSL) {
std::string tool_command = std::string(tool_executable_path) + " x509 -in " + std::string(in_path) + " -checkend 0 > " + out_path_tool;
std::string openssl_command = std::string(openssl_executable_path) + " x509 -in " + std::string(in_path) + " -checkend 0 > " + out_path_openssl;
std::string tool_command = tool_executable_path + " x509 -in " + in_path + " -checkend 0 > " + out_path_tool;
std::string openssl_command = openssl_executable_path + " x509 -in " + in_path + " -checkend 0 > " + out_path_openssl;

RunCommandsAndCompareOutput(tool_command, openssl_command);

Expand All @@ -354,8 +354,8 @@ TEST_F(X509ComparisonTest, X509ToolCompareCheckendOpenSSL) {

// Test against OpenSSL output "openssl x509 -req -in csr_file -signkey private_key_file -days 80 -out out_file"
TEST_F(X509ComparisonTest, X509ToolCompareReqSignkeyDaysOpenSSL) {
std::string tool_command = std::string(tool_executable_path) + " x509 -req -in " + std::string(csr_path) + " -signkey " + std::string(signkey_path) + " -days 80 -out " + out_path_tool;
std::string openssl_command = std::string(openssl_executable_path) + " x509 -req -in " + std::string(csr_path) + " -signkey " + std::string(signkey_path) + " -days 80 -out " + out_path_openssl;
std::string tool_command = tool_executable_path + " x509 -req -in " + csr_path + " -signkey " + signkey_path + " -days 80 -out " + out_path_tool;
std::string openssl_command = openssl_executable_path + " x509 -req -in " + csr_path + " -signkey " + signkey_path + " -days 80 -out " + out_path_openssl;

RunCommandsAndCompareOutput(tool_command, openssl_command);

Expand All @@ -371,8 +371,8 @@ TEST_F(X509ComparisonTest, X509ToolCompareReqSignkeyDaysOpenSSL) {

// Test against OpenSSL output "openssl x509 -in file -dates -noout"
TEST_F(X509ComparisonTest, X509ToolCompareDatesNooutOpenSSL) {
std::string tool_command = std::string(tool_executable_path) + " x509 -in " + std::string(in_path) + " -dates -noout > " + out_path_tool;
std::string openssl_command = std::string(openssl_executable_path) + " x509 -in " + std::string(in_path) + " -dates -noout > " + out_path_openssl;
std::string tool_command = tool_executable_path + " x509 -in " + in_path + " -dates -noout > " + out_path_tool;
std::string openssl_command = openssl_executable_path + " x509 -in " + in_path + " -dates -noout > " + out_path_openssl;

RunCommandsAndCompareOutput(tool_command, openssl_command);

Expand Down

0 comments on commit b0479b1

Please sign in to comment.