Format fixes

This commit is contained in:
Sarah Botwinick 2021-01-28 18:24:58 -05:00
parent 6d47ed2861
commit 26f88bd313
3 changed files with 12 additions and 13 deletions

View file

@ -164,7 +164,7 @@ public class TlsCredentials implements TransportCredentials {
storedFailoverCert = stringToCert(registrar.getFailoverClientCertificate()); storedFailoverCert = stringToCert(registrar.getFailoverClientCertificate());
passedCert = encodedCertStringToCert(clientCertificate.get()); passedCert = encodedCertStringToCert(clientCertificate.get());
} catch (Exception e) { } catch (Exception e) {
//TODO(Sarahbot@): remove this catch once we know it's working // TODO(Sarahbot@): remove this catch once we know it's working
logger.atWarning().log( logger.atWarning().log(
"Error converting certificate string to certificate for %s: %s", "Error converting certificate string to certificate for %s: %s",
registrar.getClientId(), e); registrar.getClientId(), e);
@ -198,8 +198,7 @@ public class TlsCredentials implements TransportCredentials {
// Log an error and validate using certificate hash instead // Log an error and validate using certificate hash instead
// TODO(sarahbot): throw a BadRegistrarCertificateException once hash is no longer used as // TODO(sarahbot): throw a BadRegistrarCertificateException once hash is no longer used as
// failover // failover
logger.atWarning().log( logger.atWarning().log("Non-matching certificate for registrar %s.", registrar.getClientId());
"Non-matching certificate for registrar %s.", registrar.getClientId());
} }
validateCertificateHash(registrar); validateCertificateHash(registrar);
} }

View file

@ -18,6 +18,7 @@ import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.LogsSubject.assertAboutLogs; import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -47,7 +48,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.shaded.org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator; import org.testcontainers.shaded.org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator;
import org.testcontainers.shaded.org.bouncycastle.util.io.pem.PemObjectGenerator; import org.testcontainers.shaded.org.bouncycastle.util.io.pem.PemObjectGenerator;
import org.testcontainers.shaded.org.bouncycastle.util.io.pem.PemWriter; import org.testcontainers.shaded.org.bouncycastle.util.io.pem.PemWriter;
import static java.nio.charset.StandardCharsets.UTF_8;
/** Test logging in with TLS credentials. */ /** Test logging in with TLS credentials. */
class EppLoginTlsTest extends EppTestCase { class EppLoginTlsTest extends EppTestCase {
@ -103,8 +103,8 @@ class EppLoginTlsTest extends EppTestCase {
Base64.getEncoder() Base64.getEncoder()
.encodeToString( .encodeToString(
CertificateFactory.getInstance("X.509") CertificateFactory.getInstance("X.509")
.generateCertificate( .generateCertificate(
new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT3.getBytes(UTF_8))) new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT3.getBytes(UTF_8)))
.getEncoded()); .getEncoded());
} }
@ -230,8 +230,8 @@ class EppLoginTlsTest extends EppTestCase {
Base64.getEncoder() Base64.getEncoder()
.encodeToString( .encodeToString(
CertificateFactory.getInstance("X.509") CertificateFactory.getInstance("X.509")
.generateCertificate( .generateCertificate(
new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT.getBytes(UTF_8))) new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT.getBytes(UTF_8)))
.getEncoded()); .getEncoded());
// SAMPLE_CERT has a validity period that is too long // SAMPLE_CERT has a validity period that is too long
setCredentials(CertificateSamples.SAMPLE_CERT_HASH, proxyEncoded); setCredentials(CertificateSamples.SAMPLE_CERT_HASH, proxyEncoded);
@ -299,8 +299,8 @@ class EppLoginTlsTest extends EppTestCase {
Base64.getEncoder() Base64.getEncoder()
.encodeToString( .encodeToString(
CertificateFactory.getInstance("X.509") CertificateFactory.getInstance("X.509")
.generateCertificate( .generateCertificate(
new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT.getBytes(UTF_8))) new ByteArrayInputStream(CertificateSamples.SAMPLE_CERT.getBytes(UTF_8)))
.getEncoded()); .getEncoded());
setCredentials(null, proxyEncoded); setCredentials(null, proxyEncoded);
persistResource( persistResource(

View file

@ -16,8 +16,8 @@ package google.registry.flows.session;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -68,7 +68,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
Base64.getEncoder() Base64.getEncoder()
.encodeToString( .encodeToString(
CertificateFactory.getInstance("X.509") CertificateFactory.getInstance("X.509")
.generateCertificate(new ByteArrayInputStream(GOOD_CERT.get().getBytes(UTF_8))) .generateCertificate(new ByteArrayInputStream(GOOD_CERT.get().getBytes(UTF_8)))
.getEncoded()); .getEncoded());
encodedCertString = Optional.of(proxyEncoded); encodedCertString = Optional.of(proxyEncoded);
} }
@ -131,7 +131,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
Base64.getEncoder() Base64.getEncoder()
.encodeToString( .encodeToString(
CertificateFactory.getInstance("X.509") CertificateFactory.getInstance("X.509")
.generateCertificate(new ByteArrayInputStream(BAD_CERT.get().getBytes(UTF_8))) .generateCertificate(new ByteArrayInputStream(BAD_CERT.get().getBytes(UTF_8)))
.getEncoded()); .getEncoded());
credentials = credentials =
new TlsCredentials( new TlsCredentials(