@Test
void buildTlsConfig_shouldUseUserSuppliedCertificateWhenDefined() throws Exception {

  Config defaultConfig =
      ConfigFactory.parseResources(XConfigTest.class, "xrpc.conf").getConfig("tls");
  Config configWithCertPaths =
      ConfigFactory.parseMap(
          ImmutableMap.of(
              "privateKeyPath",
              getResourceAbsolutePath("testing-purposes-only-key.pem"),
              "x509CertPath",
              getResourceAbsolutePath("testing-purposes-only-certificate.crt")));
  TlsConfig tlsConfig = XConfig.buildTlsConfig(configWithCertPaths.withFallback(defaultConfig));
  String privateKey = getFileContent("testing-purposes-only-key.pem");
  String certificate = getFileContent("testing-purposes-only-certificate.crt");
  assertThat(tlsConfig.getPrivateKey(), is(parsePrivateKeyFromPem(privateKey)));
  assertThat(tlsConfig.getCertificateAndChain().length, is(1));
  assertThat(tlsConfig.getCertificateAndChain()[0], is(parseX509CertificateFromPem(certificate)));
}