Skip to content

Commit e1f3179

Browse files
GutoVeroneziDaniel Augusto Veronezi Salvador
andauthored
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 <daniel@scclouds.com.br>
1 parent cc8bee7 commit e1f3179

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

plugins/ca/root-ca/src/test/java/org/apache/cloudstack/ca/provider/RootCAProviderTest.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.junit.Before;
4242
import org.junit.Test;
4343
import org.junit.runner.RunWith;
44+
import org.mockito.Mockito;
4445
import org.mockito.runners.MockitoJUnitRunner;
4546

4647
@RunWith(MockitoJUnitRunner.class)
@@ -57,12 +58,6 @@ private void addField(final RootCAProvider provider, final String name, final Ob
5758
f.set(provider, o);
5859
}
5960

60-
private void overrideDefaultConfigValue(final ConfigKey configKey, final String name, final Object o) throws IllegalAccessException, NoSuchFieldException {
61-
Field f = ConfigKey.class.getDeclaredField(name);
62-
f.setAccessible(true);
63-
f.set(configKey, o);
64-
}
65-
6661
@Before
6762
public void setUp() throws Exception {
6863
caKeyPair = CertUtils.generateRandomKeyPair(1024);
@@ -133,17 +128,17 @@ public void testRevokeCertificate() throws Exception {
133128

134129
@Test
135130
public void testCreateSSLEngineWithoutAuthStrictness() throws Exception {
136-
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "false");
131+
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
132+
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.FALSE);
137133
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
138-
Assert.assertFalse(e.getUseClientMode());
139134
Assert.assertFalse(e.getNeedClientAuth());
140135
}
141136

142137
@Test
143138
public void testCreateSSLEngineWithAuthStrictness() throws Exception {
144-
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "true");
139+
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
140+
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.TRUE);
145141
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
146-
Assert.assertFalse(e.getUseClientMode());
147142
Assert.assertTrue(e.getNeedClientAuth());
148143
}
149144

0 commit comments

Comments
 (0)