mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge forward PR#4668 of Branch 4.14 on branch 4.15
This commit is contained in:
commit
569720fcc2
@ -41,7 +41,10 @@ import org.junit.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class RootCAProviderTest {
|
public class RootCAProviderTest {
|
||||||
@ -57,12 +60,6 @@ public class RootCAProviderTest {
|
|||||||
f.set(provider, o);
|
f.set(provider, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void overrideDefaultConfigValue(final ConfigKey configKey, final String name, final Object o) throws IllegalAccessException, NoSuchFieldException {
|
|
||||||
Field f = ConfigKey.class.getDeclaredField(name);
|
|
||||||
f.setAccessible(true);
|
|
||||||
f.set(configKey, o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
caKeyPair = CertUtils.generateRandomKeyPair(1024);
|
caKeyPair = CertUtils.generateRandomKeyPair(1024);
|
||||||
@ -133,14 +130,16 @@ public class RootCAProviderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSSLEngineWithoutAuthStrictness() throws Exception {
|
public void testCreateSSLEngineWithoutAuthStrictness() throws Exception {
|
||||||
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "false");
|
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
|
||||||
|
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.FALSE);
|
||||||
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
|
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
|
||||||
Assert.assertFalse(e.getNeedClientAuth());
|
Assert.assertFalse(e.getNeedClientAuth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSSLEngineWithAuthStrictness() throws Exception {
|
public void testCreateSSLEngineWithAuthStrictness() throws Exception {
|
||||||
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "true");
|
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
|
||||||
|
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.TRUE);
|
||||||
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
|
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
|
||||||
Assert.assertTrue(e.getNeedClientAuth());
|
Assert.assertTrue(e.getNeedClientAuth());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user