gabriel-farache commented on code in PR #3928: URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/3928#discussion_r2174604869
########## quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/TokenExchangeIT.java: ########## @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.quarkus.workflows; + +import java.util.HashMap; +import java.util.Map; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +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 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.newProcessInstance; + +@QuarkusTestResource(TokenExchangeExternalServicesMock.class) +@QuarkusTestResource(KeycloakServiceMock.class) +@QuarkusIntegrationTest +class TokenExchangeIT { + + @Test + void tokenExchange() { + // start a new process instance by sending the post query and collect the process instance id. + String processInput = buildProcessInput(SUCCESSFUL_QUERY); + Map<String, String> headers = new HashMap<>(); + // prepare the headers to pass to the token_propagation SW. + // service token-propagation-external-service1 and token-propagation-external-service2 will receive the AUTHORIZATION_TOKEN + headers.put(HttpHeaders.AUTHORIZATION, BASE_AND_PROPAGATED_AUTHORIZATION_TOKEN); + + JsonPath jsonPath = newProcessInstance("/token_exchange", processInput, headers); + Assertions.assertThat(jsonPath.getString("id")).isNotBlank(); + } + Review Comment: Sure for testing the missing authz header but for testing the exchange failure, OIDC missing configuration, ... it would require to change the way the IT are done: currently they are all in the same package using the same set of workflows using the same mock and using the same application.properties So to test those, it will be needed to remove some properties for the workflow and/or to change the Keycloak mock behaviour which means a new endpoint, new mock URL in the props, etc... Except by duplicating token exchange workflow and the REST API spec then adding new props and new endpoint in keycloak I do not see how it can be done. And duplicating is not nice, especially as the package is already crowded Did you have something better in mind? -- 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]
