gabriel-farache commented on code in PR #4000:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4000#discussion_r2260732504
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/TokenExchangeIT.java:
##########
@@ -18,41 +18,203 @@
*/
package org.kie.kogito.quarkus.workflows;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Duration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.tomakehurst.wiremock.client.WireMock;
+import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.restassured.path.json.JsonPath;
import jakarta.ws.rs.core.HttpHeaders;
+import static io.restassured.RestAssured.given;
+import static
org.kie.kogito.addons.quarkus.token.exchange.OpenApiCustomCredentialProvider.LOG_PREFIX_COMPLETED_TOKEN_EXCHANGE;
+import static
org.kie.kogito.addons.quarkus.token.exchange.OpenApiCustomCredentialProvider.LOG_PREFIX_FAILED_TOKEN_EXCHANGE;
+import static
org.kie.kogito.addons.quarkus.token.exchange.OpenApiCustomCredentialProvider.LOG_PREFIX_STARTING_TOKEN_EXCHANGE;
+import static
org.kie.kogito.addons.quarkus.token.exchange.cache.TokenEvictionHandler.LOG_PREFIX_FAILED_TO_REFRESH_TOKEN;
+import static
org.kie.kogito.addons.quarkus.token.exchange.cache.TokenEvictionHandler.LOG_PREFIX_REFRESH_COMPLETED;
+import static
org.kie.kogito.addons.quarkus.token.exchange.cache.TokenEvictionHandler.LOG_PREFIX_TOKEN_REFRESH;
+import static
org.kie.kogito.addons.quarkus.token.exchange.persistence.DatabaseTokenDataStore.LOG_PREFIX_USED_REPOSITORY;
import static
org.kie.kogito.quarkus.workflows.ExternalServiceMock.SUCCESSFUL_QUERY;
import static
org.kie.kogito.quarkus.workflows.TokenExchangeExternalServicesMock.BASE_AND_PROPAGATED_AUTHORIZATION_TOKEN;
+import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.assertProcessInstanceNotExists;
import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.newProcessInstance;
@QuarkusTestResource(TokenExchangeExternalServicesMock.class)
@QuarkusTestResource(KeycloakServiceMock.class)
@QuarkusIntegrationTest
class TokenExchangeIT {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(TokenExchangeIT.class);
@Test
- void tokenExchange() {
- // start a new process instance by sending the post query and collect
the process instance id.
+ void tokenExchange() throws IOException {
+ LOGGER.info("Testing token exchange caching behavior - expecting 3
external service calls but only 2 token exchanges");
+
+ // Get the Quarkus log file path (configured in application.properties)
+ Path logFile = getQuarkusLogFile();
+
+ // Clear the log file to start fresh
+ if (Files.exists(logFile)) {
+ Files.write(logFile, new byte[0]); // Clear the file
+ }
Review Comment:
mmh, I guess that would work too, I was afraid that by deleting the file in
the fs, the Path may have issue but I must have been tired, Path is simply a
representation, it's not linked to the fs until it is used to I/O on it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]