Skip to content

Commit

Permalink
SNOW-591431: Fix ocsp wrong host name test failure (#1010)
Browse files Browse the repository at this point in the history
Fix failed test - testWrongHost.
  • Loading branch information
sfc-gh-wshangguan authored May 25, 2022
1 parent 8a7bbdc commit 5e49c86
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
package net.snowflake.client.jdbc;

import static net.snowflake.client.jdbc.ErrorCode.NETWORK_ERROR;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;

import java.net.SocketTimeoutException;
import java.security.cert.CertificateExpiredException;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import net.snowflake.client.ConditionalIgnoreRule;
import net.snowflake.client.RunningOnGithubAction;
Expand Down Expand Up @@ -413,7 +412,15 @@ public void testWrongHost() {
fail("should fail");
} catch (SQLException ex) {
assertThat(ex, instanceOf(SnowflakeSQLException.class));
assertThat(getCause(ex), instanceOf(SSLPeerUnverifiedException.class));

// The certificates used by badssl.com expired around 05/17/2022,
// https://github.com/chromium/badssl.com/issues/504. After the certificates had been updated,
// the exception seems to be changed from SSLPeerUnverifiedException to SSLHandshakeException.
assertThat(
ex.getCause(),
anyOf(
instanceOf(SSLPeerUnverifiedException.class),
instanceOf(SSLHandshakeException.class)));
}
}
}

0 comments on commit 5e49c86

Please sign in to comment.