Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.conscrypt</groupId>
<artifactId>conscrypt-openjdk-uber</artifactId>
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<!-- jspecify -->
<dependency>
<groupId>org.jspecify</groupId>
Expand Down Expand Up @@ -672,6 +678,24 @@
</testExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/private/java</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/com/google/genai/HttpApiClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.mockito.Mockito.*;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
Expand Down Expand Up @@ -1717,4 +1718,37 @@ public void testCloseClient() {
assertTrue(((ExecutorService) client.interactionsClientOptions.streamHandlerExecutor()).isShutdown());
}
}

// @Test
// @SuppressWarnings("unchecked")
// public void testSendSecureRequest_includesRequestTtl() throws Exception {
// // Arrange
// HttpApiClient client =
// new HttpApiClient(Optional.of(API_KEY), Optional.empty(), Optional.empty());
// SecureSessionConnection mockConnection = Mockito.mock(SecureSessionConnection.class);

// // Put mock connection into activeSecureSessions
// Field sessionsField = ApiClient.class.getDeclaredField("activeSecureSessions");
// sessionsField.setAccessible(true);
// Map<String, SecureSessionConnection> sessions =
// (Map<String, SecureSessionConnection>) sessionsField.get(client);
// sessions.put("models/model", mockConnection);

// String requestJson = "{\"config\": {\"requestTtl\": \"120s\"}}";

// ArgumentCaptor<String> jsonCaptor = ArgumentCaptor.forClass(String.class);
// when(mockConnection.sendEncrypted(anyString(), jsonCaptor.capture()))
// .thenReturn(new CompletableFuture<>());

// // Act
// client.asyncRequest("POST", "models/model", requestJson, Optional.empty());

// // Assert
// String transformedJson = jsonCaptor.getValue();
// ObjectMapper mapper = new ObjectMapper();
// JsonNode node = mapper.readTree(transformedJson);

// assertEquals("120s", node.get("request_ttl").asText());
// assertFalse(node.get("generate_content_request").get("config").has("requestTtl"));
// }
}
Loading