Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/core-maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand All @@ -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
Expand Down Expand Up @@ -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");
}
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<java.client.codegen.path>./codegen-modules/openapi-java-client-codegen</java.client.codegen.path>
<java.client.usage.path>./usage-modules/openapi-java-client-usage</java.client.usage.path>
<skip.surefire.tests>${skipTests}</skip.surefire.tests>
<ci.run>false</ci.run>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -247,6 +248,9 @@
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<ci-run>${ci-run}</ci-run>
</systemPropertyVariables>
<testFailureIgnore>false</testFailureIgnore>
<useModulePath>false</useModulePath>
<argLine>-Xmx8000m</argLine>
Expand Down
4 changes: 2 additions & 2 deletions usage-modules/openapi-java-client-usage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
</dependency>
<dependency>
<groupId>com.radiantlogic.openapi.generated</groupId>
<artifactId>RadiantLogic-CloudManager</artifactId>
<version>1.3.2</version>
<artifactId>Okta-OpenID-Connect--OAuth-2.0</artifactId>
<version>2025.01.1</version>
</dependency>
<dependency>
<groupId>com.radiantlogic.openapi.generated</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,49 +24,64 @@
@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<String, Object> expectedResponse = new HashMap<>();
expectedResponse.put("access_token", "test-token");
expectedResponse.put("token_type", "bearer");
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<String, Object> resultMap = (Map<String, Object>) 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,
"");
}
}