Skip to content

Commit

Permalink
SOLR-15423 Fix test failures (apache#178)
Browse files Browse the repository at this point in the history
SOLR-15484
  • Loading branch information
janhoy authored Jun 17, 2021
1 parent b0b4d1b commit 2bbee53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
-----BEGIN CERTIFICATE-----
MIIEKDCCAxCgAwIBAgIJANvA408KXcSFMA0GCSqGSIb3DQEBCwUAMGQxCzAJBgNV
BAYTAk5PMQ0wCwYDVQQIDARPU0xPMREwDwYDVQQHDAhJbnRlcm5ldDEOMAwGA1UE
CgwFTElPcmcxDDAKBgNVBAsMA1ImRDEVMBMGA1UEAwwMU29sciBSb290IENBMB4X
DTIxMDYwMzE1MDIyM1oXDTIyMDYwMzE1MDIyM1owZDELMAkGA1UEBhMCTk8xDTAL
BgNVBAgMBE9TTE8xETAPBgNVBAcMCEludGVybmV0MQ4wDAYDVQQKDAVNeU9yZzEM
MAoGA1UECwwDUiZEMRUwEwYDVQQDDAxTb2xyIFJvb3QgQ0EwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQCnbrWbL/4GmmNBep++jQ55fu/5N3QyVNfpxHC7
x5E5AZTSOU9kwh2vwUwfOp9EsaHSKQu2TZYdq3c1gHUgwaMimSFfHofFOTcio03V
dOweGE+7ycoJbXWj74c+jujGnEBAfXzwvM3slf7bHtbRUQOwvwzbAsp2mR81jAJj
XwHmyseJgbTUsYYYmHd4UcDGUkeud/4uJD0AxBlpzf+UUdFTtSfmwurYtzadRbVv
hVGWLPIaZ+URwo/I3oTy1HZnDBQjou12wRwYh/+3Ls2CwRN/Lp2LrT+nGfnxvEhj
jZFC5k2+fNO9Hh8TVR4PoaPRbAZ6KyoOLu6XTtUVtibvT/mdAgMBAAGjgdwwgdkw
DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUwPv6mv2MylV47YKI/fJFSOpGbOow
gZYGA1UdIwSBjjCBi4A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Fuvtwhn
MjevkVbDYWGMWY7qS0/OuSOwd8hmNeh6r4/gkIasLBB5y8ttHgvCMf1nlDtbZc50
catHg6OKCTkagr903CvaS7cIGCNSN+YReESRk1KUkW2+y37yfGmV2LSSK9bNDghf
gIzEt/WjQ1DQLDKaRnOZFgTb1uBgqpKscarVWBZ7z1FqVhPlfs/ykHoRMHJuzzmS
b6m/dADMjCCwTRwrshofOQyaVVIhCITSem8TYrKSLVTD27RRdJXQ3uzKfMuqgNPo
SRYxrQCqUveKPd2488bxUZ4p68UaSPKpeMfW/jTcHCjNUXQtAgMBAAGjOjA4MBQG
A1UdEQQNMAuCCWxvY2FsaG9zdDALBgNVHQ8EBAMCB4AwEwYDVR0lBAwwCgYIKwYB
BQUHAwEwDQYJKoZIhvcNAQELBQADggEBAFcKRH6pZ0zPlGHInvWUzPTMAbWO7/sr
In0vy5LB4iXDgov5iQsfRIR/MP0iajFcLVuJ4Onkrd7TBgDkCm7zA8lyTHIZMfor
aBE/8AKS+hBOyI5EmhRu0f/v5vVVt7O/g86wZ2xwV4Jq+g45zKZPIJsWVhSz8LEh
jU2MYIQtuic5hHEF+Ipe5seNo0JBC/njQLvFygXeD7BWP2dwpfY2MtzZP9Dqf36r
NGhjo6lfjdn+w4vhBlcpseJiBoe9IhDFDAY/CxrUNaL2b862BsmhyV9BuP/KhWQM
P0gPa0XmgbUOTdYu1qCdnmAENz8CbR9kQ0T+cBbE4ond52108BZaUZ8=
-----END CERTIFICATE-----
abcdefgh
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.solr.common.util.TimeSource;
import org.apache.solr.common.util.Utils;
import org.apache.solr.util.CryptoKeys;
import org.apache.solr.util.RTimer;
import org.apache.solr.util.TimeOut;
import org.jose4j.jwk.PublicJsonWebKey;
import org.jose4j.jwk.RsaJsonWebKey;
Expand Down Expand Up @@ -136,7 +137,7 @@ public void extractCertificateFromPem() throws IOException {

@Test
public void mockOAuth2Server() throws Exception {
configureClusterMockOauth(2, pemFilePath);
configureClusterMockOauth(2, pemFilePath, 10000);

// First attempt without token fails
Map<String, String> headers = getHeaders(baseUrl + "/admin/info/system", null);
Expand All @@ -150,7 +151,7 @@ public void mockOAuth2Server() throws Exception {
@Test
public void mockOAuth2ServerWrongPEMInTruststore() throws Exception {
// JWTAuthPlugin throws SSLHandshakeException when fetching JWK, so this trips cluster init
configureClusterMockOauth(2, wrongPemFilePath);
assertThrows(Exception.class, () -> configureClusterMockOauth(2, wrongPemFilePath, 2000));
// Auth is not setup
assertNull(cluster.getJettySolrRunner(0).getCoreContainer().getAuthenticationPlugin());
}
Expand Down Expand Up @@ -259,18 +260,21 @@ public void createCollectionUpdateAndQueryDistributed() throws Exception {
assertPkiAuthMetricsMinimums(4, 4, 0, 0, 0, 0);
}

private void configureClusterMockOauth(int numNodes, Path pemFilePath) throws Exception {
@SuppressWarnings("BusyWait")
private void configureClusterMockOauth(int numNodes, Path pemFilePath, long timeoutMs) throws Exception {
configureCluster(numNodes)// nodes
.addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
.withDefaultClusterProperty("useLegacyReplicaAssignment", "false")
.configure();
String securityJson = createMockOAuthSecurityJson(pemFilePath);
cluster.getZkClient().setData("/security.json", securityJson.getBytes(Charset.defaultCharset()), true);
for(int i = 0; i < 5; i++) { // Wait up to 1s for the security.json change to take effect
if (cluster.getJettySolrRunner(0).getCoreContainer().getAuthenticationPlugin() == null) {
Thread.sleep(200);
} else break;
}
RTimer timer = new RTimer();
do { // Wait timeoutMs time for the security.json change to take effect
Thread.sleep(200);
if (timer.getTime() > timeoutMs) {
throw new Exception("Custom 'security.json' not applied in " + timeoutMs +"ms");
}
} while (cluster.getJettySolrRunner(0).getCoreContainer().getAuthenticationPlugin() == null);
baseUrl = cluster.getRandomJetty(random()).getBaseUrl().toString();
cluster.waitForAllNodes(10);
}
Expand Down

0 comments on commit 2bbee53

Please sign in to comment.