mask secrets in toString()
This commit is contained in:
parent
c484949be7
commit
b3a70729db
|
|
@ -1781,7 +1781,7 @@ public class HibernateEmbeddingStore<E> implements EmbeddingStore<TextSegment> {
|
|||
return "HibernateEmbeddingStore.DynamicBuilder(jdbcUrl=" + this.jdbcUrl
|
||||
+ ", databaseKind=" + this.databaseKind
|
||||
+ ", user=" + this.user
|
||||
+ ", password=" + this.password
|
||||
+ ", password=" + (this.password == null ? null : "********")
|
||||
+ ", table=" + this.table
|
||||
+ ", dimension=" + this.dimension
|
||||
+ ", createIndex=" + this.createIndex
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package dev.langchain4j.store.embedding.hibernate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void builder_toString_should_mask_password() {
|
||||
String toString =
|
||||
HibernateEmbeddingStore.dynamicBuilder().password("super-secret").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("super-secret").contains("password=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builder_toString_should_render_null_password_as_null() {
|
||||
String toString = HibernateEmbeddingStore.dynamicBuilder().toString();
|
||||
|
||||
assertThat(toString).contains("password=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ public class HuggingFaceEmbeddingModel extends DimensionAwareEmbeddingModel {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "HuggingFaceEmbeddingModel.HuggingFaceEmbeddingModelBuilder(baseUrl=" + this.baseUrl + ", accessToken=" + this.accessToken + ", modelId=" + this.modelId + ", waitForModel=" + this.waitForModel + ", timeout=" + this.timeout + ")";
|
||||
return "HuggingFaceEmbeddingModel.HuggingFaceEmbeddingModelBuilder(baseUrl=" + this.baseUrl + ", accessToken=" + (this.accessToken == null ? null : "********") + ", modelId=" + this.modelId + ", waitForModel=" + this.waitForModel + ", timeout=" + this.timeout + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package dev.langchain4j.model.huggingface;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HuggingFaceEmbeddingModelSecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void builder_toString_should_mask_access_token() {
|
||||
String toString =
|
||||
HuggingFaceEmbeddingModel.builder().accessToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("accessToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builder_toString_should_render_null_access_token_as_null() {
|
||||
String toString = HuggingFaceEmbeddingModel.builder().toString();
|
||||
|
||||
assertThat(toString).contains("accessToken=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ public class JlamaChatModel implements ChatModel {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "JlamaChatModel.JlamaChatModelBuilder(modelCachePath=" + this.modelCachePath + ", modelName=" + this.modelName + ", authToken=" + this.authToken + ", threadCount=" + this.threadCount + ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime + ", workingDirectory=" + this.workingDirectory + ", workingQuantizedType=" + this.workingQuantizedType + ", temperature=" + this.temperature + ", maxTokens=" + this.maxTokens + ")";
|
||||
return "JlamaChatModel.JlamaChatModelBuilder(modelCachePath=" + this.modelCachePath + ", modelName=" + this.modelName + ", authToken=" + (this.authToken == null ? null : "********") + ", threadCount=" + this.threadCount + ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime + ", workingDirectory=" + this.workingDirectory + ", workingQuantizedType=" + this.workingQuantizedType + ", temperature=" + this.temperature + ", maxTokens=" + this.maxTokens + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ public class JlamaEmbeddingModel extends DimensionAwareEmbeddingModel {
|
|||
|
||||
public String toString() {
|
||||
return "JlamaEmbeddingModel.JlamaEmbeddingModelBuilder(modelCachePath=" + this.modelCachePath
|
||||
+ ", modelName=" + this.modelName + ", authToken=" + this.authToken + ", threadCount="
|
||||
+ ", modelName=" + this.modelName + ", authToken=" + (this.authToken == null ? null : "********") + ", threadCount="
|
||||
+ this.threadCount + ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime + ", poolingType="
|
||||
+ this.poolingType + ", workingDirectory=" + this.workingDirectory + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public class JlamaLanguageModel implements LanguageModel {
|
|||
|
||||
public String toString() {
|
||||
return "JlamaLanguageModel.JlamaLanguageModelBuilder(modelCachePath=" + this.modelCachePath + ", modelName="
|
||||
+ this.modelName + ", authToken=" + this.authToken + ", threadCount=" + this.threadCount
|
||||
+ this.modelName + ", authToken=" + (this.authToken == null ? null : "********") + ", threadCount=" + this.threadCount
|
||||
+ ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime + ", workingDirectory="
|
||||
+ this.workingDirectory + ", workingQuantizedType=" + this.workingQuantizedType + ", temperature="
|
||||
+ this.temperature + ", maxTokens=" + this.maxTokens + ")";
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ public class JlamaStreamingChatModel implements StreamingChatModel {
|
|||
|
||||
public String toString() {
|
||||
return "JlamaStreamingChatModel.JlamaStreamingChatModelBuilder(modelCachePath=" + this.modelCachePath
|
||||
+ ", modelName=" + this.modelName + ", authToken=" + this.authToken + ", threadCount="
|
||||
+ ", modelName=" + this.modelName + ", authToken=" + (this.authToken == null ? null : "********") + ", threadCount="
|
||||
+ this.threadCount + ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime
|
||||
+ ", workingDirectory=" + this.workingDirectory + ", workingQuantizedType="
|
||||
+ this.workingQuantizedType + ", temperature=" + this.temperature + ", maxTokens=" + this.maxTokens
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class JlamaStreamingLanguageModel implements StreamingLanguageModel {
|
|||
|
||||
public String toString() {
|
||||
return "JlamaStreamingLanguageModel.JlamaStreamingLanguageModelBuilder(modelCachePath="
|
||||
+ this.modelCachePath + ", modelName=" + this.modelName + ", authToken=" + this.authToken
|
||||
+ this.modelCachePath + ", modelName=" + this.modelName + ", authToken=" + (this.authToken == null ? null : "********")
|
||||
+ ", threadCount=" + this.threadCount + ", quantizeModelAtRuntime=" + this.quantizeModelAtRuntime
|
||||
+ ", workingDirectory=" + this.workingDirectory + ", workingQuantizedType="
|
||||
+ this.workingQuantizedType + ", temperature=" + this.temperature + ", maxTokens=" + this.maxTokens
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
package dev.langchain4j.model.jlama;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void chatModelBuilder_toString_should_mask_auth_token() {
|
||||
String toString = JlamaChatModel.builder().authToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("authToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void chatModelBuilder_toString_should_render_null_auth_token_as_null() {
|
||||
assertThat(JlamaChatModel.builder().toString()).contains("authToken=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingChatModelBuilder_toString_should_mask_auth_token() {
|
||||
String toString =
|
||||
JlamaStreamingChatModel.builder().authToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("authToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingChatModelBuilder_toString_should_render_null_auth_token_as_null() {
|
||||
assertThat(JlamaStreamingChatModel.builder().toString()).contains("authToken=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void languageModelBuilder_toString_should_mask_auth_token() {
|
||||
String toString = JlamaLanguageModel.builder().authToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("authToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void languageModelBuilder_toString_should_render_null_auth_token_as_null() {
|
||||
assertThat(JlamaLanguageModel.builder().toString()).contains("authToken=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingLanguageModelBuilder_toString_should_mask_auth_token() {
|
||||
String toString =
|
||||
JlamaStreamingLanguageModel.builder().authToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("authToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingLanguageModelBuilder_toString_should_render_null_auth_token_as_null() {
|
||||
assertThat(JlamaStreamingLanguageModel.builder().toString()).contains("authToken=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddingModelBuilder_toString_should_mask_auth_token() {
|
||||
String toString = JlamaEmbeddingModel.builder().authToken("secret-token").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-token").contains("authToken=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void embeddingModelBuilder_toString_should_render_null_auth_token_as_null() {
|
||||
assertThat(JlamaEmbeddingModel.builder().toString()).contains("authToken=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ class NomicClient {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "NomicClient.NomicClientBuilder(baseUrl=" + this.baseUrl + ", apiKey=" + this.apiKey + ", timeout=" + this.timeout + ", logRequests=" + this.logRequests + ", logResponses=" + this.logResponses + ")";
|
||||
return "NomicClient.NomicClientBuilder(baseUrl=" + this.baseUrl + ", apiKey=" + (this.apiKey == null ? null : "********") + ", timeout=" + this.timeout + ", logRequests=" + this.logRequests + ", logResponses=" + this.logResponses + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package dev.langchain4j.model.nomic;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class NomicClientSecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void builder_toString_should_mask_api_key() {
|
||||
String toString = NomicClient.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = NomicClient.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -897,7 +897,7 @@ public class PgVectorEmbeddingStore implements EmbeddingStore<TextSegment> {
|
|||
|
||||
public String toString() {
|
||||
return "PgVectorEmbeddingStore.PgVectorEmbeddingStoreBuilder(host=" + this.host + ", port=" + this.port
|
||||
+ ", user=" + this.user + ", password=" + this.password + ", database=" + this.database + ", table="
|
||||
+ ", user=" + this.user + ", password=" + (this.password == null ? null : "********") + ", database=" + this.database + ", table="
|
||||
+ this.table + ", dimension=" + this.dimension + ", useIndex=" + this.useIndex + ", indexListSize="
|
||||
+ this.indexListSize + ", createTable=" + this.createTable + ", dropTableFirst="
|
||||
+ this.dropTableFirst + ", skipCreateVectorExtension=" + this.skipCreateVectorExtension
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package dev.langchain4j.store.embedding.pgvector;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void builder_toString_should_mask_password() {
|
||||
String toString =
|
||||
PgVectorEmbeddingStore.builder().password("super-secret").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("super-secret").contains("password=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builder_toString_should_render_null_password_as_null() {
|
||||
String toString = PgVectorEmbeddingStore.builder().toString();
|
||||
|
||||
assertThat(toString).contains("password=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -543,7 +543,7 @@ public class WeaviateEmbeddingStore implements EmbeddingStore<TextSegment> {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "WeaviateEmbeddingStore.WeaviateEmbeddingStoreBuilder(apiKey=" + this.apiKey + ", scheme="
|
||||
return "WeaviateEmbeddingStore.WeaviateEmbeddingStoreBuilder(apiKey=" + (this.apiKey == null ? null : "********") + ", scheme="
|
||||
+ this.scheme + ", host=" + this.host + ", port=" + this.port + ", useGrpcForInserts="
|
||||
+ this.useGrpcForInserts + ", securedGrpc=" + this.securedGrpc + ", grpcPort=" + this.grpcPort
|
||||
+ ", objectClass=" + this.objectClass + ", avoidDups=" + this.avoidDups + ", consistencyLevel="
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package dev.langchain4j.store.embedding.weaviate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void builder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
WeaviateEmbeddingStore.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = WeaviateEmbeddingStore.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ class GoogleCustomSearchApiClient {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "GoogleCustomSearchApiClient.GoogleCustomSearchApiClientBuilder(apiKey=" + this.apiKey + ", csi=" + this.csi + ", siteRestrict=" + this.siteRestrict + ", timeout=" + this.timeout + ", maxRetries=" + this.maxRetries + ", logRequests=" + this.logRequests + ", logResponses=" + this.logResponses + ")";
|
||||
return "GoogleCustomSearchApiClient.GoogleCustomSearchApiClientBuilder(apiKey=" + (this.apiKey == null ? null : "********") + ", csi=" + this.csi + ", siteRestrict=" + this.siteRestrict + ", timeout=" + this.timeout + ", maxRetries=" + this.maxRetries + ", logRequests=" + this.logRequests + ", logResponses=" + this.logResponses + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ public class GoogleCustomWebSearchEngine implements WebSearchEngine {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "GoogleCustomWebSearchEngine.GoogleCustomWebSearchEngineBuilder(apiKey=" + this.apiKey + ", csi="
|
||||
return "GoogleCustomWebSearchEngine.GoogleCustomWebSearchEngineBuilder(apiKey=" + (this.apiKey == null ? null : "********") + ", csi="
|
||||
+ this.csi + ", siteRestrict=" + this.siteRestrict + ", includeImages=" + this.includeImages
|
||||
+ ", timeout=" + this.timeout + ", maxRetries=" + this.maxRetries + ", logRequests="
|
||||
+ this.logRequests + ", logResponses=" + this.logResponses + ")";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package dev.langchain4j.web.search.google.customsearch;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void apiClientBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
GoogleCustomSearchApiClient.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void apiClientBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = GoogleCustomSearchApiClient.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
GoogleCustomWebSearchEngine.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = GoogleCustomWebSearchEngine.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ public class SearchApiWebSearchEngine implements WebSearchEngine {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "SearchApiWebSearchEngine.SearchApiWebSearchEngineBuilder(apiKey=" + this.apiKey + ", baseUrl="
|
||||
return "SearchApiWebSearchEngine.SearchApiWebSearchEngineBuilder(apiKey=" + (this.apiKey == null ? null : "********") + ", baseUrl="
|
||||
+ this.baseUrl + ", timeout=" + this.timeout + ", engine=" + this.engine + ", optionalParameters="
|
||||
+ this.optionalParameters + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class SearchApiWebSearchRequest {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "SearchApiWebSearchRequest.SearchApiWebSearchRequestBuilder(engine=" + this.engine + ", apiKey=" + this.apiKey + ", query=" + this.query + ", optionalParameters=" + this.optionalParameters + ", additionalRequestParameters=" + this.additionalRequestParameters + ")";
|
||||
return "SearchApiWebSearchRequest.SearchApiWebSearchRequestBuilder(engine=" + this.engine + ", apiKey=" + (this.apiKey == null ? null : "********") + ", query=" + this.query + ", optionalParameters=" + this.optionalParameters + ", additionalRequestParameters=" + this.additionalRequestParameters + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package dev.langchain4j.web.search.searchapi;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
SearchApiWebSearchEngine.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = SearchApiWebSearchEngine.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
SearchApiWebSearchRequest.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = SearchApiWebSearchRequest.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ class TavilySearchRequest {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "TavilySearchRequest.TavilySearchRequestBuilder(apiKey=" + this.apiKey + ", query=" + this.query + ", searchDepth=" + this.searchDepth + ", includeAnswer=" + this.includeAnswer + ", includeRawContent=" + this.includeRawContent + ", maxResults=" + this.maxResults + ", includeDomains=" + this.includeDomains + ", excludeDomains=" + this.excludeDomains + ")";
|
||||
return "TavilySearchRequest.TavilySearchRequestBuilder(apiKey=" + (this.apiKey == null ? null : "********") + ", query=" + this.query + ", searchDepth=" + this.searchDepth + ", includeAnswer=" + this.includeAnswer + ", includeRawContent=" + this.includeRawContent + ", maxResults=" + this.maxResults + ", includeDomains=" + this.includeDomains + ", excludeDomains=" + this.excludeDomains + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ public class TavilyWebSearchEngine implements WebSearchEngine {
|
|||
|
||||
public String toString() {
|
||||
return "TavilyWebSearchEngine.TavilyWebSearchEngineBuilder(baseUrl=" + this.baseUrl + ", apiKey="
|
||||
+ this.apiKey + ", timeout=" + this.timeout + ", searchDepth=" + this.searchDepth
|
||||
+ (this.apiKey == null ? null : "********") + ", timeout=" + this.timeout + ", searchDepth=" + this.searchDepth
|
||||
+ ", includeAnswer=" + this.includeAnswer + ", includeRawContent=" + this.includeRawContent
|
||||
+ ", includeDomains=" + this.includeDomains + ", excludeDomains=" + this.excludeDomains + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package dev.langchain4j.web.search.tavily;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SecretMaskingTest {
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
TavilyWebSearchEngine.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void engineBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = TavilyWebSearchEngine.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestBuilder_toString_should_mask_api_key() {
|
||||
String toString =
|
||||
TavilySearchRequest.builder().apiKey("secret-api-key").toString();
|
||||
|
||||
assertThat(toString).doesNotContain("secret-api-key").contains("apiKey=********");
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestBuilder_toString_should_render_null_api_key_as_null() {
|
||||
String toString = TavilySearchRequest.builder().toString();
|
||||
|
||||
assertThat(toString).contains("apiKey=null");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue