Search in sources :

Example 1 with QueuedExecutor

use of io.grpc.xds.internal.certprovider.CertProviderClientSslContextProviderTest.QueuedExecutor in project grpc-java by grpc.

the class CertProviderServerSslContextProviderTest method testProviderForServer_queueExecutor.

@Test
public void testProviderForServer_queueExecutor() throws Exception {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
    TestCertificateProvider.createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    CertProviderServerSslContextProvider provider = getSslContextProvider("gcp_id", "gcp_id", CommonBootstrapperTestUtils.getTestBootstrapInfo(), /* alpnProtocols= */
    null, /* staticCertValidationContext= */
    null, /* requireClientCert= */
    true);
    QueuedExecutor queuedExecutor = new QueuedExecutor();
    TestCallback testCallback = CommonTlsContextTestsUtil.getValueThruCallback(provider, queuedExecutor);
    assertThat(queuedExecutor.runQueue).isEmpty();
    // now generate cert update
    watcherCaptor[0].updateCertificate(CommonCertProviderTestUtils.getPrivateKey(SERVER_0_KEY_FILE), ImmutableList.of(getCertFromResourceName(SERVER_0_PEM_FILE)));
    // still empty
    assertThat(queuedExecutor.runQueue).isEmpty();
    // now generate root cert update
    watcherCaptor[0].updateTrustedRoots(ImmutableList.of(getCertFromResourceName(CA_PEM_FILE)));
    assertThat(queuedExecutor.runQueue).hasSize(1);
    queuedExecutor.drain();
    doChecksOnSslContext(true, testCallback.updatedSslContext, /* expectedApnProtos= */
    null);
}
Also used : QueuedExecutor(io.grpc.xds.internal.certprovider.CertProviderClientSslContextProviderTest.QueuedExecutor) TestCallback(io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.TestCallback) Test(org.junit.Test)

Aggregations

QueuedExecutor (io.grpc.xds.internal.certprovider.CertProviderClientSslContextProviderTest.QueuedExecutor)1 TestCallback (io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.TestCallback)1 Test (org.junit.Test)1