Add new property to switch the proxy auth configuration

This commit is contained in:
Laura Prieto
2026-07-23 17:27:48 +02:00
parent c11097cd8b
commit a3390a167e
13 changed files with 140 additions and 11 deletions

View File

@@ -0,0 +1,30 @@
package de.extio.lmlib.client;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class ProxyAuthorizationSupportTest {
@Test
void httpClientModeIsDefault() {
final var support = new ProxyAuthorizationSupport(ProxyAuthorizationSupport.MODE_HTTP_CLIENT, "login", "password");
assertTrue(support.isHttpClientMode());
assertFalse(support.isHeaderMode());
}
@Test
void headerModeIsEnabled() {
final var support = new ProxyAuthorizationSupport(ProxyAuthorizationSupport.MODE_HEADER, "login", "password");
assertTrue(support.isHeaderMode());
assertFalse(support.isHttpClientMode());
}
@Test
void encodesCredentials() {
assertEquals("bG9naW46cGFzc3dvcmQ=", ProxyAuthorizationSupport.encodeCredentials("login", "password"));
}
}

View File

@@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.TestPropertySource;
import org.springframework.web.client.RestClient;
import de.extio.lmlib.client.ProxyAuthorizationSupport;
import de.extio.lmlib.profile.ModelCategory;
import de.extio.lmlib.profile.ModelProfileService;
@@ -71,7 +72,7 @@ public class TokenizerTest {
@Disabled("Requires llama.cpp model profile")
@Test
void llamaServer() throws Exception {
final var tokenizer = new LlamaServerTokenizer(this.restClientBuilder);
final var tokenizer = new LlamaServerTokenizer(this.restClientBuilder, new ProxyAuthorizationSupport(ProxyAuthorizationSupport.MODE_HTTP_CLIENT, "", ""));
final var profile = this.modelProfileService.getModelProfile(ModelCategory.MEDIUM.getModelProfile());
assertEquals(21, tokenizer.count(TEXT, profile));