tests: delete dead code in KeyChainFixture

Also sync GlobalConfiguration with NFD and reformat
the example configuration files.

Change-Id: Id1580eed30514bcbf2e0653635ccbf65dac24d58
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index 4dad5c0..e217098 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -18,12 +18,14 @@
  * See AUTHORS.md for complete list of ndncert authors and contributors.
  */
 
-#include "detail/ndncert-common.hpp"
-
 #include "tests/boost-test.hpp"
 
-#include <boost/filesystem.hpp>
-#include <fstream>
+#include <ndn-cxx/util/exception.hpp>
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+
+#include <stdexcept>
 #include <stdlib.h>
 
 namespace ndncert::tests {
@@ -35,17 +37,16 @@
   {
     const char* envHome = ::getenv("HOME");
     if (envHome)
-      m_home = envHome;
+      m_home.assign(envHome);
 
-    auto testHome = boost::filesystem::path(UNIT_TESTS_TMPDIR) / "test-home";
-    if (::setenv("HOME", testHome.c_str(), 1) != 0)
-      NDN_THROW(std::runtime_error("setenv() failed"));
+    // in case an earlier test run crashed without a chance to run the destructor
+    boost::filesystem::remove_all(TESTDIR);
 
+    auto testHome = TESTDIR / "test-home";
     boost::filesystem::create_directories(testHome);
 
-    std::ofstream clientConf((testHome / ".ndn" / "client.conf").c_str());
-    clientConf << "pib=pib-sqlite3" << std::endl
-               << "tpm=tpm-file" << std::endl;
+    if (::setenv("HOME", testHome.c_str(), 1) != 0)
+      NDN_THROW(std::runtime_error("setenv() failed"));
   }
 
   ~GlobalConfiguration() noexcept
@@ -54,9 +55,13 @@
       ::unsetenv("HOME");
     else
       ::setenv("HOME", m_home.data(), 1);
+
+    boost::system::error_code ec;
+    boost::filesystem::remove_all(TESTDIR, ec); // ignore error
   }
 
 private:
+  static inline const boost::filesystem::path TESTDIR{UNIT_TESTS_TMPDIR};
   std::string m_home;
 };