Skip to content

Commit 7be87f1

Browse files
Merge forward PR#4668 of Branch 4.13 on branch 4.14
2 parents 3b5f99a + e1f3179 commit 7be87f1

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

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

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

4649
@RunWith(MockitoJUnitRunner.class)
4750
public class RootCAProviderTest {
@@ -57,12 +60,6 @@ private void addField(final RootCAProvider provider, final String name, final Ob
5760
f.set(provider, o);
5861
}
5962

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-
6663
@Before
6764
public void setUp() throws Exception {
6865
caKeyPair = CertUtils.generateRandomKeyPair(1024);
@@ -133,14 +130,16 @@ public void testRevokeCertificate() throws Exception {
133130

134131
@Test
135132
public void testCreateSSLEngineWithoutAuthStrictness() throws Exception {
136-
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "false");
133+
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
134+
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.FALSE);
137135
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
138136
Assert.assertFalse(e.getNeedClientAuth());
139137
}
140138

141139
@Test
142140
public void testCreateSSLEngineWithAuthStrictness() throws Exception {
143-
overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "true");
141+
provider.rootCAAuthStrictness = Mockito.mock(ConfigKey.class);
142+
Mockito.when(provider.rootCAAuthStrictness.value()).thenReturn(Boolean.TRUE);
144143
final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
145144
Assert.assertTrue(e.getNeedClientAuth());
146145
}

0 commit comments

Comments
 (0)