From e1f3179446529da3683154c044b15f277d0d7eab Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Date: Thu, 25 Feb 2021 20:28:11 -0300 Subject: [PATCH] Adjust tests to fix a problem with the container builders (https://github.com/khos2ow/cloudstack-deb-builder) (#4668) * Changes to allow builders containers to build ACS Co-authored-by: Daniel Augusto Veronezi Salvador --- .../ca/provider/RootCAProviderTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/ca/root-ca/src/test/java/org/apache/cloudstack/ca/provider/RootCAProviderTest.java b/plugins/ca/root-ca/src/test/java/org/apache/cloudstack/ca/provider/RootCAProviderTest.java index d5d64289da2..1f16360786c 100644 --- a/plugins/ca/root-ca/src/test/java/org/apache/cloudstack/ca/provider/RootCAProviderTest.java +++ b/plugins/ca/root-ca/src/test/java/org/apache/cloudstack/ca/provider/RootCAProviderTest.java @@ -41,6 +41,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) @@ -57,12 +58,6 @@ public class RootCAProviderTest { 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 public void setUp() throws Exception { caKeyPair = CertUtils.generateRandomKeyPair(1024); @@ -133,17 +128,17 @@ public class RootCAProviderTest { @Test 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); - Assert.assertFalse(e.getUseClientMode()); Assert.assertFalse(e.getNeedClientAuth()); } @Test 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); - Assert.assertFalse(e.getUseClientMode()); Assert.assertTrue(e.getNeedClientAuth()); }