Fix SAMLRealmTests#testReadIdpMetadataFromHttps failures
This commit fixes failures in SAMLRealmTests#testReadIdpMetadataFromHttps. The main test failure is caused by the test relying too much on timing with a sleep; the sleep has been removed and replaced with an assert busy. The second issue that was fixed in the test, is the test makes two requests to the webserver but only one request is queued in the MockWebServer leading to a NPE. relates elastic/x-pack-elasticsearch#3667 Original commit: elastic/x-pack-elasticsearch@6c7076c990
This commit is contained in:
parent
e577d2b776
commit
698ad62150
|
@ -115,6 +115,7 @@ public class SamlRealmTests extends SamlTestCase {
|
|||
try (MockWebServer proxyServer = new MockWebServer(sslService.sslContext(Settings.EMPTY), false)) {
|
||||
proxyServer.start();
|
||||
proxyServer.enqueue(new MockResponse().setResponseCode(200).setBody(body).addHeader("Content-Type", "application/xml"));
|
||||
proxyServer.enqueue(new MockResponse().setResponseCode(200).setBody(body).addHeader("Content-Type", "application/xml"));
|
||||
assertEquals(0, proxyServer.requests().size());
|
||||
|
||||
Tuple<RealmConfig, SSLService> config = buildConfig("https://localhost:" + proxyServer.getPort());
|
||||
|
@ -126,8 +127,7 @@ public class SamlRealmTests extends SamlTestCase {
|
|||
final int firstRequestCount = proxyServer.requests().size();
|
||||
assertThat(firstRequestCount, greaterThanOrEqualTo(1));
|
||||
assertIdp1MetadataParsedCorrectly(tuple.v2().get());
|
||||
Thread.sleep(METADATA_REFRESH + 10);
|
||||
assertThat(proxyServer.requests().size(), greaterThan(firstRequestCount));
|
||||
assertBusy(() -> assertThat(proxyServer.requests().size(), greaterThan(firstRequestCount)));
|
||||
} finally {
|
||||
tuple.v1().destroy();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue