tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ssl_debug_env_unittest.cc (1195B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include <cstdlib>
      8 #include <fstream>
      9 #include <sstream>
     10 
     11 #include "gtest_utils.h"
     12 #include "tls_connect.h"
     13 
     14 namespace nss_test {
     15 
     16 extern "C" {
     17 extern FILE* ssl_trace_iob;
     18 
     19 #ifdef NSS_ALLOW_SSLKEYLOGFILE
     20 extern FILE* ssl_keylog_iob;
     21 #endif
     22 }
     23 
     24 // These tests ensure that when the associated environment variables are unset
     25 // that the lazily-initialized defaults are what they are supposed to be.
     26 
     27 #ifdef DEBUG
     28 TEST_P(TlsConnectGeneric, DebugEnvTraceFileNotSet) {
     29  char* ev = PR_GetEnvSecure("SSLDEBUGFILE");
     30  if (ev && ev[0]) {
     31    GTEST_SKIP();
     32  }
     33 
     34  Connect();
     35  EXPECT_EQ(stderr, ssl_trace_iob);
     36 }
     37 #endif
     38 
     39 #ifdef NSS_ALLOW_SSLKEYLOGFILE
     40 TEST_P(TlsConnectGeneric, DebugEnvKeylogFileNotSet) {
     41  char* ev = PR_GetEnvSecure("SSLKEYLOGFILE");
     42  if (ev && ev[0]) {
     43    GTEST_SKIP();
     44  }
     45 
     46  Connect();
     47  EXPECT_EQ(nullptr, ssl_keylog_iob);
     48 }
     49 #endif
     50 
     51 }  // namespace nss_test