diff --git a/.github/workflows/core-maven-build.yml b/.github/workflows/core-maven-build.yml index 7247f230..4ff7d895 100644 --- a/.github/workflows/core-maven-build.yml +++ b/.github/workflows/core-maven-build.yml @@ -94,7 +94,7 @@ jobs: with: pom_artifact_name: ${{ inputs.is_release && 'release_pom_xml' || '' }} - name: Run Integration Tests - run: mvn integration-test -Dskip.surefire.tests + run: mvn integration-test -Dskip.surefire.tests -Dci-run=true - name: Upload Integration Test Artifacts uses: actions/upload-artifact@v4 with: diff --git a/codegen-modules/openapi-java-client-codegen/src/test/java/com/radiantlogic/openapi/codegen/javaclient/integration/CodegenIT.java b/codegen-modules/openapi-java-client-codegen/src/test/java/com/radiantlogic/openapi/codegen/javaclient/integration/CodegenIT.java index 25783539..90470a7b 100644 --- a/codegen-modules/openapi-java-client-codegen/src/test/java/com/radiantlogic/openapi/codegen/javaclient/integration/CodegenIT.java +++ b/codegen-modules/openapi-java-client-codegen/src/test/java/com/radiantlogic/openapi/codegen/javaclient/integration/CodegenIT.java @@ -13,9 +13,11 @@ import lombok.NonNull; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; /** * Integration tests that validate this codegen against various openapi specifications. All of these @@ -28,14 +30,17 @@ public class CodegenIT { private static final Duration WAIT_FOR_BUILD = Duration.ofMinutes(2); private static long peakMemory = 0; + private static Thread memoryMonitorThread; /** * This prints the memory being used on an ongoing basis. This is useful information due to the - * sheer absurd size of some of the specs. + * sheer absurd size of some of the specs. Also in the more memory-constrained Github Action CI/CD + * pipeline this was helpful for getting the configuration right. */ @BeforeAll static void beforeAll() { - new Thread( + memoryMonitorThread = + new Thread( () -> { while (true) { final long amount = @@ -45,12 +50,18 @@ static void beforeAll() { } System.out.printf("Memory Current: %,d Peak: %,d%n", amount, peakMemory); try { - Thread.sleep(3000); + Thread.sleep(5000); } catch (InterruptedException e) { + return; } } - }) - .start(); + }); + memoryMonitorThread.start(); + } + + @AfterAll + static void afterAll() { + memoryMonitorThread.interrupt(); } @Test @@ -124,6 +135,7 @@ void bitbucket() { } @Test + @DisabledIfSystemProperty(named = "ci-run", matches = "true") void radiantlogicCloudmanager() { generateAndBuild("radiantlogic-cloudmanager-1.3.2.json", "Radiantlogic-CloudManager/1.3.2"); } diff --git a/pom.xml b/pom.xml index adcb0c45..cfa8ddfc 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ ./codegen-modules/openapi-java-client-codegen ./usage-modules/openapi-java-client-usage ${skipTests} + false @@ -247,6 +248,9 @@ + + ${ci-run} + false false -Xmx8000m diff --git a/usage-modules/openapi-java-client-usage/pom.xml b/usage-modules/openapi-java-client-usage/pom.xml index 1cf4711d..811975ca 100644 --- a/usage-modules/openapi-java-client-usage/pom.xml +++ b/usage-modules/openapi-java-client-usage/pom.xml @@ -46,8 +46,8 @@ com.radiantlogic.openapi.generated - RadiantLogic-CloudManager - 1.3.2 + Okta-OpenID-Connect--OAuth-2.0 + 2025.01.1 com.radiantlogic.openapi.generated diff --git a/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/ApiClientSupport.java b/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/ApiClientSupport.java index 3b7b5783..2093b09a 100644 --- a/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/ApiClientSupport.java +++ b/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/ApiClientSupport.java @@ -94,4 +94,13 @@ public class ApiClientSupport { apiClient.setBasePath(ApiClientSupport.BASE_URL); return apiClient; } + + public static com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.invoker.ApiClient + createOktaOpenidConnectApiClient() { + final com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.invoker.ApiClient apiClient = + new com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.invoker.ApiClient(); + apiClient.setDebugging(true); + apiClient.setBasePath(ApiClientSupport.BASE_URL); + return apiClient; + } } diff --git a/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/FormUrlencodedTest.java b/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/FormUrlencodedTest.java index efc1ee38..ddd94226 100644 --- a/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/FormUrlencodedTest.java +++ b/usage-modules/openapi-java-client-usage/src/test/java/com/radiantlogic/openapi/usage/javaclient/FormUrlencodedTest.java @@ -1,13 +1,21 @@ package com.radiantlogic.openapi.usage.javaclient; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.radiantlogic.openapi.usage.javaclient.ApiClientSupport.BASE_URL; -import static org.assertj.core.api.Assertions.assertThat; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import com.radiantlogic.openapi.generated.radiantlogiccloudmanager.api.AuthApi; -import com.radiantlogic.openapi.generated.radiantlogiccloudmanager.invoker.ApiClient; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.api.OrgAsApi; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.invoker.ApiClient; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.AcrValue; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.AmrValue; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.CodeChallengeMethod; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.Prompt; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.ResponseMode; +import com.radiantlogic.openapi.generated.oktaopenidconnectoauth20.model.ResponseTypesSupported; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.BeforeEach; @@ -16,20 +24,22 @@ @WireMockTest(httpPort = 9000) public class FormUrlencodedTest { private final ObjectMapper objectMapper = new ObjectMapper(); - private AuthApi authApi; + private OrgAsApi orgAsApi; @BeforeEach void setUp() { - final ApiClient apiClient = new ApiClient(); - apiClient.setBasePath(BASE_URL); - apiClient.setDebugging(true); - authApi = new AuthApi(apiClient); + final ApiClient apiClient = ApiClientSupport.createOktaOpenidConnectApiClient(); + orgAsApi = new OrgAsApi(apiClient); } @Test void testFormUrlencodedRequest() throws Exception { - final String email = "testuser"; - final String password = "password123"; + final String clientId = "client-id"; + final String codeChallenge = "challenge"; + final CodeChallengeMethod codeChallengeMethod = CodeChallengeMethod.S256; + final ResponseTypesSupported responseTypesSupported = ResponseTypesSupported.CODE; + final AcrValue acrValue = AcrValue.PHR; + final AmrValue amrValue = AmrValue.DUO; final Map expectedResponse = new HashMap<>(); expectedResponse.put("access_token", "test-token"); @@ -37,28 +47,41 @@ void testFormUrlencodedRequest() throws Exception { expectedResponse.put("expires_in", 3600); stubFor( - post(urlPathEqualTo("/eoc-backend/auth/local")) + post(urlPathEqualTo("/oauth2/v1/authorize")) .withHeader("Content-Type", equalTo("application/x-www-form-urlencoded;charset=UTF-8")) - .withFormParam("email", equalTo(email)) - .withFormParam("password", equalTo(password)) + .withFormParam("client_id", equalTo(clientId)) + .withFormParam("code_challenge", equalTo(codeChallenge)) + .withFormParam("code_challenge_method", equalTo(codeChallengeMethod.getValue())) + .withFormParam("response_type", equalTo(responseTypesSupported.getValue())) + .withFormParam("acr_values", equalTo(acrValue.getValue())) + .withFormParam("enroll_amr_values", equalTo(amrValue.getValue())) .willReturn( aResponse() .withStatus(201) .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(expectedResponse)))); - final Object result = authApi.authControllerLocalLogin(email, password, null); - - assertThat(result).isNotNull(); - assertThat(result).isInstanceOf(Map.class); - final Map resultMap = (Map) result; - - assertThat(resultMap).usingRecursiveComparison().isEqualTo(expectedResponse); - - verify( - postRequestedFor(urlPathEqualTo("/eoc-backend/auth/local")) - .withHeader("Content-Type", equalTo("application/x-www-form-urlencoded;charset=UTF-8")) - .withFormParam("email", equalTo(email)) - .withFormParam("password", equalTo(password))); + // If it doesn't match the stub, an exception will be thrown + orgAsApi.authorizeWithPost( + clientId, + "", + responseTypesSupported, + "", + "", + acrValue, + codeChallenge, + codeChallengeMethod, + "", + amrValue, + "", + "", + "", + 10, + "", + Prompt.NONE, + "", + "", + ResponseMode.FORM_POST, + ""); } }