From 4662ee7fe1296c80d248583488116e24b2345e9c Mon Sep 17 00:00:00 2001 From: Bilal Al-Shahwany Date: Tue, 1 Jul 2025 08:22:48 -0700 Subject: [PATCH 1/2] Fixed config property and test --- .../io/split/client/SplitClientConfig.java | 4 ++-- .../java/io/split/client/SplitFactoryImpl.java | 4 ++-- .../io/split/client/SplitClientConfigTest.java | 8 ++++---- .../io/split/client/SplitFactoryImplTest.java | 18 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index ef798847..ef75b2cc 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -314,7 +314,7 @@ public String proxyPassword() { return _proxyPassword; } - public ProxyRuntimeProvider proxyRuntimeStorage() { + public ProxyRuntimeProvider proxyRuntimeProvider() { return _proxyRuntimeProvider; } @@ -816,7 +816,7 @@ public Builder proxyPassword(String proxyPassword) { * @param proxyRuntimeProvider * @return this builder */ - public Builder proxyRuntimeStorage(ProxyRuntimeProvider proxyRuntimeProvider) { + public Builder proxyRuntimeProvider(ProxyRuntimeProvider proxyRuntimeProvider) { _proxyRuntimeProvider = proxyRuntimeProvider; return this; } diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 64874c36..13d925ad 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -634,9 +634,9 @@ private static HttpClientBuilder setupProxy(HttpClientBuilder httpClientbuilder, httpClientbuilder.setDefaultCredentialsProvider(credsProvider); } - if (config.proxyRuntimeStorage() != null) { + if (config.proxyRuntimeProvider() != null) { _log.debug("Proxy setup using token"); - httpClientbuilder.setDefaultCredentialsProvider(new HttpClientDynamicCredentials(config.proxyRuntimeStorage())); + httpClientbuilder.setDefaultCredentialsProvider(new HttpClientDynamicCredentials(config.proxyRuntimeProvider())); } return httpClientbuilder; diff --git a/client/src/test/java/io/split/client/SplitClientConfigTest.java b/client/src/test/java/io/split/client/SplitClientConfigTest.java index 25de5498..f72fb84f 100644 --- a/client/src/test/java/io/split/client/SplitClientConfigTest.java +++ b/client/src/test/java/io/split/client/SplitClientConfigTest.java @@ -283,9 +283,9 @@ public String getJwtToken() { config = SplitClientConfig.builder() .proxyHost("proxy-host") .proxyPort(8888) - .proxyRuntimeStorage(proxyRuntimeProvider) + .proxyRuntimeProvider(proxyRuntimeProvider) .build(); - Assert.assertEquals(proxyRuntimeProvider, config.proxyRuntimeStorage()); + Assert.assertEquals(proxyRuntimeProvider, config.proxyRuntimeProvider()); config = SplitClientConfig.builder() .proxyHost("proxy-host") @@ -319,7 +319,7 @@ public String getJwtToken() { .proxyPort(8888) .proxyUsername("user") .proxyPassword("pass") - .proxyRuntimeStorage(proxyRuntimeProvider) + .proxyRuntimeProvider(proxyRuntimeProvider) .build(); } @@ -346,7 +346,7 @@ public String getJwtToken() { SplitClientConfig.builder() .proxyHost("proxy-host") .proxyPort(8888) - .proxyRuntimeStorage(proxyRuntimeProvider) + .proxyRuntimeProvider(proxyRuntimeProvider) .proxyMtlsAuth(new ProxyMTLSAuth.Builder().proxyP12File("path/to/file").proxyP12FilePassKey("pass-key").build()) .build(); } diff --git a/client/src/test/java/io/split/client/SplitFactoryImplTest.java b/client/src/test/java/io/split/client/SplitFactoryImplTest.java index 008df7f4..072eed25 100644 --- a/client/src/test/java/io/split/client/SplitFactoryImplTest.java +++ b/client/src/test/java/io/split/client/SplitFactoryImplTest.java @@ -151,10 +151,10 @@ public void testFactoryInstantiationWithProxyCredentials() throws Exception { splitFactory.destroy(); } -/* + @Test public void testFactoryInstantiationWithProxyToken() throws Exception { - class MyProxyRuntimeStorage implements ProxyRuntimeStorage { + class MyProxyRuntimeProvider implements ProxyRuntimeProvider { @Override public String getJwtToken() { return "123456789"; @@ -170,7 +170,7 @@ public String getJwtToken() { .authServiceURL(AUTH_SERVICE) .setBlockUntilReadyTimeout(1000) .proxyPort(6060) - .proxyRuntimeStorage(new MyProxyRuntimeStorage()) + .proxyRuntimeProvider(new MyProxyRuntimeProvider()) .proxyHost(ENDPOINT) .build(); SplitFactoryImpl splitFactory2 = new SplitFactoryImpl(API_KEY, splitClientConfig); @@ -187,17 +187,17 @@ public String getJwtToken() { Field credentialsProviderField2 = InternalHttp2.getDeclaredField("credentialsProvider"); credentialsProviderField2.setAccessible(true); - BasicCredentialsProvider credentialsProvider2 = (BasicCredentialsProvider) credentialsProviderField2.get(InternalHttp2.cast(httpClientField2.get(client2))); + HttpClientDynamicCredentials credentialsProvider2 = (HttpClientDynamicCredentials) credentialsProviderField2.get(InternalHttp2.cast(httpClientField2.get(client2))); - Field credMapField2 = BasicCredentialsProvider.class.getDeclaredField("credMap"); - credMapField2.setAccessible(true); - ConcurrentHashMap credMap2 = (ConcurrentHashMap) credMapField2.get(credentialsProvider2); + Field proxyRuntimeField = HttpClientDynamicCredentials.class.getDeclaredField("_proxyRuntimeProvider"); + proxyRuntimeField.setAccessible(true); + MyProxyRuntimeProvider proxyRuntime = (MyProxyRuntimeProvider) proxyRuntimeField.get(credentialsProvider2); - Assert.assertEquals("123456789", credMap2.entrySet().stream().iterator().next().getValue().getToken()); + assertNotNull("123456789", proxyRuntime.getJwtToken()); splitFactory2.destroy(); } -*/ + @Test public void testFactoryInstantiationWithProxyMtls() throws Exception { SplitClientConfig splitClientConfig = SplitClientConfig.builder() From 61fe715491fb14ef91aa55aabc16fa82192c188f Mon Sep 17 00:00:00 2001 From: Bilal Al-Shahwany Date: Tue, 1 Jul 2025 08:54:01 -0700 Subject: [PATCH 2/2] Rename config field --- .../client/HttpClientDynamicCredentials.java | 8 +- ...der.java => ProxyCredentialsProvider.java} | 2 +- .../io/split/client/SplitClientConfig.java | 26 +- .../io/split/client/SplitFactoryImpl.java | 4 +- .../split/client/SplitClientConfigTest.java | 14 +- .../io/split/client/SplitFactoryImplTest.java | 10 +- testing/.github/CODEOWNERS | 1 + .../linter/checkstyle-suppressions.xml | 9 + testing/.github/linter/google-java-style.xml | 380 ++++++++++++++++++ 9 files changed, 421 insertions(+), 33 deletions(-) rename client/src/main/java/io/split/client/{ProxyRuntimeProvider.java => ProxyCredentialsProvider.java} (81%) create mode 100644 testing/.github/CODEOWNERS create mode 100644 testing/.github/linter/checkstyle-suppressions.xml create mode 100644 testing/.github/linter/google-java-style.xml diff --git a/client/src/main/java/io/split/client/HttpClientDynamicCredentials.java b/client/src/main/java/io/split/client/HttpClientDynamicCredentials.java index bdf0cff8..01a32362 100644 --- a/client/src/main/java/io/split/client/HttpClientDynamicCredentials.java +++ b/client/src/main/java/io/split/client/HttpClientDynamicCredentials.java @@ -7,10 +7,10 @@ class HttpClientDynamicCredentials implements org.apache.hc.client5.http.auth.CredentialsProvider { - private final ProxyRuntimeProvider _proxyRuntimeProvider; + private final ProxyCredentialsProvider _proxyCredentialsProvider; - public HttpClientDynamicCredentials (ProxyRuntimeProvider proxyRuntimeProvider) { - _proxyRuntimeProvider = proxyRuntimeProvider; + public HttpClientDynamicCredentials (ProxyCredentialsProvider proxyCredentialsProvider) { + _proxyCredentialsProvider = proxyCredentialsProvider; } @Override @@ -18,7 +18,7 @@ public Credentials getCredentials(AuthScope authScope, HttpContext context) { // This Provider is invoked every time a request is made. // This should invoke a user-custom provider responsible for: - return new BearerToken(_proxyRuntimeProvider.getJwtToken()); + return new BearerToken(_proxyCredentialsProvider.getJwtToken()); } } diff --git a/client/src/main/java/io/split/client/ProxyRuntimeProvider.java b/client/src/main/java/io/split/client/ProxyCredentialsProvider.java similarity index 81% rename from client/src/main/java/io/split/client/ProxyRuntimeProvider.java rename to client/src/main/java/io/split/client/ProxyCredentialsProvider.java index ca30c7f2..6fb595bc 100644 --- a/client/src/main/java/io/split/client/ProxyRuntimeProvider.java +++ b/client/src/main/java/io/split/client/ProxyCredentialsProvider.java @@ -1,6 +1,6 @@ package io.split.client; -public interface ProxyRuntimeProvider +public interface ProxyCredentialsProvider { /** * Get the additional headers needed for all http operations diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index ef75b2cc..603d5ef1 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -91,7 +91,7 @@ public static class HttpScheme { private final HttpHost _proxy; private final String _proxyUsername; private final String _proxyPassword; - private final ProxyRuntimeProvider _proxyRuntimeProvider; + private final ProxyCredentialsProvider _proxyCredentialsProvider; private final ProxyMTLSAuth _proxyMtlsAuth; // To be set during startup @@ -126,7 +126,7 @@ private SplitClientConfig(String endpoint, HttpHost proxy, String proxyUsername, String proxyPassword, - ProxyRuntimeProvider proxyRuntimeProvider, + ProxyCredentialsProvider proxyCredentialsProvider, ProxyMTLSAuth proxyMtlsAuth, int eventsQueueSize, long eventSendIntervalInMillis, @@ -181,7 +181,7 @@ private SplitClientConfig(String endpoint, _proxy = proxy; _proxyUsername = proxyUsername; _proxyPassword = proxyPassword; - _proxyRuntimeProvider = proxyRuntimeProvider; + _proxyCredentialsProvider = proxyCredentialsProvider; _proxyMtlsAuth = proxyMtlsAuth; _eventsQueueSize = eventsQueueSize; _eventSendIntervalInMillis = eventSendIntervalInMillis; @@ -314,8 +314,8 @@ public String proxyPassword() { return _proxyPassword; } - public ProxyRuntimeProvider proxyRuntimeProvider() { - return _proxyRuntimeProvider; + public ProxyCredentialsProvider proxyCredentialsProvider() { + return _proxyCredentialsProvider; } public ProxyMTLSAuth proxyMTLSAuth() { @@ -463,7 +463,7 @@ public static final class Builder { private String _proxyScheme = HttpScheme.HTTP; private String _proxyUsername; private String _proxyPassword; - private ProxyRuntimeProvider _proxyRuntimeProvider; + private ProxyCredentialsProvider _proxyCredentialsProvider; private ProxyMTLSAuth _proxyMtlsAuth; private int _eventsQueueSize = 500; private long _eventSendIntervalInMillis = 30 * (long)1000; @@ -813,11 +813,11 @@ public Builder proxyPassword(String proxyPassword) { /** * Set the token for authentication against the proxy (if proxy settings are enabled). (Optional). * - * @param proxyRuntimeProvider + * @param proxyCredentialsProvider * @return this builder */ - public Builder proxyRuntimeProvider(ProxyRuntimeProvider proxyRuntimeProvider) { - _proxyRuntimeProvider = proxyRuntimeProvider; + public Builder proxyCredentialsProvider(ProxyCredentialsProvider proxyCredentialsProvider) { + _proxyCredentialsProvider = proxyCredentialsProvider; return this; } @@ -1161,11 +1161,11 @@ private void verifyProxy() { throw new IllegalArgumentException("Proxy scheme must be either http or https."); } - if (_proxyUsername == null && _proxyRuntimeProvider == null && _proxyMtlsAuth == null) { + if (_proxyUsername == null && _proxyCredentialsProvider == null && _proxyMtlsAuth == null) { return; } - if (_proxyUsername != null && _proxyRuntimeProvider != null) { + if (_proxyUsername != null && _proxyCredentialsProvider != null) { throw new IllegalArgumentException("Proxy user and Proxy token params are updated, set only one param."); } @@ -1173,7 +1173,7 @@ private void verifyProxy() { throw new IllegalArgumentException("Proxy user and Proxy mTLS params are updated, set only one param."); } - if (_proxyRuntimeProvider != null && _proxyMtlsAuth != null) { + if (_proxyCredentialsProvider != null && _proxyMtlsAuth != null) { throw new IllegalArgumentException("Proxy token and Proxy mTLS params are updated, set only one param."); } @@ -1223,7 +1223,7 @@ public SplitClientConfig build() { proxy(), _proxyUsername, _proxyPassword, - _proxyRuntimeProvider, + _proxyCredentialsProvider, _proxyMtlsAuth, _eventsQueueSize, _eventSendIntervalInMillis, diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 13d925ad..4da2f503 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -634,9 +634,9 @@ private static HttpClientBuilder setupProxy(HttpClientBuilder httpClientbuilder, httpClientbuilder.setDefaultCredentialsProvider(credsProvider); } - if (config.proxyRuntimeProvider() != null) { + if (config.proxyCredentialsProvider() != null) { _log.debug("Proxy setup using token"); - httpClientbuilder.setDefaultCredentialsProvider(new HttpClientDynamicCredentials(config.proxyRuntimeProvider())); + httpClientbuilder.setDefaultCredentialsProvider(new HttpClientDynamicCredentials(config.proxyCredentialsProvider())); } return httpClientbuilder; diff --git a/client/src/test/java/io/split/client/SplitClientConfigTest.java b/client/src/test/java/io/split/client/SplitClientConfigTest.java index f72fb84f..81ad9913 100644 --- a/client/src/test/java/io/split/client/SplitClientConfigTest.java +++ b/client/src/test/java/io/split/client/SplitClientConfigTest.java @@ -273,7 +273,7 @@ public void checkProxyParams() { Assert.assertEquals("user", config.proxyUsername()); Assert.assertEquals("pass", config.proxyPassword()); - ProxyRuntimeProvider proxyRuntimeProvider = new ProxyRuntimeProvider() { + ProxyCredentialsProvider proxyCredentialsProvider = new ProxyCredentialsProvider() { @Override public String getJwtToken() { return "my-token"; @@ -283,9 +283,9 @@ public String getJwtToken() { config = SplitClientConfig.builder() .proxyHost("proxy-host") .proxyPort(8888) - .proxyRuntimeProvider(proxyRuntimeProvider) + .proxyCredentialsProvider(proxyCredentialsProvider) .build(); - Assert.assertEquals(proxyRuntimeProvider, config.proxyRuntimeProvider()); + Assert.assertEquals(proxyCredentialsProvider, config.proxyCredentialsProvider()); config = SplitClientConfig.builder() .proxyHost("proxy-host") @@ -307,7 +307,7 @@ public void cannotUseInvalidHttpScheme() { @Test(expected = IllegalArgumentException.class) public void cannotUseProxyTokenAndProxyUsername() { - ProxyRuntimeProvider proxyRuntimeProvider = new ProxyRuntimeProvider() { + ProxyCredentialsProvider proxyCredentialsProvider = new ProxyCredentialsProvider() { @Override public String getJwtToken() { return "my-token"; @@ -319,7 +319,7 @@ public String getJwtToken() { .proxyPort(8888) .proxyUsername("user") .proxyPassword("pass") - .proxyRuntimeProvider(proxyRuntimeProvider) + .proxyCredentialsProvider(proxyCredentialsProvider) .build(); } @@ -336,7 +336,7 @@ public void cannotUseProxyUserAndProxyMtls() { @Test(expected = IllegalArgumentException.class) public void cannotUseProxyTokenAndProxyMtls() { - ProxyRuntimeProvider proxyRuntimeProvider = new ProxyRuntimeProvider() { + ProxyCredentialsProvider proxyCredentialsProvider = new ProxyCredentialsProvider() { @Override public String getJwtToken() { return "my-token"; @@ -346,7 +346,7 @@ public String getJwtToken() { SplitClientConfig.builder() .proxyHost("proxy-host") .proxyPort(8888) - .proxyRuntimeProvider(proxyRuntimeProvider) + .proxyCredentialsProvider(proxyCredentialsProvider) .proxyMtlsAuth(new ProxyMTLSAuth.Builder().proxyP12File("path/to/file").proxyP12FilePassKey("pass-key").build()) .build(); } diff --git a/client/src/test/java/io/split/client/SplitFactoryImplTest.java b/client/src/test/java/io/split/client/SplitFactoryImplTest.java index 072eed25..1214b246 100644 --- a/client/src/test/java/io/split/client/SplitFactoryImplTest.java +++ b/client/src/test/java/io/split/client/SplitFactoryImplTest.java @@ -11,7 +11,6 @@ import io.split.telemetry.synchronizer.TelemetrySynchronizer; import junit.framework.TestCase; import org.apache.hc.client5.http.auth.AuthScope; -import org.apache.hc.client5.http.auth.BearerToken; import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; import org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator; @@ -21,7 +20,6 @@ import org.apache.hc.core5.http.config.Registry; import org.awaitility.Awaitility; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; import static org.mockito.Mockito.when; @@ -154,7 +152,7 @@ public void testFactoryInstantiationWithProxyCredentials() throws Exception { @Test public void testFactoryInstantiationWithProxyToken() throws Exception { - class MyProxyRuntimeProvider implements ProxyRuntimeProvider { + class MyProxyCredentialsProvider implements ProxyCredentialsProvider { @Override public String getJwtToken() { return "123456789"; @@ -170,7 +168,7 @@ public String getJwtToken() { .authServiceURL(AUTH_SERVICE) .setBlockUntilReadyTimeout(1000) .proxyPort(6060) - .proxyRuntimeProvider(new MyProxyRuntimeProvider()) + .proxyCredentialsProvider(new MyProxyCredentialsProvider()) .proxyHost(ENDPOINT) .build(); SplitFactoryImpl splitFactory2 = new SplitFactoryImpl(API_KEY, splitClientConfig); @@ -189,9 +187,9 @@ public String getJwtToken() { credentialsProviderField2.setAccessible(true); HttpClientDynamicCredentials credentialsProvider2 = (HttpClientDynamicCredentials) credentialsProviderField2.get(InternalHttp2.cast(httpClientField2.get(client2))); - Field proxyRuntimeField = HttpClientDynamicCredentials.class.getDeclaredField("_proxyRuntimeProvider"); + Field proxyRuntimeField = HttpClientDynamicCredentials.class.getDeclaredField("_proxyCredentialsProvider"); proxyRuntimeField.setAccessible(true); - MyProxyRuntimeProvider proxyRuntime = (MyProxyRuntimeProvider) proxyRuntimeField.get(credentialsProvider2); + MyProxyCredentialsProvider proxyRuntime = (MyProxyCredentialsProvider) proxyRuntimeField.get(credentialsProvider2); assertNotNull("123456789", proxyRuntime.getJwtToken()); diff --git a/testing/.github/CODEOWNERS b/testing/.github/CODEOWNERS new file mode 100644 index 00000000..9e319810 --- /dev/null +++ b/testing/.github/CODEOWNERS @@ -0,0 +1 @@ +* @splitio/sdk diff --git a/testing/.github/linter/checkstyle-suppressions.xml b/testing/.github/linter/checkstyle-suppressions.xml new file mode 100644 index 00000000..81d23539 --- /dev/null +++ b/testing/.github/linter/checkstyle-suppressions.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/testing/.github/linter/google-java-style.xml b/testing/.github/linter/google-java-style.xml new file mode 100644 index 00000000..e885305e --- /dev/null +++ b/testing/.github/linter/google-java-style.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file