use of org.mockserver.configuration.Configuration in project mockserver by mock-server.
the class CustomKeyAndCertificateFactorySupplierTest method setServerModifier_shouldBeCalled.
@Test
public void setServerModifier_shouldBeCalled() {
final AtomicBoolean customizerCallFlag = new AtomicBoolean(false);
NettySslContextFactory.sslServerContextBuilderCustomizer = builder -> {
customizerCallFlag.set(true);
return builder;
};
new NettySslContextFactory(new Configuration(), mock(MockServerLogger.class), true).createServerSslContext();
assertTrue(customizerCallFlag.get());
}
use of org.mockserver.configuration.Configuration in project mockserver by mock-server.
the class CustomKeyAndCertificateFactorySupplierTest method shouldReturnCustomFactory.
@Test
public void shouldReturnCustomFactory() {
BiFunction<MockServerLogger, Boolean, KeyAndCertificateFactory> originalCustomKeyAndCertificateFactorySupplier = KeyAndCertificateFactoryFactory.getCustomKeyAndCertificateFactorySupplier();
// given
Configuration configuration = configuration();
MockServerLogger mockServerLogger = new MockServerLogger();
KeyAndCertificateFactory factoryInstance = new KeyAndCertificateFactory() {
@Override
public void buildAndSaveCertificateAuthorityPrivateKeyAndX509Certificate() {
}
@Override
public void buildAndSavePrivateKeyAndX509Certificate() {
}
@Override
public boolean certificateNotYetCreated() {
return false;
}
@Override
public PrivateKey privateKey() {
return null;
}
@Override
public X509Certificate x509Certificate() {
return null;
}
@Override
public X509Certificate certificateAuthorityX509Certificate() {
return null;
}
@Override
public List<X509Certificate> certificateChain() {
return null;
}
};
try {
// when
KeyAndCertificateFactoryFactory.setCustomKeyAndCertificateFactorySupplier((logger, isServer) -> factoryInstance);
// then
assertThat(KeyAndCertificateFactoryFactory.createKeyAndCertificateFactory(configuration, mockServerLogger), equalTo(factoryInstance));
} finally {
KeyAndCertificateFactoryFactory.setCustomKeyAndCertificateFactorySupplier(originalCustomKeyAndCertificateFactorySupplier);
}
}
use of org.mockserver.configuration.Configuration in project mockserver by mock-server.
the class CustomKeyAndCertificateFactorySupplierTest method setClientModifier_shouldBeCalled.
@Test
public void setClientModifier_shouldBeCalled() {
final AtomicBoolean customizerCallFlag = new AtomicBoolean(false);
NettySslContextFactory.sslClientContextBuilderCustomizer = builder -> {
customizerCallFlag.set(true);
return builder;
};
new NettySslContextFactory(new Configuration(), mock(MockServerLogger.class), false).createClientSslContext(false);
assertTrue(customizerCallFlag.get());
}
Aggregations