diff --git a/build-logic/src/main/kotlin/authmgr-bundle.gradle.kts b/build-logic/src/main/kotlin/authmgr-bundle.gradle.kts index cbe5ce84..dcb53f8f 100644 --- a/build-logic/src/main/kotlin/authmgr-bundle.gradle.kts +++ b/build-logic/src/main/kotlin/authmgr-bundle.gradle.kts @@ -34,9 +34,8 @@ plugins { id("authmgr-java-production") } -// Create configurations to hold the core project's source and javadoc artifacts -// These will be used to copy the core project's source and javadoc jars into this project's -// artifacts +// Create configurations to hold the core and agent projects' source and javadoc artifacts. +// These will be used to copy those projects' source and javadoc jars into this project's artifacts. val coreSources by configurations.creating { isCanBeConsumed = false @@ -59,6 +58,28 @@ val coreJavadoc by } } +val agentSources by + configurations.creating { + isCanBeConsumed = false + isCanBeResolved = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) + attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES)) + } + } + +val agentJavadoc by + configurations.creating { + isCanBeConsumed = false + isCanBeResolved = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) + attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.JAVADOC)) + } + } + dependencies { api(project(":authmgr-oauth2-core")) { // exclude dependencies that are already provided by Iceberg @@ -69,6 +90,8 @@ dependencies { } coreSources(project(":authmgr-oauth2-core", "sourcesElements")) coreJavadoc(project(":authmgr-oauth2-core", "javadocElements")) + agentSources(project(":authmgr-oauth2-agent", "sourcesElements")) + agentJavadoc(project(":authmgr-oauth2-agent", "javadocElements")) } val shadowJar = tasks.named("shadowJar") @@ -114,18 +137,20 @@ shadowJar.configure { tasks.named("assemble").configure { dependsOn("shadowJar") } -// Configure the source jar to copy from the core project's source jar +// Configure the source jar to copy from both the core and agent projects' source jars tasks.named("sourcesJar") { - dependsOn(":authmgr-oauth2-core:sourcesJar") + dependsOn(":authmgr-oauth2-core:sourcesJar", ":authmgr-oauth2-agent:sourcesJar") duplicatesStrategy = DuplicatesStrategy.INCLUDE // LICENSE files may be duplicated from({ coreSources.incoming.artifactView { lenient(true) }.files.map { zipTree(it) } }) + from({ agentSources.incoming.artifactView { lenient(true) }.files.map { zipTree(it) } }) } -// Configure the javadoc jar to copy from the core project's javadoc jar +// Configure the javadoc jar to copy from both the core and agent projects' javadoc jars tasks.named("javadocJar") { - dependsOn(":authmgr-oauth2-core:javadocJar") + dependsOn(":authmgr-oauth2-core:javadocJar", ":authmgr-oauth2-agent:javadocJar") duplicatesStrategy = DuplicatesStrategy.INCLUDE // LICENSE files may be duplicated from({ coreJavadoc.incoming.artifactView { lenient(true) }.files.map { zipTree(it) } }) + from({ agentJavadoc.incoming.artifactView { lenient(true) }.files.map { zipTree(it) } }) } // Skip the javadoc generation task as we'll copy from the core project diff --git a/build-logic/src/main/kotlin/authmgr-root.gradle.kts b/build-logic/src/main/kotlin/authmgr-root.gradle.kts index 34958a52..6a23c852 100644 --- a/build-logic/src/main/kotlin/authmgr-root.gradle.kts +++ b/build-logic/src/main/kotlin/authmgr-root.gradle.kts @@ -26,7 +26,7 @@ plugins { spotless { java { target("**/*.java") - googleJavaFormat() + googleJavaFormat("1.25.2") licenseHeaderFile(rootProject.file("codestyle/copyright-header-java.txt")) endWithNewline() } diff --git a/gradle/projects.main.properties b/gradle/projects.main.properties index c524ff10..005e001f 100644 --- a/gradle/projects.main.properties +++ b/gradle/projects.main.properties @@ -20,6 +20,7 @@ authmgr-bom=bom authmgr-immutables=tools/immutables +authmgr-oauth2-agent=oauth2/agent authmgr-oauth2-core=oauth2/core # Bundles diff --git a/oauth2/agent/build.gradle.kts b/oauth2/agent/build.gradle.kts new file mode 100644 index 00000000..d214a79a --- /dev/null +++ b/oauth2/agent/build.gradle.kts @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2025 Dremio Corporation + * + * Licensed 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. + */ + +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + +plugins { + id("authmgr-java-production") + id("authmgr-java-testing") + id("authmgr-maven") +} + +description = "OAuth2 Agent for Dremio AuthManager" + +ext { set("mavenName", "Auth Manager for Apache Iceberg - OAuth2 - Agent") } + +val docs by + configurations.creating { + description = "Dependencies for generating configuration documentation" + isCanBeResolved = true + isCanBeConsumed = false + isVisible = false + } + +dependencies { + api(libs.nimbus.oauth2.oidc.sdk) { + exclude(group = "com.github.stephenc.jcip", module = "jcip-annotations") + } + api(libs.nimbus.jose.jwt) + + implementation(libs.httpclient5) + + implementation(libs.smallrye.config) + + // optional, but recommended for advanced cryptography (private_key_jwt client auth, DPoP) + compileOnly(libs.bouncycastle.bcpkix) + + implementation(libs.slf4j.api) + implementation(libs.caffeine) + + implementation(libs.jakarta.annotation.api) + compileOnly(libs.errorprone.annotations) + + compileOnly(project(":authmgr-immutables")) + annotationProcessor(project(":authmgr-immutables", configuration = "processor")) + + testFixturesApi(project(":authmgr-oauth2-tests")) + + testFixturesApi(platform(libs.junit.bom)) + testFixturesApi("org.junit.jupiter:junit-jupiter") + testFixturesApi(libs.junit.pioneer) + + testFixturesApi(libs.assertj.core) + testFixturesApi(libs.mockito.core) + + testFixturesApi(libs.nimbus.oauth2.oidc.sdk) + testFixturesApi(libs.nimbus.jose.jwt) + + testFixturesApi(libs.guava) + + testFixturesApi(platform(libs.testcontainers.bom)) + testFixturesApi("org.testcontainers:testcontainers") + testFixturesApi("org.testcontainers:testcontainers-junit-jupiter") + testFixturesApi(libs.keycloak.admin.client) + testFixturesApi(libs.testcontainers.keycloak) + + testFixturesImplementation(libs.bouncycastle.bcpkix) + + // Required to compile expectation classes + testFixturesCompileOnly(libs.mockserver.netty) + testFixturesCompileOnly(libs.mockserver.client.java) + + testFixturesCompileOnly(project(":authmgr-immutables")) + testFixturesAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) + + testImplementation(libs.mockserver.netty) + testImplementation(libs.mockserver.client.java) + + testImplementation(libs.bouncycastle.bcpkix) + + testCompileOnly(project(":authmgr-immutables")) + testAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) + + intTestCompileOnly(project(":authmgr-immutables")) + intTestAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) + + intTestRuntimeOnly(libs.bouncycastle.bcpkix) + + longTestCompileOnly(project(":authmgr-immutables")) + longTestAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) + + longTestRuntimeOnly(libs.bouncycastle.bcpkix) + + docs("com.thoughtworks.qdox:qdox:2.2.0") +} + +tasks.named("test").configure { + configForks(4) + commonTestConfig() +} + +tasks.named("intTest").configure { + configForks(3) + commonTestConfig() +} + +val bouncyCastle = configurations.create("bouncyCastle") + +dependencies { bouncyCastle(libs.bouncycastle.bcpkix) } + +tasks.register("intTestNoBouncyCastle") { + description = "Runs integration tests without BouncyCastle dependencies" + group = "verification" + configForks(3) + commonTestConfig() + shouldRunAfter("test") + useJUnitPlatform() + testClassesDirs = sourceSets.intTest.get().output.classesDirs + classpath = sourceSets.intTest.get().runtimeClasspath - bouncyCastle +} + +tasks.named("check") { dependsOn("intTestNoBouncyCastle") } + +tasks.named("longTest").configure { + configForks(3) + commonTestConfig() + if (System.getProperty("authmgr.it.long.total") != null) { + val total = Duration.parse(System.getProperty("authmgr.it.long.total")) + systemProperty("authmgr.it.long.total", total.toIsoString()) + // Add a 10-second safety window to the tests default timeout + systemProperty( + "junit.jupiter.execution.timeout.testable.method.default", + (total + 10.seconds).inWholeSeconds.toString() + " s", + ) + } +} + +val mockitoAgent = configurations.create("mockitoAgent") + +dependencies { mockitoAgent(libs.mockito.core) { isTransitive = false } } + +tasks { test { jvmArgs("-javaagent:${mockitoAgent.asPath}") } } + +fun Test.configForks(forks: Int) { + if (System.getenv("CI") == null) { + maxParallelForks = forks + } +} + +fun Test.commonTestConfig() { + val outputMemoryUsage = System.getProperty("authmgr.test.mockserver.outputMemoryUsage") + if (outputMemoryUsage.toBoolean()) { + val outputDir = + project.layout.buildDirectory.dir("reports/mockserver/${this.name}").get().asFile.absolutePath + outputs.dir(outputDir) + File(outputDir).mkdirs() + systemProperty("authmgr.test.mockserver.memoryUsageCsvDirectory", outputDir) + } +} + +sourceSets.create("docs") { + java.srcDir("src/docs/java") + resources.srcDir("src/docs/resources") + compileClasspath += docs + runtimeClasspath += docs +} + +tasks.named("processDocsResources", ProcessResources::class) { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +tasks.register("generateDocs") { + group = "documentation" + description = "Generates configuration documentation from OAuth2AgentConfig" + mainClass.set("com.dremio.iceberg.authmgr.oauth2.agent.docs.DocumentationGenerator") + classpath = sourceSets.getByName("docs").runtimeClasspath + + val inputFile = + project.file("src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfig.java") + val outputFile = rootProject.file("docs/configuration.md") + + val headerFile = sourceSets.getByName("docs").resources.singleFile + val header = headerFile.readText() + + inputs.files(inputFile, headerFile) + outputs.file(outputFile) + + args(inputFile.absolutePath, header, outputFile.absolutePath) + + doFirst { outputFile.parentFile.mkdirs() } +} + +tasks.named("publish") { dependsOn("generateDocs") } + +rootProject.tasks.named("spotlessMarkdown") { dependsOn(":authmgr-oauth2-agent:generateDocs") } + +rootProject.tasks.named("rat") { dependsOn(":authmgr-oauth2-agent:generateDocs") } diff --git a/oauth2/core/src/docs/java/com/dremio/iceberg/authmgr/oauth2/docs/DocumentationGenerator.java b/oauth2/agent/src/docs/java/com/dremio/iceberg/authmgr/oauth2/agent/docs/DocumentationGenerator.java similarity index 97% rename from oauth2/core/src/docs/java/com/dremio/iceberg/authmgr/oauth2/docs/DocumentationGenerator.java rename to oauth2/agent/src/docs/java/com/dremio/iceberg/authmgr/oauth2/agent/docs/DocumentationGenerator.java index 5c4c41b9..6574dee5 100644 --- a/oauth2/core/src/docs/java/com/dremio/iceberg/authmgr/oauth2/docs/DocumentationGenerator.java +++ b/oauth2/agent/src/docs/java/com/dremio/iceberg/authmgr/oauth2/agent/docs/DocumentationGenerator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.docs; +package com.dremio.iceberg.authmgr.oauth2.agent.docs; import com.thoughtworks.qdox.JavaProjectBuilder; import com.thoughtworks.qdox.model.JavaClass; @@ -36,7 +36,7 @@ /** * Parses the properties from the source code and generates documentation for them. * - *

This generator is mostly intended to parse the `OAuth2Properties` class. The parser relies + *

This generator is mostly intended to parse the `OAuth2AgentConfig` class. The parser relies * heavily on conventions, such as the use of `PREFIX` fields, or fields starting with `DEFAULT_`, * or the presence of nested classes to structure the properties into sections. */ @@ -76,7 +76,8 @@ public class DocumentationGenerator { KNOWN_REFS = Map.copyOf(refs); } - private static final String ROOT_CLASS_NAME = "com.dremio.iceberg.authmgr.oauth2.OAuth2Config"; + private static final String ROOT_CLASS_NAME = + "com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig"; private final Path rootConfigFile; private final String header; @@ -218,7 +219,7 @@ private String sanitizeDescription(Section section, String text) { private String resolveReference(Section section, String ref, String text) { String refTarget = KNOWN_REFS.get(ref); if (refTarget == null) { - if (ref.equals("OAuth2Config#PREFIX")) { + if (ref.equals("OAuth2AgentConfig#PREFIX")) { refTarget = rootPrefix; } else if (ref.startsWith("#")) { // local ref diff --git a/oauth2/core/src/docs/resources/header.md b/oauth2/agent/src/docs/resources/header.md similarity index 100% rename from oauth2/core/src/docs/resources/header.md rename to oauth2/agent/src/docs/resources/header.md diff --git a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java similarity index 94% rename from oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java rename to oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java index 55bb1337..ab0fe979 100644 --- a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java +++ b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAuth0IT.java @@ -17,10 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.JWTParser; @@ -109,7 +107,7 @@ private void introspectToken(AccessToken accessToken, TestEnvironment env) throw assertThat(claims.getStringClaim("scope")).contains("catalog"); } - private static Builder envBuilder( + private static ImmutableTestEnvironment.Builder envBuilder( GrantType initialGrantType, ClientAuthenticationMethod authenticationMethod) { URI issuerUrl = URI.create(System.getenv(AUTH0_DOMAIN_ENV)); @@ -119,7 +117,7 @@ private static Builder envBuilder( ? new Scope("catalog") : new Scope("catalog", "offline_access"); // request refresh token - return TestEnvironment.builder() + return ImmutableTestEnvironment.builder() .serverRootUrl(issuerUrl) .authorizationServerUrl(issuerUrl) .grantType(initialGrantType) diff --git a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java similarity index 83% rename from oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java rename to oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java index 3451daf6..8dd534e8 100644 --- a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java +++ b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentAutheliaIT.java @@ -15,20 +15,17 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.AutheliaExtension.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.AutheliaExtension.CLIENT_ID2; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.AutheliaExtension.CLIENT_SECRET1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.AutheliaExtension.CLIENT_SECRET2; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.AutheliaExtension.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.AutheliaExtension.CLIENT_ID2; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.AutheliaExtension.CLIENT_SECRET1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.AutheliaExtension.CLIENT_SECRET2; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_BASIC; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_POST; import static org.assertj.core.api.InstanceOfAssertFactories.type; -import com.dremio.iceberg.authmgr.oauth2.flow.OAuth2Exception; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.AutheliaExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.OAuth2Exception; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.AutheliaExtension; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; import com.nimbusds.oauth2.sdk.ErrorObject; @@ -53,7 +50,7 @@ public class OAuth2AgentAutheliaIT { private static final TestCertificates CERTS = TestCertificates.instance(); @Test - void clientSecretBasic(Builder envBuilder) throws Exception { + void clientSecretBasic(ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder .grantType(GrantType.CLIENT_CREDENTIALS) @@ -70,7 +67,7 @@ void clientSecretBasic(Builder envBuilder) throws Exception { } @Test - void clientSecretPost(Builder envBuilder) throws Exception { + void clientSecretPost(ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder .grantType(GrantType.CLIENT_CREDENTIALS) @@ -87,7 +84,7 @@ void clientSecretPost(Builder envBuilder) throws Exception { } @Test - void unauthorizedBadClientSecret(Builder envBuilder) { + void unauthorizedBadClientSecret(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder .clientSecret(new Secret("BAD SECRET")) diff --git a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java similarity index 81% rename from oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java rename to oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java index e31d2226..ab325c40 100644 --- a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java +++ b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentHydraIT.java @@ -15,21 +15,19 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.HydraExtension.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.HydraExtension.CLIENT_ID2; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.HydraExtension.CLIENT_SECRET1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.HydraExtension.CLIENT_SECRET2; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.HydraExtension.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.HydraExtension.CLIENT_ID2; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.HydraExtension.CLIENT_SECRET1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.HydraExtension.CLIENT_SECRET2; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_BASIC; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_POST; import static org.assertj.core.api.InstanceOfAssertFactories.type; -import com.dremio.iceberg.authmgr.oauth2.flow.OAuth2Exception; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.OAuth2Exception; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.HydraExtension; import com.dremio.iceberg.authmgr.oauth2.test.container.HydraContainer; -import com.dremio.iceberg.authmgr.oauth2.test.junit.HydraExtension; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; import com.nimbusds.oauth2.sdk.ErrorObject; @@ -53,7 +51,9 @@ public class OAuth2AgentHydraIT { @InjectSoftAssertions private SoftAssertions soft; @CartesianTest - void clientSecretBasic(@Enum HttpClientType httpClientType, Builder envBuilder) throws Exception { + void clientSecretBasic( + @Enum HttpClientType httpClientType, ImmutableTestEnvironment.Builder envBuilder) + throws Exception { try (TestEnvironment env = envBuilder .httpClientType(httpClientType) @@ -68,7 +68,9 @@ void clientSecretBasic(@Enum HttpClientType httpClientType, Builder envBuilder) } @CartesianTest - void clientSecretPost(@Enum HttpClientType httpClientType, Builder envBuilder) throws Exception { + void clientSecretPost( + @Enum HttpClientType httpClientType, ImmutableTestEnvironment.Builder envBuilder) + throws Exception { try (TestEnvironment env = envBuilder .httpClientType(httpClientType) @@ -83,7 +85,7 @@ void clientSecretPost(@Enum HttpClientType httpClientType, Builder envBuilder) t } @Test - void unauthorizedBadClientSecret(Builder envBuilder) { + void unauthorizedBadClientSecret(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder.clientSecret(new Secret("BAD SECRET")).build(); OAuth2Agent agent = env.newAgent()) { soft.assertThatThrownBy(agent::authenticate) diff --git a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java similarity index 89% rename from oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java rename to oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java index 80e20fd3..7d59e23a 100644 --- a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java +++ b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakIT.java @@ -15,17 +15,17 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID2; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID3; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID4; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID5; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID6; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_SECRET3; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_SECRET6; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.JWT_BEARER_ECDSA_ASSERTION_ISSUER; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.createJwtBearerAssertion; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID2; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID3; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID4; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID5; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID6; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_SECRET3; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_SECRET6; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.JWT_BEARER_ECDSA_ASSERTION_ISSUER; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.createJwtBearerAssertion; import static com.nimbusds.oauth2.sdk.GrantType.AUTHORIZATION_CODE; import static com.nimbusds.oauth2.sdk.GrantType.CLIENT_CREDENTIALS; import static com.nimbusds.oauth2.sdk.GrantType.DEVICE_CODE; @@ -42,17 +42,13 @@ import static org.assertj.core.api.Assumptions.assumeThat; import static org.assertj.core.api.InstanceOfAssertFactories.type; -import com.dremio.iceberg.authmgr.oauth2.flow.OAuth2Exception; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.OAuth2Exception; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.user.UserBehavior; import com.dremio.iceberg.authmgr.oauth2.test.container.KeycloakContainer; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; -import com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension; -import com.dremio.iceberg.authmgr.oauth2.test.user.UserBehavior; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; @@ -90,7 +86,7 @@ void clientSecretBasic( @Enum HttpClientType httpClientType, @EnumLike(excludes = "urn:ietf:params:oauth:grant-type:token-exchange") GrantType initialGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -110,7 +106,7 @@ void clientSecretPost( @Enum HttpClientType httpClientType, @EnumLike(excludes = "urn:ietf:params:oauth:grant-type:token-exchange") GrantType initialGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -135,7 +131,7 @@ void publicClient( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType initialGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -155,7 +151,7 @@ void clientSecretJwt( @Enum HttpClientType httpClientType, @EnumLike(excludes = "urn:ietf:params:oauth:grant-type:token-exchange") GrantType initialGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -177,7 +173,7 @@ void privateKeyJwt( @EnumLike(excludes = "urn:ietf:params:oauth:grant-type:token-exchange") GrantType initialGrantType, @Values(strings = {"rsa_pkcs8", "rsa_pkcs1", "ecdsa_pkcs8", "ecdsa_sec1"}) String keyType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { TestCertificates certs = TestCertificates.instance(); assumeThat( @@ -232,7 +228,7 @@ void privateKeyJwt( void pkce( @Values(booleans = {true, false}) boolean enabled, @EnumLike CodeChallengeMethod method, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -246,7 +242,9 @@ void pkce( } @CartesianTest - void httpsCallback(@EnumLike CodeChallengeMethod method, Builder envBuilder) throws Exception { + void httpsCallback( + @EnumLike CodeChallengeMethod method, ImmutableTestEnvironment.Builder envBuilder) + throws Exception { TestCertificates certs = TestCertificates.instance(); for (Path keyStore : List.of(certs.getRsaKeyStore(), certs.getEcdsaKeyStore())) { try (TestEnvironment env = @@ -282,7 +280,7 @@ void impersonation1( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType subjectGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -310,7 +308,7 @@ void impersonation2( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType subjectGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -328,7 +326,7 @@ void impersonation2( * using itws own access token as the actor token. */ @Test - void delegation1(Builder envBuilder) throws Exception { + void delegation1(ImmutableTestEnvironment.Builder envBuilder) throws Exception { AccessToken subjectToken; try (TestEnvironment env = envBuilder.build(); OAuth2Agent subjectAgent = env.newAgent()) { @@ -347,7 +345,7 @@ void delegation1(Builder envBuilder) throws Exception { * using its own access token as the subject token. */ @Test - void delegation2(Builder envBuilder) throws Exception { + void delegation2(ImmutableTestEnvironment.Builder envBuilder) throws Exception { AccessToken actorToken; try (TestEnvironment env = envBuilder.build(); OAuth2Agent actorAgent = env.newAgent()) { @@ -374,7 +372,7 @@ void delegation3( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType subjectGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { boolean expectRefreshToken = subjectGrantType != CLIENT_CREDENTIALS; try (TestEnvironment env = @@ -399,7 +397,7 @@ void delegation3( /** Tests dynamically-obtained tokens with refresh forcibly disabled. */ @Test - void refreshDisabled(Builder envBuilder) throws Exception { + void refreshDisabled(ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder.grantType(PASSWORD).tokenRefreshEnabled(false).build(); OAuth2Agent agent = env.newAgent()) { // initial grant @@ -410,7 +408,7 @@ void refreshDisabled(Builder envBuilder) throws Exception { } @Test - void unauthorizedBadClientSecret(Builder envBuilder) { + void unauthorizedBadClientSecret(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder.clientSecret(new Secret("BAD SECRET")).build(); OAuth2Agent agent = env.newAgent()) { soft.assertThatThrownBy(agent::authenticate) @@ -422,7 +420,7 @@ void unauthorizedBadClientSecret(Builder envBuilder) { } @Test - void unauthorizedBadPassword(Builder envBuilder) { + void unauthorizedBadPassword(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder.grantType(PASSWORD).password(new Secret("BAD PASSWORD")).build(); OAuth2Agent agent = env.newAgent()) { @@ -435,7 +433,7 @@ void unauthorizedBadPassword(Builder envBuilder) { } @Test - void unauthorizedBadCode(Builder envBuilder) { + void unauthorizedBadCode(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder .grantType(AUTHORIZATION_CODE) @@ -456,7 +454,7 @@ void unauthorizedBadCode(Builder envBuilder) { } @Test - void deviceCodeAccessDenied(Builder envBuilder) { + void deviceCodeAccessDenied(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder .grantType(DEVICE_CODE) @@ -478,7 +476,8 @@ void deviceCodeAccessDenied(Builder envBuilder) { /** Tests a JWT bearer grant with an ECDSA-signed JWT assertion. */ @Test - void jwtBearerEcdsa(Builder envBuilder, KeycloakContainer keycloak) throws Exception { + void jwtBearerEcdsa(ImmutableTestEnvironment.Builder envBuilder, KeycloakContainer keycloak) + throws Exception { TestCertificates certs = TestCertificates.instance(); String assertion = createJwtBearerAssertion( @@ -493,7 +492,7 @@ void jwtBearerEcdsa(Builder envBuilder, KeycloakContainer keycloak) throws Excep } @Test - void jwtBearerInvalidAssertion(Builder envBuilder) { + void jwtBearerInvalidAssertion(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder .grantType(JWT_BEARER) @@ -513,7 +512,7 @@ void dpop( @Enum HttpClientType httpClientType, @EnumLike(includes = {"client_credentials", "authorization_code"}) GrantType initialGrantType, @EnumLike(includes = {"ES256", "RS256", "PS256"}) JWSAlgorithm dpopAlgorithm, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder @@ -561,7 +560,7 @@ void dpop( * the token request for lack of a DPoP proof. */ @Test - void dpopInvalidRequest(Builder envBuilder) { + void dpopInvalidRequest(ImmutableTestEnvironment.Builder envBuilder) { try (TestEnvironment env = envBuilder .grantType(PASSWORD) @@ -580,7 +579,7 @@ void dpopInvalidRequest(Builder envBuilder) { } @Test - void agentCopy(Builder envBuilder) throws Exception { + void agentCopy(ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder.build(); OAuth2Agent agent = env.newAgent()) { try (OAuth2Agent agent2 = agent.copy()) { @@ -606,7 +605,7 @@ void offlineAccess( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType grantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder.grantType(grantType).scope(Scope.parse(SCOPE1 + " offline_access")).build(); @@ -635,7 +634,7 @@ void offlineAccessImpersonation( "urn:ietf:params:oauth:grant-type:token-exchange" }) GrantType subjectGrantType, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { Scope offlineScope = Scope.parse(SCOPE1 + " offline_access"); try (TestEnvironment env = diff --git a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java similarity index 85% rename from oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java rename to oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java index cdfaf7c0..bf55b7c8 100644 --- a/oauth2/core/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java +++ b/oauth2/agent/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisIT.java @@ -17,11 +17,9 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; -import com.dremio.iceberg.authmgr.oauth2.test.junit.PolarisExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.PolarisExtension; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; @@ -38,7 +36,7 @@ public class OAuth2AgentPolarisIT { void clientCredentials( @EnumLike(includes = {"client_secret_basic", "client_secret_post"}) ClientAuthenticationMethod clientAuthenticationMethod, - Builder envBuilder) + ImmutableTestEnvironment.Builder envBuilder) throws Exception { try (TestEnvironment env = envBuilder.clientAuthenticationMethod(clientAuthenticationMethod).build(); diff --git a/oauth2/core/src/intTest/resources/junit-platform.properties b/oauth2/agent/src/intTest/resources/junit-platform.properties similarity index 100% rename from oauth2/core/src/intTest/resources/junit-platform.properties rename to oauth2/agent/src/intTest/resources/junit-platform.properties diff --git a/oauth2/core/src/intTest/resources/logback-test.xml b/oauth2/agent/src/intTest/resources/logback-test.xml similarity index 100% rename from oauth2/core/src/intTest/resources/logback-test.xml rename to oauth2/agent/src/intTest/resources/logback-test.xml diff --git a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java similarity index 86% rename from oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java rename to oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java index dcad4ac3..f5e85fa6 100644 --- a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java +++ b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentKeycloakLongIT.java @@ -15,15 +15,15 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension.SCOPE1; import static com.nimbusds.oauth2.sdk.GrantType.AUTHORIZATION_CODE; import static com.nimbusds.oauth2.sdk.GrantType.DEVICE_CODE; import static com.nimbusds.oauth2.sdk.GrantType.TOKEN_EXCHANGE; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.junit.KeycloakExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment.Builder; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.KeycloakExtension; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; import com.nimbusds.oauth2.sdk.token.AccessToken; diff --git a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java similarity index 94% rename from oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java rename to oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java index 3fadebdd..9150433a 100644 --- a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java +++ b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentLongITBase.java @@ -19,8 +19,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment.Builder; import java.time.Duration; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; diff --git a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java similarity index 92% rename from oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java rename to oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java index 5b5f2b47..15214dd8 100644 --- a/oauth2/core/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java +++ b/oauth2/agent/src/longTest/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentPolarisLongIT.java @@ -17,8 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.junit.PolarisExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment.Builder; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.PolarisExtension; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWTParser; import com.nimbusds.oauth2.sdk.token.AccessToken; diff --git a/oauth2/core/src/longTest/resources/junit-platform.properties b/oauth2/agent/src/longTest/resources/junit-platform.properties similarity index 100% rename from oauth2/core/src/longTest/resources/junit-platform.properties rename to oauth2/agent/src/longTest/resources/junit-platform.properties diff --git a/oauth2/core/src/longTest/resources/logback-test.xml b/oauth2/agent/src/longTest/resources/logback-test.xml similarity index 100% rename from oauth2/core/src/longTest/resources/logback-test.xml rename to oauth2/agent/src/longTest/resources/logback-test.xml diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java index 69620b30..4555fd15 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2Agent.java @@ -15,17 +15,16 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.concurrent.AutoCloseables.cancelOnClose; - -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.concurrent.Futures; -import com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils; -import com.dremio.iceberg.authmgr.oauth2.dpop.DpopContext; -import com.dremio.iceberg.authmgr.oauth2.dpop.DpopScope; -import com.dremio.iceberg.authmgr.oauth2.flow.Flow; -import com.dremio.iceberg.authmgr.oauth2.flow.FlowFactory; -import com.dremio.iceberg.authmgr.oauth2.flow.OAuth2Exception; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.concurrent.AutoCloseables.cancelOnClose; + +import com.dremio.iceberg.authmgr.oauth2.agent.concurrent.Futures; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils; +import com.dremio.iceberg.authmgr.oauth2.agent.dpop.DpopContext; +import com.dremio.iceberg.authmgr.oauth2.agent.dpop.DpopScope; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.Flow; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.FlowFactory; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.OAuth2Exception; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; import com.nimbusds.jwt.SignedJWT; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.DPoPAccessToken; @@ -62,7 +61,7 @@ public final class OAuth2Agent implements Closeable { private static final CompletableFuture MUST_FETCH_NEW_TOKENS_FUTURE = CompletableFuture.failedFuture(MustFetchNewTokensException.INSTANCE); - private final OAuth2Config config; + private final OAuth2AgentConfig config; private final ScheduledExecutorService executor; private final FlowFactory flowFactory; private final String name; @@ -78,7 +77,7 @@ public final class OAuth2Agent implements Closeable { private volatile Instant lastAccess; private volatile Instant lastWarn; - public OAuth2Agent(OAuth2Config config, OAuth2AgentRuntime runtime) { + public OAuth2Agent(OAuth2AgentConfig config, OAuth2AgentRuntime runtime) { this.config = config; this.executor = runtime.getExecutor(); this.flowFactory = FlowFactory.create(config, runtime); @@ -144,7 +143,7 @@ private OAuth2Agent(OAuth2Agent toCopy) { currentTokensFuture.whenComplete((tokens, error) -> maybeScheduleTokensRenewal(tokens)); } - public OAuth2Config getConfig() { + public OAuth2AgentConfig getConfig() { return config; } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Config.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfig.java similarity index 82% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Config.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfig.java index 7a03cf89..744010f7 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Config.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfig.java @@ -13,28 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2; - -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.config.BasicConfig.CLIENT_AUTH; -import static com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig.ALGORITHM; -import static com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig.PRIVATE_KEY; -import static com.dremio.iceberg.authmgr.oauth2.config.ResourceOwnerConfig.PASSWORD; -import static com.dremio.iceberg.authmgr.oauth2.config.ResourceOwnerConfig.USERNAME; - -import com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils; -import com.dremio.iceberg.authmgr.oauth2.config.DeviceCodeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.DpopConfig; -import com.dremio.iceberg.authmgr.oauth2.config.HttpConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig; -import com.dremio.iceberg.authmgr.oauth2.config.ResourceOwnerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.SystemConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +package com.dremio.iceberg.authmgr.oauth2.agent; + +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig.CLIENT_AUTH; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig.ALGORITHM; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig.PRIVATE_KEY; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.ResourceOwnerConfig.PASSWORD; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.ResourceOwnerConfig.USERNAME; + +import com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DeviceCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DpopConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.HttpConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ResourceOwnerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; @@ -48,7 +48,7 @@ import java.util.Map; @ConfigMapping(prefix = PREFIX) -public interface OAuth2Config { +public interface OAuth2AgentConfig { String PREFIX = "rest.auth.oauth2"; @@ -86,8 +86,8 @@ public interface OAuth2Config { HttpConfig getHttpConfig(); /** - * Creates an {@link OAuth2Config} from the environment and the given catalog session properties - * map. + * Creates an {@link OAuth2AgentConfig} from the environment and the given catalog session + * properties map. * *

The resulting configuration is loaded in the following order: * @@ -105,7 +105,7 @@ public interface OAuth2Config { * * @param properties The catalog session properties to create the config from. */ - static OAuth2Config from(Map properties) { + static OAuth2AgentConfig from(Map properties) { MapBackedConfigSource source = new MapBackedConfigSource("catalog session properties", properties, 200) {}; SmallRyeConfig smallRyeConfig = @@ -113,9 +113,9 @@ static OAuth2Config from(Map properties) { .addDefaultSources() .addDiscoveredInterceptors() .withSources(source) - .withMapping(OAuth2Config.class) + .withMapping(OAuth2AgentConfig.class) .build(); - OAuth2Config config = smallRyeConfig.getConfigMapping(OAuth2Config.class); + OAuth2AgentConfig config = smallRyeConfig.getConfigMapping(OAuth2AgentConfig.class); config.validate(); return config; } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentRuntime.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentRuntime.java similarity index 100% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentRuntime.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentRuntime.java diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseables.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseables.java similarity index 95% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseables.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseables.java index dc0c755e..fcb40fc9 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseables.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseables.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.concurrent; +package com.dremio.iceberg.authmgr.oauth2.agent.concurrent; import jakarta.annotation.Nullable; import java.util.concurrent.Future; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/Futures.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/Futures.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/Futures.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/Futures.java index 05b3cd78..551e0a25 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/concurrent/Futures.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/Futures.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.concurrent; +package com.dremio.iceberg.authmgr.oauth2.agent.concurrent; import jakarta.annotation.Nullable; import java.util.concurrent.CompletableFuture; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfig.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfig.java index 34c04c45..e025491a 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.pkce.CodeChallengeMethod; import io.smallrye.config.WithDefault; @@ -41,7 +41,7 @@ public interface AuthorizationCodeConfig { String GROUP_NAME = "auth-code"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ENDPOINT = "endpoint"; String REDIRECT_URI = "redirect-uri"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfig.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfig.java index f6d86df6..dd1ceb85 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.Scope; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; @@ -38,7 +38,7 @@ */ public interface BasicConfig { - String PREFIX = OAuth2Config.PREFIX; + String PREFIX = OAuth2AgentConfig.PREFIX; String TOKEN = "token"; String ISSUER_URL = "issuer-url"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptor.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptor.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptor.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptor.java index 6da17dfd..370e3752 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptor.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptor.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import io.smallrye.config.ConfigSourceInterceptor; import io.smallrye.config.ConfigSourceInterceptorContext; import io.smallrye.config.ConfigValue; @@ -30,7 +30,7 @@ public class ConfigRelocationInterceptor implements ConfigSourceInterceptor { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigRelocationInterceptor.class); - private static final String ROOT_PREFIX = OAuth2Config.PREFIX + '.'; + private static final String ROOT_PREFIX = OAuth2AgentConfig.PREFIX + '.'; private static final Set REMOVED_PROPERTIES = Set.of(DeviceCodeConfig.PREFIX + ".poll-interval"); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtils.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtils.java similarity index 98% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtils.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtils.java index 5123c30f..c9e5386c 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtils.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtils.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.jwk.Curve; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfig.java similarity index 87% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfig.java index 16bc6289..ddbfb2e4 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.WithName; import java.net.URI; import java.util.Optional; @@ -32,7 +32,7 @@ public interface DeviceCodeConfig { String GROUP_NAME = "device-code"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ENDPOINT = "endpoint"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfig.java similarity index 92% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfig.java index 5d9adbeb..26f9cb63 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.jose.JWSAlgorithm; import io.smallrye.config.WithDefault; import io.smallrye.config.WithName; @@ -34,7 +34,7 @@ public interface DpopConfig { String GROUP_NAME = "dpop"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ENABLED = "enabled"; String ALGORITHM = "algorithm"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfig.java similarity index 95% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfig.java index aa8f27a0..4d6ea1f8 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfig.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClient; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClient; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; import com.google.errorprone.annotations.MustBeClosed; import io.smallrye.config.WithDefault; import io.smallrye.config.WithName; @@ -34,7 +34,7 @@ public interface HttpConfig { String GROUP_NAME = "http"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String CLIENT_TYPE = "client-type"; String READ_TIMEOUT = "read-timeout"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfig.java similarity index 87% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfig.java index ca53dafb..d0d77922 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.WithName; import java.nio.file.Files; import java.nio.file.Path; @@ -33,7 +33,7 @@ public interface JwtBearerConfig { String GROUP_NAME = "jwt-bearer"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ASSERTION = "assertion"; String ASSERTION_FILE = "assertion-file"; @@ -59,7 +59,7 @@ public interface JwtBearerConfig { * The configuration to use for fetching the assertion dynamically. * *

This is a prefix property; any property that can be set under the {@value - * OAuth2Config#PREFIX} prefix can also be set under this prefix. + * OAuth2AgentConfig#PREFIX} prefix can also be set under this prefix. */ @WithName(ASSERTION) Map getAssertionConfig(); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfig.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfig.java index 0afc6a7b..dc0e8d29 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import com.nimbusds.oauth2.sdk.id.Audience; @@ -44,7 +44,7 @@ public interface JwtClientAuthConfig { String GROUP_NAME = "client-auth.jwt"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ISSUER = "issuer"; String SUBJECT = "subject"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ResourceOwnerConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ResourceOwnerConfig.java similarity index 91% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ResourceOwnerConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ResourceOwnerConfig.java index 350fa812..52d77fdb 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/ResourceOwnerConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ResourceOwnerConfig.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.Secret; import io.smallrye.config.WithName; @@ -34,7 +34,7 @@ public interface ResourceOwnerConfig { String GROUP_NAME = "resource-owner"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String USERNAME = "username"; String PASSWORD = "password"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfig.java similarity index 89% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfig.java index 30912dfd..075faf38 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.WithDefault; import io.smallrye.config.WithName; import java.time.Duration; @@ -29,7 +29,7 @@ public interface SystemConfig { String GROUP_NAME = "system"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String AGENT_NAME = "agent-name"; String SESSION_CACHE_TIMEOUT = "session-cache-timeout"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfig.java similarity index 95% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfig.java index d46bcd8e..2afa3efe 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.oauth2.sdk.id.Audience; import com.nimbusds.oauth2.sdk.token.TokenTypeURI; import com.nimbusds.oauth2.sdk.token.TypelessAccessToken; @@ -41,7 +41,7 @@ public interface TokenExchangeConfig { String GROUP_NAME = "token-exchange"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String SUBJECT_TOKEN = "subject-token"; String SUBJECT_TOKEN_FILE = "subject-token-file"; @@ -127,7 +127,7 @@ public interface TokenExchangeConfig { * not set. * *

This is a prefix property; any property that can be set under the {@value - * OAuth2Config#PREFIX} prefix can also be set under this prefix. + * OAuth2AgentConfig#PREFIX} prefix can also be set under this prefix. * *

The effective subject token fetch configuration will be the result of merging the * subject-specific configuration with the main configuration. @@ -156,7 +156,7 @@ public interface TokenExchangeConfig { * #ACTOR_TOKEN} is not set but an actor token is required. * *

This is a prefix property; any property that can be set under the {@value - * OAuth2Config#PREFIX} prefix can also be set under this prefix. + * OAuth2AgentConfig#PREFIX} prefix can also be set under this prefix. * *

The effective actor token fetch configuration will be the result of merging the * actor-specific configuration with the main configuration. diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfig.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfig.java similarity index 95% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfig.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfig.java index d555fafe..5cd1c475 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfig.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfig.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.WithDefault; import io.smallrye.config.WithName; import java.time.Duration; @@ -26,7 +26,7 @@ public interface TokenRefreshConfig { String GROUP_NAME = "token-refresh"; - String PREFIX = OAuth2Config.PREFIX + '.' + GROUP_NAME; + String PREFIX = OAuth2AgentConfig.PREFIX + '.' + GROUP_NAME; String ENABLED = "enabled"; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigValidator.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigValidator.java similarity index 98% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigValidator.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigValidator.java index 40ad2420..bab8cf30 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigValidator.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigValidator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config.validator; +package com.dremio.iceberg.authmgr.oauth2.agent.config.validator; import com.google.errorprone.annotations.FormatMethod; import com.google.errorprone.annotations.FormatString; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigViolation.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigViolation.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigViolation.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigViolation.java index 9334ec0f..f31ee942 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/config/validator/ConfigViolation.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/config/validator/ConfigViolation.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config.validator; +package com.dremio.iceberg.authmgr.oauth2.agent.config.validator; import static java.lang.String.format; import static java.lang.String.join; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReader.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReader.java similarity index 98% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReader.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReader.java index d0ab85ce..ee1cc536 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReader.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReader.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.crypto; +package com.dremio.iceberg.authmgr.oauth2.agent.crypto; import java.io.Reader; import java.nio.file.Files; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReader.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReader.java similarity index 93% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReader.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReader.java index 02560728..c202963e 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReader.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReader.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.crypto; +package com.dremio.iceberg.authmgr.oauth2.agent.crypto; import java.io.BufferedReader; import java.io.IOException; @@ -25,7 +25,7 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; -import org.apache.commons.codec.binary.Base64; +import java.util.Base64; final class JcaPemReader implements PemReader { @@ -34,7 +34,7 @@ final class JcaPemReader implements PemReader { @Override public PrivateKey readPrivateKey(Path file) { try { - byte[] encoded = Base64.decodeBase64(readPemEncodedPrivateKey(file)); + byte[] encoded = Base64.getDecoder().decode(readPemEncodedPrivateKey(file)); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded); InvalidKeySpecException toThrow = null; for (String algorithm : ALGORITHMS) { @@ -57,7 +57,7 @@ public PrivateKey readPrivateKey(Path file) { @Override public PublicKey readPublicKey(Path file) { try { - byte[] encoded = Base64.decodeBase64(readPemEncodedPublicKey(file)); + byte[] encoded = Base64.getDecoder().decode(readPemEncodedPublicKey(file)); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encoded); InvalidKeySpecException toThrow = null; for (String algorithm : ALGORITHMS) { diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/PemReader.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/PemReader.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/PemReader.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/PemReader.java index ab85679c..e208ab30 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/crypto/PemReader.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/PemReader.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.crypto; +package com.dremio.iceberg.authmgr.oauth2.agent.crypto; import java.nio.file.Path; import java.security.PrivateKey; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContext.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContext.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContext.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContext.java index da729cb3..69c531d7 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContext.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContext.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.dpop; +package com.dremio.iceberg.authmgr.oauth2.agent.dpop; -import com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils; -import com.dremio.iceberg.authmgr.oauth2.config.DpopConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DpopConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCache.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCache.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCache.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCache.java index c458153e..ef489281 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCache.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.dpop; +package com.dremio.iceberg.authmgr.oauth2.agent.dpop; import com.nimbusds.openid.connect.sdk.Nonce; import java.util.Objects; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopScope.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopScope.java similarity index 94% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopScope.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopScope.java index 8af950cc..ce29a3c4 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopScope.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopScope.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.dpop; +package com.dremio.iceberg.authmgr.oauth2.agent.dpop; /** * Identifies the issuer of a DPoP nonce (RFC 9449 §8). Nonces are issuer-scoped: a nonce issued by diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProvider.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProvider.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProvider.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProvider.java index 0bbfb8ce..0698a19a 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProvider.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProvider.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.endpoint; +package com.dremio.iceberg.authmgr.oauth2.agent.endpoint; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.nimbusds.oauth2.sdk.AbstractConfigurationRequest; @@ -38,7 +38,7 @@ @AuthManagerImmutable public abstract class EndpointProvider { - public static EndpointProvider create(OAuth2Config spec, HTTPRequestSender httpClient) { + public static EndpointProvider create(OAuth2AgentConfig spec, HTTPRequestSender httpClient) { Builder builder = builder().httpClient(httpClient); spec.getBasicConfig().getIssuerUrl().ifPresent(builder::issuerUrl); spec.getBasicConfig().getTokenEndpoint().ifPresent(builder::tokenEndpoint); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AbstractFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AbstractFlow.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AbstractFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AbstractFlow.java index 2d4312e0..c8f00fe1 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AbstractFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AbstractFlow.java @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_BASIC; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_JWT; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_POST; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.PRIVATE_KEY_JWT; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.crypto.PemReader; -import com.dremio.iceberg.authmgr.oauth2.dpop.DpopContext; -import com.dremio.iceberg.authmgr.oauth2.dpop.DpopScope; -import com.dremio.iceberg.authmgr.oauth2.endpoint.EndpointProvider; +import com.dremio.iceberg.authmgr.oauth2.agent.crypto.PemReader; +import com.dremio.iceberg.authmgr.oauth2.agent.dpop.DpopContext; +import com.dremio.iceberg.authmgr.oauth2.agent.dpop.DpopScope; +import com.dremio.iceberg.authmgr.oauth2.agent.endpoint.EndpointProvider; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; @@ -87,7 +87,7 @@ static String getMsgPrefix(String agentName) { interface Builder> { @CanIgnoreReturnValue - B config(OAuth2Config config); + B config(OAuth2AgentConfig config); @CanIgnoreReturnValue B runtime(OAuth2AgentRuntime runtime); @@ -104,7 +104,7 @@ interface Builder> { F build(); } - abstract OAuth2Config getConfig(); + abstract OAuth2AgentConfig getConfig(); abstract OAuth2AgentRuntime getRuntime(); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlow.java similarity index 99% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlow.java index 64ee2ad2..743773d2 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlow.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import static java.net.HttpURLConnection.HTTP_OK; -import com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.errorprone.annotations.FormatMethod; import com.nimbusds.oauth2.sdk.AuthorizationCode; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlow.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlow.java index 8083e89d..6d8cac69 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.AuthorizationGrant; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlow.java similarity index 99% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlow.java index e81e7dfd..0ba28f30 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.GrantType; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/Flow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/Flow.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/Flow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/Flow.java index 9ab96f09..d7685ac1 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/Flow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/Flow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.nimbusds.oauth2.sdk.GrantType; import java.util.concurrent.CompletionStage; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/FlowFactory.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/FlowFactory.java similarity index 89% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/FlowFactory.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/FlowFactory.java index 4eef6968..aa8b1ec2 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/FlowFactory.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/FlowFactory.java @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.dpop.DpopContext; -import com.dremio.iceberg.authmgr.oauth2.endpoint.EndpointProvider; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClient; -import com.dremio.iceberg.authmgr.oauth2.jwtbearer.AssertionSupplier; -import com.dremio.iceberg.authmgr.oauth2.tokenexchange.ActorTokenSupplier; -import com.dremio.iceberg.authmgr.oauth2.tokenexchange.SubjectTokenSupplier; +import com.dremio.iceberg.authmgr.oauth2.agent.dpop.DpopContext; +import com.dremio.iceberg.authmgr.oauth2.agent.endpoint.EndpointProvider; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClient; +import com.dremio.iceberg.authmgr.oauth2.agent.jwtbearer.AssertionSupplier; +import com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange.ActorTokenSupplier; +import com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange.SubjectTokenSupplier; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.token.RefreshToken; @@ -33,7 +33,7 @@ @AuthManagerImmutable public abstract class FlowFactory implements AutoCloseable { - public static FlowFactory create(OAuth2Config config, OAuth2AgentRuntime runtime) { + public static FlowFactory create(OAuth2AgentConfig config, OAuth2AgentRuntime runtime) { return ImmutableFlowFactory.builder().config(config).runtime(runtime).build(); } @@ -91,7 +91,7 @@ public FlowFactory copy() { .build(); } - protected abstract OAuth2Config getConfig(); + protected abstract OAuth2AgentConfig getConfig(); protected abstract OAuth2AgentRuntime getRuntime(); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlow.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlow.java index e8d09aea..fd7220a8 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.errorprone.annotations.CanIgnoreReturnValue; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/OAuth2Exception.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/OAuth2Exception.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/OAuth2Exception.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/OAuth2Exception.java index 23e41b8b..18fa3d3c 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/OAuth2Exception.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/OAuth2Exception.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.nimbusds.oauth2.sdk.ErrorObject; import com.nimbusds.oauth2.sdk.ErrorResponse; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlow.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlow.java index 68ffe9d2..793e8ceb 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.GrantType; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlow.java similarity index 97% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlow.java index a68c6578..9f039667 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.errorprone.annotations.CanIgnoreReturnValue; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlow.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlow.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlow.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlow.java index 6668577f..b14e98dd 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlow.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlow.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.nimbusds.oauth2.sdk.AuthorizationGrant; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokensResult.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokensResult.java similarity index 99% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokensResult.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokensResult.java index 92d98a0f..5711f4a7 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/flow/TokensResult.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokensResult.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.jwt.JWTParser; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/ApacheHttpClient.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/ApacheHttpClient.java similarity index 98% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/ApacheHttpClient.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/ApacheHttpClient.java index 118920b2..2a1e9a95 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/ApacheHttpClient.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/ApacheHttpClient.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.http; +package com.dremio.iceberg.authmgr.oauth2.agent.http; -import com.dremio.iceberg.authmgr.oauth2.config.HttpConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.HttpConfig; import com.nimbusds.oauth2.sdk.http.HTTPRequest; import com.nimbusds.oauth2.sdk.http.HTTPResponse; import com.nimbusds.oauth2.sdk.http.ReadOnlyHTTPRequest; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClient.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClient.java similarity index 96% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClient.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClient.java index 5dfdf131..3be69a4f 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClient.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClient.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.http; +package com.dremio.iceberg.authmgr.oauth2.agent.http; import com.nimbusds.oauth2.sdk.http.HTTPRequest; import com.nimbusds.oauth2.sdk.http.HTTPRequestSender; diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClientType.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClientType.java similarity index 92% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClientType.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClientType.java index e2947af6..9decedd5 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/http/HttpClientType.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/http/HttpClientType.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.http; +package com.dremio.iceberg.authmgr.oauth2.agent.http; -import com.dremio.iceberg.authmgr.oauth2.config.HttpConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.HttpConfig; import com.google.errorprone.annotations.MustBeClosed; public enum HttpClientType { diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplier.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplier.java similarity index 88% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplier.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplier.java index 373af0ac..15160070 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplier.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplier.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.jwtbearer; +package com.dremio.iceberg.authmgr.oauth2.agent.jwtbearer; -import static com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils.prefixedMap; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils.prefixedMap; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.SystemConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.id.Identifier; @@ -41,7 +41,7 @@ @AuthManagerImmutable public abstract class AssertionSupplier implements AutoCloseable { - public static AssertionSupplier create(OAuth2Config config, OAuth2AgentRuntime runtime) { + public static AssertionSupplier create(OAuth2AgentConfig config, OAuth2AgentRuntime runtime) { return ImmutableAssertionSupplier.builder().mainConfig(config).runtime(runtime).build(); } @@ -97,7 +97,7 @@ protected OAuth2Agent getAssertionAgent() { assertionAgentProperties.put( SystemConfig.PREFIX + '.' + SystemConfig.AGENT_NAME, getDefaultAgentName()); } - OAuth2Config assertionAgentConfig = OAuth2Config.from(assertionAgentProperties); + OAuth2AgentConfig assertionAgentConfig = OAuth2AgentConfig.from(assertionAgentProperties); return new OAuth2Agent(assertionAgentConfig, getRuntime()); } @@ -111,7 +111,7 @@ public void close() { @Value.Derived protected Map getAssertionAgentConfig() { return prefixedMap( - getMainConfig().getJwtBearerGrantConfig().getAssertionConfig(), OAuth2Config.PREFIX); + getMainConfig().getJwtBearerGrantConfig().getAssertionConfig(), OAuth2AgentConfig.PREFIX); } @Value.Derived @@ -135,7 +135,7 @@ protected String getDefaultAgentName() { return getMainConfig().getSystemConfig().getAgentName() + "-assertion"; } - protected abstract OAuth2Config getMainConfig(); + protected abstract OAuth2AgentConfig getMainConfig(); protected abstract OAuth2AgentRuntime getRuntime(); } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/AbstractTokenSupplier.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/AbstractTokenSupplier.java similarity index 90% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/AbstractTokenSupplier.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/AbstractTokenSupplier.java index 3c85edab..32ce8813 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/AbstractTokenSupplier.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/AbstractTokenSupplier.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.tokenexchange; +package com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange; -import static com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils.prefixedMap; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils.prefixedMap; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.SystemConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.BearerAccessToken; @@ -91,7 +91,7 @@ protected OAuth2Agent getTokenAgent() { tokenAgentProperties.put( SystemConfig.PREFIX + '.' + SystemConfig.AGENT_NAME, getDefaultAgentName()); } - OAuth2Config tokenAgentConfig = OAuth2Config.from(tokenAgentProperties); + OAuth2AgentConfig tokenAgentConfig = OAuth2AgentConfig.from(tokenAgentProperties); return new OAuth2Agent(tokenAgentConfig, getRuntime()); } @@ -121,10 +121,10 @@ public void close() { @Value.Derived protected Map getTokenAgentConfig() { - return prefixedMap(getDynamicTokenConfig(), OAuth2Config.PREFIX); + return prefixedMap(getDynamicTokenConfig(), OAuth2AgentConfig.PREFIX); } - protected abstract OAuth2Config getMainConfig(); + protected abstract OAuth2AgentConfig getMainConfig(); protected abstract OAuth2AgentRuntime getRuntime(); diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplier.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplier.java similarity index 87% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplier.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplier.java index 67039754..66d0c9c4 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplier.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplier.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.tokenexchange; +package com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.token.TokenTypeURI; import com.nimbusds.oauth2.sdk.token.TypelessAccessToken; @@ -28,7 +28,7 @@ @AuthManagerImmutable public abstract class ActorTokenSupplier extends AbstractTokenSupplier { - public static ActorTokenSupplier create(OAuth2Config config, OAuth2AgentRuntime runtime) { + public static ActorTokenSupplier create(OAuth2AgentConfig config, OAuth2AgentRuntime runtime) { return ImmutableActorTokenSupplier.builder().mainConfig(config).runtime(runtime).build(); } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplier.java b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplier.java similarity index 89% rename from oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplier.java rename to oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplier.java index dff7cf61..2c31ebab 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplier.java +++ b/oauth2/agent/src/main/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplier.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.tokenexchange; +package com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.nimbusds.oauth2.sdk.token.TokenTypeURI; import com.nimbusds.oauth2.sdk.token.TypelessAccessToken; @@ -29,7 +29,7 @@ @AuthManagerImmutable public abstract class SubjectTokenSupplier extends AbstractTokenSupplier { - public static SubjectTokenSupplier create(OAuth2Config config, OAuth2AgentRuntime runtime) { + public static SubjectTokenSupplier create(OAuth2AgentConfig config, OAuth2AgentRuntime runtime) { return ImmutableSubjectTokenSupplier.builder().mainConfig(config).runtime(runtime).build(); } diff --git a/oauth2/core/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/oauth2/agent/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor similarity index 88% rename from oauth2/core/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor rename to oauth2/agent/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor index 87f04f39..8266535e 100644 --- a/oauth2/core/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor +++ b/oauth2/agent/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor @@ -14,4 +14,4 @@ # limitations under the License. # -com.dremio.iceberg.authmgr.oauth2.config.ConfigRelocationInterceptor \ No newline at end of file +com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigRelocationInterceptor \ No newline at end of file diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfigTest.java similarity index 93% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfigTest.java index 36466b37..bf7783b7 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentConfigTest.java @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2; +package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig; -import com.dremio.iceberg.authmgr.oauth2.config.ResourceOwnerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ResourceOwnerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.google.common.collect.ImmutableMap; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.oauth2.sdk.GrantType; @@ -48,7 +48,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.junitpioneer.jupiter.RestoreSystemProperties; -class OAuth2ConfigTest { +class OAuth2AgentConfigTest { @TempDir static Path tempDir; @@ -68,7 +68,7 @@ void testFromPropertiesMap() { .put(PREFIX + '.' + BasicConfig.CLIENT_SECRET, "w00t") .put(PREFIX + '.' + BasicConfig.SCOPE, "test") .build(); - OAuth2Config config = OAuth2Config.from(properties); + OAuth2AgentConfig config = OAuth2AgentConfig.from(properties); assertThat(config).isNotNull(); assertThat(config.getBasicConfig().getTokenEndpoint()) .contains(URI.create("https://example.com/token")); @@ -87,7 +87,7 @@ void testFromSystemProperties() { System.setProperty(PREFIX + '.' + BasicConfig.CLIENT_ID, "Client"); System.setProperty(PREFIX + '.' + BasicConfig.CLIENT_SECRET, "w00t"); System.setProperty(PREFIX + '.' + BasicConfig.SCOPE, "test"); - OAuth2Config config = OAuth2Config.from(Map.of()); + OAuth2AgentConfig config = OAuth2AgentConfig.from(Map.of()); assertThat(config).isNotNull(); assertThat(config.getBasicConfig().getTokenEndpoint()) .contains(URI.create("https://example.com/token")); @@ -114,7 +114,7 @@ void testLegacyPrefixRelocation() { .put(PREFIX + ".client-assertion.jwt.algorithm", "RS256") .put(PREFIX + ".client-assertion.jwt.private-key", tempFile.toString()) .build(); - OAuth2Config config = OAuth2Config.from(properties); + OAuth2AgentConfig config = OAuth2AgentConfig.from(properties); assertThat(config.getAuthorizationCodeConfig().isCallbackHttps()).isTrue(); assertThat(config.getAuthorizationCodeConfig().getCallbackBindHost()).hasValue("example.com"); assertThat(config.getAuthorizationCodeConfig().getCallbackBindPort()).hasValue(8080); @@ -137,7 +137,7 @@ void testLegacyPrefixRelocationFromSystemProperties() { System.setProperty(PREFIX + ".auth-code.callback-context-path", "/context"); System.setProperty(PREFIX + ".client-assertion.jwt.algorithm", "RS256"); System.setProperty(PREFIX + ".client-assertion.jwt.private-key", tempFile.toString()); - OAuth2Config config = OAuth2Config.from(Map.of()); + OAuth2AgentConfig config = OAuth2AgentConfig.from(Map.of()); assertThat(config.getAuthorizationCodeConfig().isCallbackHttps()).isTrue(); assertThat(config.getAuthorizationCodeConfig().getCallbackBindHost()).hasValue("example.com"); assertThat(config.getAuthorizationCodeConfig().getCallbackBindPort()).hasValue(8080); @@ -159,7 +159,7 @@ void testLegacyNestedPrefixRelocation() { GrantType.AUTHORIZATION_CODE.getValue()) .put("rest.auth.oauth2.token-exchange.subject-token.auth-code.callback-https", "true") .build(); - OAuth2Config config = OAuth2Config.from(properties); + OAuth2AgentConfig config = OAuth2AgentConfig.from(properties); assertThat(config.getTokenExchangeConfig().getSubjectTokenConfig()) .containsEntry(BasicConfig.GRANT_TYPE, GrantType.AUTHORIZATION_CODE.getValue()) .containsEntry( @@ -171,7 +171,7 @@ void testLegacyNestedPrefixRelocation() { void testFromUnknownProperty() { Map properties = ImmutableMap.builder().put(PREFIX + ".unknown", "test").build(); - assertThatThrownBy(() -> OAuth2Config.from(properties)) + assertThatThrownBy(() -> OAuth2AgentConfig.from(properties)) .isInstanceOf(ConfigValidationException.class) .hasMessageContaining( PREFIX + ".unknown in catalog session properties does not map to any root"); @@ -186,14 +186,14 @@ void testFromRemovedProperties() { .put(PREFIX + '.' + BasicConfig.CLIENT_SECRET, "s3cr3t") .put(PREFIX + ".device-code.poll-interval", "PT10S") .build(); - assertThat(OAuth2Config.from(properties)).isNotNull(); + assertThat(OAuth2AgentConfig.from(properties)).isNotNull(); } @ParameterizedTest @MethodSource void testValidate(Map properties, List expected) { assertThatIllegalArgumentException() - .isThrownBy(() -> OAuth2Config.from(properties)) + .isThrownBy(() -> OAuth2AgentConfig.from(properties)) .withMessage(ConfigValidator.buildDescription(expected.stream())); } diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java similarity index 93% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java index 3d87c66d..95bd91b3 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/OAuth2AgentTest.java @@ -15,14 +15,14 @@ */ package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_LIFESPAN; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SUBJECT_TOKEN; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertAccessToken; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_LIFESPAN; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SUBJECT_TOKEN; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertAccessToken; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.InstanceOfAssertFactories.ATOMIC_BOOLEAN; @@ -38,15 +38,11 @@ import static org.mockserver.model.HttpResponse.response; import static org.mockserver.verify.VerificationTimes.atLeast; -import com.dremio.iceberg.authmgr.oauth2.flow.OAuth2Exception; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestClock; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; -import com.dremio.iceberg.authmgr.oauth2.test.user.UserBehavior; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.OAuth2Exception; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.user.UserBehavior; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.util.Base64URL; import com.nimbusds.jwt.JWTClaimsSet; @@ -97,7 +93,7 @@ void testClientCredentials( @EnumLike(excludes = "none") ClientAuthenticationMethod authenticationMethod, @Values(booleans = {true, false}) boolean returnRefreshTokens) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) @@ -112,7 +108,7 @@ void testClientCredentials( @Test void testClientCredentialsUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder().clientId(new ClientID("WrongClient")).build(); + ImmutableTestEnvironment.builder().clientId(new ClientID("WrongClient")).build(); OAuth2Agent agent = env.newAgent()) { soft.assertThatThrownBy(agent::authenticate) .asInstanceOf(throwable(OAuth2Exception.class)) @@ -131,7 +127,7 @@ void testPassword( @EnumLike ClientAuthenticationMethod authenticationMethod, @Values(booleans = {true, false}) boolean returnRefreshTokens) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.PASSWORD) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -147,7 +143,7 @@ void testPassword( @Test void testPasswordUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.PASSWORD) .password(new Secret("WrongPassword")) .build(); @@ -169,7 +165,7 @@ void testAuthorizationCode( @EnumLike ClientAuthenticationMethod authenticationMethod, @Values(booleans = {true, false}) boolean returnRefreshTokens) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -185,7 +181,7 @@ void testAuthorizationCode( @Test void testAuthorizationCodeTimeout() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .timeout(Duration.ofMillis(10)) .forceInactiveUser(true) @@ -201,7 +197,7 @@ void testAuthorizationCodeTimeout() { @Test void testAuthorizationCodeUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .userBehavior(UserBehavior.builder().emulateFailure(true).build()) .build(); @@ -223,7 +219,7 @@ void testDeviceCode( @EnumLike ClientAuthenticationMethod authenticationMethod, @Values(booleans = {true, false}) boolean returnRefreshTokens) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.DEVICE_CODE) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -239,7 +235,7 @@ void testDeviceCode( @Test void testDeviceCodeTimeout() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.DEVICE_CODE) .timeout(Duration.ofMillis(10)) .forceInactiveUser(true) @@ -255,7 +251,7 @@ void testDeviceCodeTimeout() { @Test void testDeviceCodeUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.DEVICE_CODE) .timeout(Duration.ofSeconds(1)) .userBehavior(UserBehavior.builder().emulateFailure(true).build()) @@ -276,7 +272,7 @@ void testRefreshToken( @Values(booleans = {true, false}) boolean returnRefreshTokenLifespan) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.PASSWORD) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -296,7 +292,7 @@ void testRefreshToken( @Test void testRefreshTokenMustFetchNewTokens() { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (TestEnvironment env = ImmutableTestEnvironment.builder().build(); OAuth2Agent agent = env.newAgent()) { // no refresh token TokensResult currentTokens = @@ -358,7 +354,7 @@ void testTokenExchangeStaticSubjectActor( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws ExecutionException, InterruptedException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -391,7 +387,7 @@ void testTokenExchangeDynamicSubject( !subjectGrantType.equals(GrantType.CLIENT_CREDENTIALS) || !authenticationMethod.equals(ClientAuthenticationMethod.NONE)); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .httpClientType(httpClientType) .subjectToken(null) @@ -426,7 +422,7 @@ void testTokenExchangeDynamicActor( !actorGrantType.equals(GrantType.CLIENT_CREDENTIALS) || !authenticationMethod.equals(ClientAuthenticationMethod.NONE)); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .httpClientType(httpClientType) .actorToken(null) @@ -448,7 +444,7 @@ void testTokenExchangeDynamicActor( @Test void testTokenExchangeSubjectUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .subjectToken(new TypelessAccessToken("WrongSubjectToken")) .build(); @@ -467,7 +463,7 @@ void testTokenExchangeSubjectUnauthorized() { @Test void testTokenExchangeActorUnauthorized() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .actorToken(new TypelessAccessToken("WrongActorToken")) .build(); @@ -490,7 +486,7 @@ void testJwtBearerStaticAssertion( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws ExecutionException, InterruptedException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .httpClientType(httpClientType) .clientAuthenticationMethod(authenticationMethod) @@ -523,7 +519,7 @@ void testJwtBearerDynamicAssertion( !assertionGrantType.equals(GrantType.CLIENT_CREDENTIALS) || !authenticationMethod.equals(ClientAuthenticationMethod.NONE)); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .httpClientType(httpClientType) .assertion(null) @@ -545,7 +541,7 @@ void testJwtBearerDynamicAssertion( @Test void testJwtBearerAssertionNotJwt() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .assertion("NotAValidJWT") .build(); @@ -562,7 +558,7 @@ void testJwtBearerAssertionNotJwt() { @Test void testJwtBearerAssertionInvalid() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .assertion(SUBJECT_TOKEN /* invalid JWT */) .build(); @@ -582,7 +578,7 @@ void testJwtBearerAssertionInvalid() { @EnumSource(HttpClientType.class) void testStaticToken(@Enum HttpClientType httpClientType) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .httpClientType(httpClientType) .token(new TypelessAccessToken(ACCESS_TOKEN_INITIAL)) .build(); @@ -601,7 +597,7 @@ void testStaticToken(@Enum HttpClientType httpClientType) { void testSsl() { TestCertificates certs = TestCertificates.instance(); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .ssl(true) .httpClientType(HttpClientType.APACHE) .sslTrustStorePath(certs.getMockServerKeyStore()) @@ -621,7 +617,7 @@ void testSsl() { @Test void testSslTrustAll() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .ssl(true) .httpClientType(HttpClientType.APACHE) .sslTrustAll(true) @@ -635,7 +631,7 @@ void testSslTrustAll() { void testProxy() { try (ClientAndServer proxyServer = ClientAndServer.startClientAndServer(); TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .httpClientType(HttpClientType.APACHE) .proxyHost("localhost") .proxyPort(proxyServer.getLocalPort()) @@ -662,7 +658,7 @@ void testProxy() { void testProxyAuthentication() { try (ClientAndServer proxyServer = ClientAndServer.startClientAndServer(); TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .httpClientType(HttpClientType.APACHE) .proxyHost("localhost") .proxyPort(proxyServer.getLocalPort()) @@ -709,7 +705,7 @@ void testProxyAuthentication() { @Test void testCopyAfterSuccessfulAuth() throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .subjectToken(null) .actorToken(null) @@ -762,7 +758,7 @@ void testCopyAfterSuccessfulAuth() throws InterruptedException, ExecutionExcepti @Test void testCopyAfterFailedAuth() throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .subjectToken(null) .actorToken(null) @@ -822,7 +818,10 @@ void testSleepWakeUp() { AtomicReference currentRenewalTask = mockExecutorSchedule(executor); try (TestEnvironment env = - TestEnvironment.builder().grantType(GrantType.PASSWORD).executor(executor).build(); + ImmutableTestEnvironment.builder() + .grantType(GrantType.PASSWORD) + .executor(executor) + .build(); OAuth2Agent agent = env.newAgent()) { // should fetch the initial token @@ -876,7 +875,7 @@ void testExecutionRejectedOnInitialTokenFetch() { // throws RejectedExecutionException immediately. try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.CLIENT_CREDENTIALS) .executor(executor) .build(); @@ -909,7 +908,7 @@ void testExecutionRejectedOnTokenRefreshes() { // then schedule a new refresh. If that refresh is rejected again, sleep mode is reactivated. try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.CLIENT_CREDENTIALS) .executor(executor) .build(); @@ -946,7 +945,7 @@ void testFailureRecovery() { AtomicReference currentRenewalTask = mockExecutorSchedule(executor); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.PASSWORD) .executor(executor) .createDefaultExpectations(false) @@ -1040,7 +1039,7 @@ void testFailureRecovery() { @Test void testApplyAuthenticationBearer() { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (TestEnvironment env = ImmutableTestEnvironment.builder().build(); OAuth2Agent agent = env.newAgent()) { Map headers = new LinkedHashMap<>(); @@ -1055,7 +1054,10 @@ void testApplyAuthenticationBearer() { @Test void testApplyAuthenticationDpop() throws Exception { try (TestEnvironment env = - TestEnvironment.builder().dpopEnabled(true).dpopAlgorithm(JWSAlgorithm.ES256).build(); + ImmutableTestEnvironment.builder() + .dpopEnabled(true) + .dpopAlgorithm(JWSAlgorithm.ES256) + .build(); OAuth2Agent agent = env.newAgent()) { URI rsUri = URI.create("https://rs.example.com/warehouse1"); diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseablesTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseablesTest.java similarity index 96% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseablesTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseablesTest.java index 95e36937..ee436813 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/AutoCloseablesTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/AutoCloseablesTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.concurrent; +package com.dremio.iceberg.authmgr.oauth2.agent.concurrent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.dremio.iceberg.authmgr.oauth2.concurrent.AutoCloseables.UncheckedAutoCloseable; +import com.dremio.iceberg.authmgr.oauth2.agent.concurrent.AutoCloseables.UncheckedAutoCloseable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/FuturesTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/FuturesTest.java similarity index 97% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/FuturesTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/FuturesTest.java index 3a53872a..a5ea62dd 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/concurrent/FuturesTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/concurrent/FuturesTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.concurrent; +package com.dremio.iceberg.authmgr.oauth2.agent.concurrent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfigTest.java similarity index 84% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfigTest.java index 82dc48d6..953ec9ae 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/AuthorizationCodeConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/AuthorizationCodeConfigTest.java @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.CALLBACK_BIND_PORT; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.ENDPOINT; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.PKCE_METHOD; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.SSL_KEYSTORE_ALIAS; -import static com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig.SSL_KEYSTORE_PATH; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.CALLBACK_BIND_PORT; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.ENDPOINT; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.PKCE_METHOD; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.SSL_KEYSTORE_ALIAS; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig.SSL_KEYSTORE_PATH; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfigTest.java similarity index 98% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfigTest.java index bd80dd36..b21484d6 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/BasicConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/BasicConfigTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import io.smallrye.config.SmallRyeConfig; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptorTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptorTest.java similarity index 99% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptorTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptorTest.java index fc50c270..6e38267d 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigRelocationInterceptorTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigRelocationInterceptorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; import static org.assertj.core.api.Assertions.assertThat; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtilsTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtilsTest.java similarity index 98% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtilsTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtilsTest.java index c9e61423..3187b128 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/ConfigUtilsTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/ConfigUtilsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; import static org.assertj.core.api.Assertions.assertThat; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfigTest.java similarity index 89% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfigTest.java index e3409b78..2f4742aa 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DeviceCodeConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DeviceCodeConfigTest.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.DeviceCodeConfig.ENDPOINT; -import static com.dremio.iceberg.authmgr.oauth2.config.DeviceCodeConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.DeviceCodeConfig.ENDPOINT; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.DeviceCodeConfig.PREFIX; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfigTest.java similarity index 93% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfigTest.java index dfc0253b..d3791a7b 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/DpopConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/DpopConfigTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.DpopConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.DpopConfig.PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.jose.JWSAlgorithm; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfigTest.java similarity index 91% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfigTest.java index ee4ea6a8..55edf0ef 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/HttpConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/HttpConfigTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.HttpConfig.SSL_TRUSTSTORE_PATH; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.HttpConfig.SSL_TRUSTSTORE_PATH; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfigTest.java similarity index 85% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfigTest.java index 6b74c053..72f685ce 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtBearerConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtBearerConfigTest.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig.ASSERTION_FILE; -import static com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig.ASSERTION_FILE; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig.PREFIX; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfigTest.java similarity index 96% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfigTest.java index afb6e517..deb42cfa 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/JwtClientAuthConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/JwtClientAuthConfigTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig.PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.nimbusds.oauth2.sdk.id.Audience; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfigTest.java similarity index 86% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfigTest.java index c75c50f1..12573809 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/SystemConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/SystemConfigTest.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.SystemConfig.AGENT_NAME; -import static com.dremio.iceberg.authmgr.oauth2.config.SystemConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig.AGENT_NAME; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig.PREFIX; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfigTest.java similarity index 91% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfigTest.java index 7bbb841a..03f11b2f 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenExchangeConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenExchangeConfigTest.java @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.ACTOR_TOKEN_FILE; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.AUDIENCES; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.RESOURCES; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.SUBJECT_TOKEN; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig.SUBJECT_TOKEN_FILE; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.ACTOR_TOKEN_FILE; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.AUDIENCES; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.RESOURCES; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.SUBJECT_TOKEN; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig.SUBJECT_TOKEN_FILE; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.id.Audience; import io.smallrye.config.SmallRyeConfig; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfigTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfigTest.java similarity index 86% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfigTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfigTest.java index c6ab7988..5f57f131 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/config/TokenRefreshConfigTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/config/TokenRefreshConfigTest.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.config; +package com.dremio.iceberg.authmgr.oauth2.agent.config; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig.ACCESS_TOKEN_LIFESPAN; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig.IDLE_TIMEOUT; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig.SAFETY_WINDOW; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig.ACCESS_TOKEN_LIFESPAN; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig.IDLE_TIMEOUT; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig.SAFETY_WINDOW; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import com.dremio.iceberg.authmgr.oauth2.config.validator.ConfigValidator; +import com.dremio.iceberg.authmgr.oauth2.agent.config.validator.ConfigValidator; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; import io.smallrye.config.common.MapBackedConfigSource; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReaderTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReaderTest.java similarity index 98% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReaderTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReaderTest.java index 86ca86a3..9192c323 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/BouncyCastlePemReaderTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/BouncyCastlePemReaderTest.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.crypto; +package com.dremio.iceberg.authmgr.oauth2.agent.crypto; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; +import com.dremio.iceberg.authmgr.oauth2.agent.TestCertificates; import java.io.IOException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReaderTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReaderTest.java similarity index 96% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReaderTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReaderTest.java index 637d648e..463cd29f 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/crypto/JcaPemReaderTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/crypto/JcaPemReaderTest.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.crypto; +package com.dremio.iceberg.authmgr.oauth2.agent.crypto; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; +import com.dremio.iceberg.authmgr.oauth2.agent.TestCertificates; import java.io.IOException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; @@ -161,6 +161,6 @@ void testReadPemWithInvalidBase64() throws IOException { .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Failed to read PEM file") .rootCause() - .hasMessageContaining("not enough content"); + .hasMessageContaining("Illegal base64 character"); } } diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContextTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContextTest.java similarity index 98% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContextTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContextTest.java index 84128317..9d990890 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopContextTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopContextTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.dpop; +package com.dremio.iceberg.authmgr.oauth2.agent.dpop; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.dremio.iceberg.authmgr.oauth2.config.DpopConfig; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DpopConfig; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSVerifier; import com.nimbusds.jose.crypto.ECDSAVerifier; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCacheTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCacheTest.java similarity index 97% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCacheTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCacheTest.java index fabdc629..44a8429a 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/dpop/DpopNonceCacheTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/dpop/DpopNonceCacheTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.dpop; +package com.dremio.iceberg.authmgr.oauth2.agent.dpop; import static org.assertj.core.api.Assertions.assertThat; diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProviderTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProviderTest.java similarity index 88% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProviderTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProviderTest.java index dc741654..a611485f 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/endpoint/EndpointProviderTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/endpoint/EndpointProviderTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.endpoint; +package com.dremio.iceberg.authmgr.oauth2.agent.endpoint; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchThrowable; import static org.assertj.core.api.InstanceOfAssertFactories.throwable; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClient; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClient; import com.nimbusds.oauth2.sdk.ParseException; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.cartesian.CartesianTest; @@ -38,7 +39,7 @@ class EndpointProviderTest { @Test void withoutDiscovery() { - try (TestEnvironment env = TestEnvironment.builder().discoveryEnabled(false).build()) { + try (TestEnvironment env = ImmutableTestEnvironment.builder().discoveryEnabled(false).build()) { EndpointProvider endpointProvider = EndpointProvider.create(env.getOAuth2Config(), HttpClient.DEFAULT); assertThat(endpointProvider.getResolvedTokenEndpoint()).isEqualTo(env.getTokenEndpoint()); @@ -59,7 +60,7 @@ void withDiscovery( }) String wellKnownPath) { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .includeDeviceAuthEndpointInDiscoveryMetadata(includeDeviceAuthEndpoint) .wellKnownPath(wellKnownPath) .build()) { @@ -82,7 +83,8 @@ void withDiscovery( @Test void fetchOpenIdProviderMetadataWrongEndpoint() { - try (TestEnvironment env = TestEnvironment.builder().createDefaultExpectations(false).build()) { + try (TestEnvironment env = + ImmutableTestEnvironment.builder().createDefaultExpectations(false).build()) { env.createErrorExpectations(); EndpointProvider endpointProvider = EndpointProvider.create(env.getOAuth2Config(), HttpClient.DEFAULT); @@ -106,7 +108,8 @@ void fetchOpenIdProviderMetadataWrongEndpoint() { @Test void fetchOpenIdProviderMetadataWrongData() { - try (TestEnvironment env = TestEnvironment.builder().createDefaultExpectations(false).build()) { + try (TestEnvironment env = + ImmutableTestEnvironment.builder().createDefaultExpectations(false).build()) { TestServer.getInstance() .when(HttpRequest.request().withPath(env.getAuthorizationServerUrl().getPath() + ".*")) .respond( diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlowTest.java similarity index 82% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlowTest.java index 2ba4c209..db03346e 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/AuthorizationCodeFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/AuthorizationCodeFlowTest.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestCertificates; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import com.nimbusds.oauth2.sdk.pkce.CodeChallengeMethod; @@ -42,7 +43,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .clientAuthenticationMethod(authenticationMethod) .pkceEnabled(pkceEnabled) @@ -62,7 +63,7 @@ void fetchNewTokens( void httpsCallback() throws Exception { TestCertificates certs = TestCertificates.instance(); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .callbackHttps(true) .sslKeyStorePath(certs.getMockServerKeyStore()) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlowTest.java similarity index 71% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlowTest.java index b961bdfc..ed914f71 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/ClientCredentialsFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/ClientCredentialsFlowTest.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import java.util.concurrent.ExecutionException; import org.junitpioneer.jupiter.cartesian.CartesianTest; @@ -31,7 +32,9 @@ class ClientCredentialsFlowTest { void fetchNewTokens(@EnumLike(excludes = "none") ClientAuthenticationMethod authenticationMethod) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder().clientAuthenticationMethod(authenticationMethod).build(); + ImmutableTestEnvironment.builder() + .clientAuthenticationMethod(authenticationMethod) + .build(); FlowFactory flowFactory = env.newFlowFactory()) { Flow flow = flowFactory.createInitialFlow(); assertThat(flow).isInstanceOf(ClientCredentialsFlow.class); diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlowTest.java similarity index 75% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlowTest.java index 7c19add3..141c3859 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DeviceCodeFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DeviceCodeFlowTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import java.util.concurrent.ExecutionException; @@ -36,7 +37,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws ExecutionException, InterruptedException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.DEVICE_CODE) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DpopFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DpopFlowTest.java similarity index 90% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DpopFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DpopFlowTest.java index 541a3a31..fdd99b1d 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/DpopFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/DpopFlowTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSVerifier; import com.nimbusds.jose.crypto.ECDSAVerifier; @@ -48,7 +49,7 @@ void testDpop( || initialGrantType != GrantType.CLIENT_CREDENTIALS); try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .clientAuthenticationMethod(authenticationMethod) .grantType(initialGrantType) .dpopEnabled(true) @@ -92,7 +93,7 @@ void testDpop( @Test void testDpopNonceChallengeTriggersRetryWithNonce() throws Exception { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .dpopEnabled(true) .requireDpopNonce(true) .dpopAlgorithm(JWSAlgorithm.ES256) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlowTest.java similarity index 85% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlowTest.java index 17bff40c..5b2e3495 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/JwtBearerFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/JwtBearerFlowTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.ParseException; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; @@ -39,7 +40,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) @@ -66,7 +67,7 @@ void fetchNewTokensDynamic( GrantType assertionGrantType) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .clientAuthenticationMethod(authenticationMethod) .executorPoolSize(2) @@ -86,7 +87,7 @@ void fetchNewTokensDynamic( @Test void fetchNewTokensInvalidAssertion() { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.JWT_BEARER) .assertion("InvalidJWT") .build(); diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlowTest.java similarity index 75% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlowTest.java index 2de4fe16..4074a7ff 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/PasswordFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/PasswordFlowTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import java.util.concurrent.ExecutionException; @@ -36,7 +37,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.PASSWORD) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlowTest.java similarity index 77% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlowTest.java index 8a68b54d..a5a9f1ee 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/RefreshTokenFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/RefreshTokenFlowTest.java @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import com.nimbusds.oauth2.sdk.token.RefreshToken; @@ -40,7 +41,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokenLifespan) throws ExecutionException, InterruptedException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.AUTHORIZATION_CODE) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlowTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlowTest.java similarity index 86% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlowTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlowTest.java index df20abbc..070b4026 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/flow/TokenExchangeFlowTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/flow/TokenExchangeFlowTest.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.flow; +package com.dremio.iceberg.authmgr.oauth2.agent.flow; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TokenAssertions.assertTokensResult; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TokenAssertions.assertTokensResult; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.junit.EnumLike; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.junit.EnumLike; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import com.nimbusds.oauth2.sdk.token.TokenTypeURI; @@ -43,7 +44,7 @@ void fetchNewTokens( @Values(booleans = {true, false}) boolean returnRefreshTokens) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .clientAuthenticationMethod(authenticationMethod) .returnRefreshTokens(returnRefreshTokens) @@ -75,7 +76,7 @@ void fetchNewTokensDynamic( GrantType actorGrantType) throws InterruptedException, ExecutionException { try (TestEnvironment env = - TestEnvironment.builder() + ImmutableTestEnvironment.builder() .grantType(GrantType.TOKEN_EXCHANGE) .clientAuthenticationMethod(authenticationMethod) // increase concurrency so that token fetches can happen in parallel diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplierTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplierTest.java similarity index 80% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplierTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplierTest.java index f419b64c..ede0bc81 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/jwtbearer/AssertionSupplierTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/jwtbearer/AssertionSupplierTest.java @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.jwtbearer; +package com.dremio.iceberg.authmgr.oauth2.agent.jwtbearer; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ASSERTION_TOKEN; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ASSERTION_TOKEN; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.mock; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; import io.smallrye.config.SmallRyeConfig; @@ -42,7 +42,7 @@ class AssertionSupplierTest { @Test void testSupplyAssertionAsyncStatic() { - OAuth2Config config = createMainConfig(ASSERTION_TOKEN, null, Map.of()); + OAuth2AgentConfig config = createMainConfig(ASSERTION_TOKEN, null, Map.of()); try (AssertionSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyAssertionAsync(); assertThat(stage).isCompleted(); @@ -52,7 +52,7 @@ void testSupplyAssertionAsyncStatic() { @Test void testSupplyAssertionAsyncDynamic() { - OAuth2Config config = + OAuth2AgentConfig config = createMainConfig( null, null, @@ -74,7 +74,7 @@ void testSupplyAssertionAsyncDynamic() { @Test @SuppressWarnings("resource") void testValidate() { - OAuth2Config config = createInvalidMainConfig(); + OAuth2AgentConfig config = createInvalidMainConfig(); assertThatIllegalArgumentException() .isThrownBy(() -> createSupplier(config)) .withMessage("Assertion is required"); @@ -84,7 +84,7 @@ void testValidate() { void testSupplyAssertionAsyncFromFile(@TempDir Path tempDir) throws Exception { Path assertionFile = tempDir.resolve("assertion.txt"); Files.writeString(assertionFile, " " + ASSERTION_TOKEN + " "); - OAuth2Config config = createMainConfig(null, assertionFile, Map.of()); + OAuth2AgentConfig config = createMainConfig(null, assertionFile, Map.of()); try (AssertionSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyAssertionAsync(); assertThat(stage).isCompleted(); @@ -92,20 +92,20 @@ void testSupplyAssertionAsyncFromFile(@TempDir Path tempDir) throws Exception { } } - private static OAuth2Config createMainConfig( + private static OAuth2AgentConfig createMainConfig( String assertion, Path assertionFile, Map assertionConfig) { - return OAuth2Config.from(createProperties(assertion, assertionFile, assertionConfig)); + return OAuth2AgentConfig.from(createProperties(assertion, assertionFile, assertionConfig)); } - private static OAuth2Config createInvalidMainConfig() { + private static OAuth2AgentConfig createInvalidMainConfig() { SmallRyeConfig smallRyeConfig = new SmallRyeConfigBuilder() .withSources( new MapBackedConfigSource( "catalog properties", createProperties(null, null, Map.of()), 200) {}) - .withMapping(OAuth2Config.class) + .withMapping(OAuth2AgentConfig.class) .build(); - return smallRyeConfig.getConfigMapping(OAuth2Config.class); + return smallRyeConfig.getConfigMapping(OAuth2AgentConfig.class); } private static Map createProperties( @@ -132,7 +132,7 @@ private static Map createProperties( return builder.build(); } - private static AssertionSupplier createSupplier(OAuth2Config config) { + private static AssertionSupplier createSupplier(OAuth2AgentConfig config) { ScheduledExecutorService executor = mock(ScheduledExecutorService.class); return AssertionSupplier.create(config, OAuth2AgentRuntime.of(executor)); } diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplierTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplierTest.java similarity index 84% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplierTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplierTest.java index 845bec09..56ad8d61 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/ActorTokenSupplierTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/ActorTokenSupplierTest.java @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.tokenexchange; +package com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.token.AccessToken; @@ -43,7 +43,8 @@ class ActorTokenSupplierTest { @Test void testSupplyActorTokenAsyncStatic() { - OAuth2Config config = createMainConfig("actor-token", null, TokenTypeURI.ID_TOKEN, Map.of()); + OAuth2AgentConfig config = + createMainConfig("actor-token", null, TokenTypeURI.ID_TOKEN, Map.of()); try (ActorTokenSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyTokenAsync(); assertThat(stage) @@ -54,7 +55,7 @@ void testSupplyActorTokenAsyncStatic() { @Test void testSupplyActorTokenAsyncDynamic() { - OAuth2Config config = + OAuth2AgentConfig config = createMainConfig( null, null, @@ -76,7 +77,7 @@ void testSupplyActorTokenAsyncDynamic() { @Test void testSupplyActorTokenAsyncNull() { - OAuth2Config config = createMainConfig(null, null, TokenTypeURI.ACCESS_TOKEN, Map.of()); + OAuth2AgentConfig config = createMainConfig(null, null, TokenTypeURI.ACCESS_TOKEN, Map.of()); try (ActorTokenSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyTokenAsync(); assertThat(stage).isCompletedWithValue(null); @@ -87,7 +88,7 @@ void testSupplyActorTokenAsyncNull() { void testSupplyActorTokenAsyncFromFile(@TempDir Path tempDir) throws Exception { Path tokenFile = tempDir.resolve("actor-token.txt"); Files.writeString(tokenFile, " actor-token-from-file "); - OAuth2Config config = createMainConfig(null, tokenFile, TokenTypeURI.JWT, Map.of()); + OAuth2AgentConfig config = createMainConfig(null, tokenFile, TokenTypeURI.JWT, Map.of()); try (ActorTokenSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyTokenAsync(); assertThat(stage) @@ -96,7 +97,7 @@ void testSupplyActorTokenAsyncFromFile(@TempDir Path tempDir) throws Exception { } } - private static OAuth2Config createMainConfig( + private static OAuth2AgentConfig createMainConfig( String actorToken, Path actorTokenFile, TokenTypeURI actorTokenType, @@ -129,10 +130,10 @@ private static OAuth2Config createMainConfig( actorTokenFile.toString()); } - return OAuth2Config.from(builder.build()); + return OAuth2AgentConfig.from(builder.build()); } - private static ActorTokenSupplier createSupplier(OAuth2Config config) { + private static ActorTokenSupplier createSupplier(OAuth2AgentConfig config) { ScheduledExecutorService executor = mock(ScheduledExecutorService.class); return ActorTokenSupplier.create(config, OAuth2AgentRuntime.of(executor)); } diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplierTest.java b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplierTest.java similarity index 84% rename from oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplierTest.java rename to oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplierTest.java index c27239f3..80408e36 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/tokenexchange/SubjectTokenSupplierTest.java +++ b/oauth2/agent/src/test/java/com/dremio/iceberg/authmgr/oauth2/agent/tokenexchange/SubjectTokenSupplierTest.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.tokenexchange; +package com.dremio.iceberg.authmgr.oauth2.agent.tokenexchange; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.mock; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.token.AccessToken; @@ -47,7 +47,8 @@ class SubjectTokenSupplierTest { @Test void testSupplyTokenAsyncStatic() { - OAuth2Config config = createMainConfig("subject-token", null, TokenTypeURI.ID_TOKEN, Map.of()); + OAuth2AgentConfig config = + createMainConfig("subject-token", null, TokenTypeURI.ID_TOKEN, Map.of()); try (SubjectTokenSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyTokenAsync(); assertThat(stage) @@ -58,7 +59,7 @@ void testSupplyTokenAsyncStatic() { @Test void testSupplyTokenAsyncDynamic() { - OAuth2Config config = + OAuth2AgentConfig config = createMainConfig( null, null, @@ -81,7 +82,7 @@ void testSupplyTokenAsyncDynamic() { @Test @SuppressWarnings("resource") void testValidate() { - OAuth2Config config = createInvalidMainConfig(); + OAuth2AgentConfig config = createInvalidMainConfig(); assertThatIllegalArgumentException() .isThrownBy(() -> createSupplier(config)) .withMessage("Subject token is dynamic but no configuration is provided"); @@ -91,7 +92,7 @@ void testValidate() { void testSupplyTokenAsyncFromFile(@TempDir Path tempDir) throws Exception { Path tokenFile = tempDir.resolve("subject-token.txt"); Files.writeString(tokenFile, " subject-token-from-file "); - OAuth2Config config = createMainConfig(null, tokenFile, TokenTypeURI.JWT, Map.of()); + OAuth2AgentConfig config = createMainConfig(null, tokenFile, TokenTypeURI.JWT, Map.of()); try (SubjectTokenSupplier supplier = createSupplier(config)) { CompletionStage stage = supplier.supplyTokenAsync(); assertThat(stage) @@ -100,16 +101,16 @@ void testSupplyTokenAsyncFromFile(@TempDir Path tempDir) throws Exception { } } - private static OAuth2Config createMainConfig( + private static OAuth2AgentConfig createMainConfig( String subjectToken, Path subjectTokenFile, TokenTypeURI subjectTokenType, Map subjectTokenConfig) { - return OAuth2Config.from( + return OAuth2AgentConfig.from( createProperties(subjectToken, subjectTokenFile, subjectTokenType, subjectTokenConfig)); } - private static OAuth2Config createInvalidMainConfig() { + private static OAuth2AgentConfig createInvalidMainConfig() { SmallRyeConfig smallRyeConfig = new SmallRyeConfigBuilder() .withSources( @@ -117,9 +118,9 @@ private static OAuth2Config createInvalidMainConfig() { "catalog properties", createProperties(null, null, TokenTypeURI.ACCESS_TOKEN, Map.of()), 200) {}) - .withMapping(OAuth2Config.class) + .withMapping(OAuth2AgentConfig.class) .build(); - return smallRyeConfig.getConfigMapping(OAuth2Config.class); + return smallRyeConfig.getConfigMapping(OAuth2AgentConfig.class); } private static Map createProperties( @@ -156,7 +157,7 @@ private static Map createProperties( return builder.build(); } - private static SubjectTokenSupplier createSupplier(OAuth2Config config) { + private static SubjectTokenSupplier createSupplier(OAuth2AgentConfig config) { ScheduledExecutorService executor = mock(ScheduledExecutorService.class); return SubjectTokenSupplier.create(config, OAuth2AgentRuntime.of(executor)); } diff --git a/oauth2/agent/src/test/resources/junit-platform.properties b/oauth2/agent/src/test/resources/junit-platform.properties new file mode 100644 index 00000000..6143d905 --- /dev/null +++ b/oauth2/agent/src/test/resources/junit-platform.properties @@ -0,0 +1,18 @@ +# +# Copyright (C) 2025 Dremio Corporation +# +# Licensed 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. +# + +junit.jupiter.execution.timeout.default=10 s +junit.jupiter.execution.timeout.threaddump.enabled=true \ No newline at end of file diff --git a/oauth2/agent/src/test/resources/logback-test.xml b/oauth2/agent/src/test/resources/logback-test.xml new file mode 100644 index 00000000..94651569 --- /dev/null +++ b/oauth2/agent/src/test/resources/logback-test.xml @@ -0,0 +1,32 @@ + + + + + + + %date{ISO8601} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/BouncyCastleHelper.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/BouncyCastleHelper.java similarity index 97% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/BouncyCastleHelper.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/BouncyCastleHelper.java index 00e12645..8c07ef86 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/BouncyCastleHelper.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/BouncyCastleHelper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; import java.io.IOException; import java.nio.file.Files; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestCertificates.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestCertificates.java similarity index 99% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestCertificates.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestCertificates.java index dd0649c9..e7ee8850 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestCertificates.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestCertificates.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; -import com.dremio.iceberg.authmgr.oauth2.crypto.PemReader; +import com.dremio.iceberg.authmgr.oauth2.agent.crypto.PemReader; import com.google.common.io.MoreFiles; import com.google.common.io.RecursiveDeleteOption; import java.io.IOException; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestClock.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestClock.java similarity index 96% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestClock.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestClock.java index 71f6e210..fcd516bc 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestClock.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestClock.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; import java.time.Clock; import java.time.Instant; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestConstants.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestConstants.java similarity index 84% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestConstants.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestConstants.java index 2f17a461..208e37f8 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestConstants.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestConstants.java @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; - -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSHeader; @@ -35,10 +32,7 @@ import java.time.Instant; import java.util.Base64; import java.util.Date; -import java.util.Map; import java.util.UUID; -import org.apache.iceberg.catalog.SessionCatalog; -import org.apache.iceberg.catalog.TableIdentifier; public class TestConstants { @@ -108,18 +102,6 @@ public class TestConstants { public static final TokenTypeURI REQUESTED_TOKEN_TYPE = TokenTypeURI.ACCESS_TOKEN; public static final String WAREHOUSE = "warehouse1"; - public static final TableIdentifier TABLE_IDENTIFIER = TableIdentifier.of("namespace1", "table1"); - - public static final SessionCatalog.SessionContext SESSION_CONTEXT = - new SessionCatalog.SessionContext( - UUID.randomUUID().toString(), - "user", - Map.of( - PREFIX + '.' + BasicConfig.CLIENT_ID, - TestConstants.CLIENT_ID2.getValue(), - PREFIX + '.' + BasicConfig.CLIENT_SECRET, - TestConstants.CLIENT_SECRET2.getValue()), - Map.of(PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE2.toString())); private TestConstants() {} diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironment.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironment.java similarity index 77% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironment.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironment.java index 8a8ce4e9..7fd854db 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironment.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironment.java @@ -13,45 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; - -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; -import static org.apache.iceberg.rest.RESTUtil.extractPrefixMap; - -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Manager; -import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableOAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; -import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.AuthorizationCodeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils; -import com.dremio.iceberg.authmgr.oauth2.config.DeviceCodeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.DpopConfig; -import com.dremio.iceberg.authmgr.oauth2.config.HttpConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtBearerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.JwtClientAuthConfig; -import com.dremio.iceberg.authmgr.oauth2.config.ResourceOwnerConfig; -import com.dremio.iceberg.authmgr.oauth2.config.SystemConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig; -import com.dremio.iceberg.authmgr.oauth2.flow.FlowFactory; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableAuthorizationCodeExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableClientCredentialsExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableConfigEndpointExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableDeviceCodeExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableErrorExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableJwtBearerExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableLoadTableEndpointExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableMetadataDiscoveryExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutablePasswordExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableRefreshTokenExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.expectation.ImmutableTokenExchangeExpectation; -import com.dremio.iceberg.authmgr.oauth2.test.user.InteractiveUserEmulator; -import com.dremio.iceberg.authmgr.oauth2.test.user.UserBehavior; -import com.dremio.iceberg.authmgr.oauth2.test.user.UserEmulator; +package com.dremio.iceberg.authmgr.oauth2.agent; + +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; + +import com.dremio.iceberg.authmgr.oauth2.agent.config.AuthorizationCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DeviceCodeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.DpopConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.HttpConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtBearerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.JwtClientAuthConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ResourceOwnerConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableAuthorizationCodeExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableClientCredentialsExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableDeviceCodeExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableErrorExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableJwtBearerExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableMetadataDiscoveryExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutablePasswordExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableRefreshTokenExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.ImmutableTokenExchangeExpectation; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.FlowFactory; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; +import com.dremio.iceberg.authmgr.oauth2.agent.user.InteractiveUserEmulator; +import com.dremio.iceberg.authmgr.oauth2.agent.user.UserBehavior; +import com.dremio.iceberg.authmgr.oauth2.agent.user.UserEmulator; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.google.errorprone.annotations.MustBeClosed; @@ -67,7 +58,6 @@ import com.nimbusds.oauth2.sdk.token.TokenTypeURI; import com.nimbusds.oauth2.sdk.token.TypelessAccessToken; import jakarta.annotation.Nullable; -import java.io.IOException; import java.io.PrintStream; import java.net.URI; import java.nio.file.Path; @@ -77,18 +67,12 @@ import java.util.Map; import java.util.Optional; import java.util.OptionalInt; +import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import javax.net.ssl.SSLContext; -import org.apache.iceberg.CatalogProperties; -import org.apache.iceberg.catalog.SessionCatalog.SessionContext; -import org.apache.iceberg.rest.HTTPClient; -import org.apache.iceberg.rest.RESTCatalog; -import org.apache.iceberg.rest.ResourcePaths; -import org.apache.iceberg.rest.auth.AuthProperties; -import org.apache.iceberg.rest.auth.AuthSession; -import org.apache.iceberg.util.ThreadPools; import org.immutables.value.Value; @AuthManagerImmutable @@ -97,10 +81,6 @@ public abstract class TestEnvironment implements AutoCloseable { private static final AtomicInteger ID_COUNTER = new AtomicInteger(); - public static Builder builder() { - return ImmutableTestEnvironment.builder(); - } - @Value.Check public void validate() { if (isCreateDefaultExpectations()) { @@ -155,7 +135,7 @@ public boolean isSsl() { @Value.Default public ScheduledExecutorService getExecutor() { - return ThreadPools.newScheduledPool(getAgentName() + "-refresh", getExecutorPoolSize()); + return Executors.newScheduledThreadPool(getExecutorPoolSize()); } @Value.Default @@ -239,15 +219,7 @@ public URI getDeviceVerificationEndpoint() { @Value.Default public URI getConfigEndpoint() { - return getCatalogServerUrl().resolve(ResourcePaths.config()); - } - - @Value.Default - public URI getLoadTableEndpoint() { - return getCatalogServerUrl() - .resolve( - ResourcePaths.forCatalogProperties(getCatalogProperties()) - .table(TestConstants.TABLE_IDENTIFIER)); + return getCatalogServerUrl().resolve("v1/config"); } @Value.Default @@ -278,8 +250,8 @@ public Map getProperties() { } @Value.Default - public OAuth2Config getOAuth2Config() { - return OAuth2Config.from(getProperties()); + public OAuth2AgentConfig getOAuth2Config() { + return OAuth2AgentConfig.from(getProperties()); } @Value.Default @@ -535,14 +507,14 @@ public Scope getAssertionScope() { public Map getAssertionConfig() { ImmutableMap.Builder builder = ImmutableMap.builder() - .putAll(extractPrefixMap(getBasicConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getResourceOwnerConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getAuthorizationCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getDeviceCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getTokenRefreshConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getJwtClientAuthConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getSystemConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getHttpConfig(), PREFIX + '.')) + .putAll(stripPrefix(getBasicConfig(), PREFIX + '.')) + .putAll(stripPrefix(getResourceOwnerConfig(), PREFIX + '.')) + .putAll(stripPrefix(getAuthorizationCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getDeviceCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getTokenRefreshConfig(), PREFIX + '.')) + .putAll(stripPrefix(getJwtClientAuthConfig(), PREFIX + '.')) + .putAll(stripPrefix(getSystemConfig(), PREFIX + '.')) + .putAll(stripPrefix(getHttpConfig(), PREFIX + '.')) .put(BasicConfig.GRANT_TYPE, getAssertionGrantType().getValue()) .put(BasicConfig.CLIENT_ID, getAssertionClientId().getValue()) .put(BasicConfig.EXTRA_PARAMS + ".extra2", "value2") @@ -636,14 +608,14 @@ public Scope getSubjectScope() { public Map getSubjectTokenConfig() { ImmutableMap.Builder builder = ImmutableMap.builder() - .putAll(extractPrefixMap(getBasicConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getResourceOwnerConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getAuthorizationCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getDeviceCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getTokenRefreshConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getJwtClientAuthConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getSystemConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getHttpConfig(), PREFIX + '.')) + .putAll(stripPrefix(getBasicConfig(), PREFIX + '.')) + .putAll(stripPrefix(getResourceOwnerConfig(), PREFIX + '.')) + .putAll(stripPrefix(getAuthorizationCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getDeviceCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getTokenRefreshConfig(), PREFIX + '.')) + .putAll(stripPrefix(getJwtClientAuthConfig(), PREFIX + '.')) + .putAll(stripPrefix(getSystemConfig(), PREFIX + '.')) + .putAll(stripPrefix(getHttpConfig(), PREFIX + '.')) .put(BasicConfig.GRANT_TYPE, getSubjectGrantType().getValue()) .put(BasicConfig.CLIENT_ID, getSubjectClientId().getValue()) .put(BasicConfig.EXTRA_PARAMS + ".extra2", "value2") @@ -689,14 +661,14 @@ public Scope getActorScope() { public Map getActorTokenConfig() { ImmutableMap.Builder builder = ImmutableMap.builder() - .putAll(extractPrefixMap(getBasicConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getResourceOwnerConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getAuthorizationCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getDeviceCodeConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getTokenRefreshConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getJwtClientAuthConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getSystemConfig(), PREFIX + '.')) - .putAll(extractPrefixMap(getHttpConfig(), PREFIX + '.')) + .putAll(stripPrefix(getBasicConfig(), PREFIX + '.')) + .putAll(stripPrefix(getResourceOwnerConfig(), PREFIX + '.')) + .putAll(stripPrefix(getAuthorizationCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getDeviceCodeConfig(), PREFIX + '.')) + .putAll(stripPrefix(getTokenRefreshConfig(), PREFIX + '.')) + .putAll(stripPrefix(getJwtClientAuthConfig(), PREFIX + '.')) + .putAll(stripPrefix(getSystemConfig(), PREFIX + '.')) + .putAll(stripPrefix(getHttpConfig(), PREFIX + '.')) .put(BasicConfig.GRANT_TYPE, getActorGrantType().getValue()) .put(BasicConfig.CLIENT_ID, getActorClientId().getValue()) .put(BasicConfig.EXTRA_PARAMS + ".extra2", "value2") @@ -755,7 +727,7 @@ public Map getSystemConfig() { @Value.Default public String getAgentName() { - return "iceberg-auth-manager-" + java.lang.System.nanoTime(); + return "iceberg-auth-manager-" + System.nanoTime(); } @Value.Default @@ -859,28 +831,6 @@ public SSLContext getUserSslContext() { } } - @Value.Default - public Map getCatalogProperties() { - return ImmutableMap.builder() - .put(CatalogProperties.URI, getCatalogServerUrl().toString()) - .put("prefix", TestConstants.WAREHOUSE) - .put(CatalogProperties.FILE_IO_IMPL, "org.apache.iceberg.inmemory.InMemoryFileIO") - .put(AuthProperties.AUTH_TYPE, OAuth2Manager.class.getName()) - .put(PREFIX + '.' + BasicConfig.GRANT_TYPE, getGrantType().toString()) - .put(PREFIX + '.' + BasicConfig.ISSUER_URL, getAuthorizationServerUrl().toString()) - .put(PREFIX + '.' + BasicConfig.CLIENT_ID, getClientId().getValue()) - .put(PREFIX + '.' + BasicConfig.CLIENT_SECRET, getClientSecret().getValue()) - .put(PREFIX + '.' + BasicConfig.SCOPE, getScope().toString()) - .put(PREFIX + '.' + BasicConfig.EXTRA_PARAMS + ".extra1", "value1") - .put(SystemConfig.PREFIX + '.' + SystemConfig.AGENT_NAME, getAgentName()) - .build(); - } - - @Value.Default - public SessionContext getSessionContext() { - return SessionContext.createEmpty(); - } - @Value.Default public Map getTableProperties() { return Map.of(); @@ -905,29 +855,6 @@ public PrintStream getConsole() { return getUser().getConsole(); } - public HTTPClient.Builder newIcebergRestClientBuilder(Map properties) { - return HTTPClient.builder(properties) - .uri(getCatalogServerUrl()) - .withAuthSession(AuthSession.EMPTY); - } - - @MustBeClosed - public RESTCatalog newCatalog() { - RESTCatalog catalog = - new RESTCatalog(getSessionContext(), config -> newIcebergRestClientBuilder(config).build()); - UserEmulator user = getUser(); - user.addErrorListener( - e -> { - try { - catalog.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - }); - catalog.initialize("catalog-" + java.lang.System.nanoTime(), getCatalogProperties()); - return catalog; - } - @MustBeClosed public FlowFactory newFlowFactory() { return FlowFactory.create(getOAuth2Config(), getOAuth2AgentRuntime()); @@ -943,11 +870,13 @@ public OAuth2Agent newAgent() { public void createExpectations() { createInitialGrantExpectations(getGrantType()); createRefreshTokenExpectations(); - createCatalogExpectations(); createMetadataDiscoveryExpectations(); + createOtherExpectations(); createErrorExpectations(); } + public void createOtherExpectations() {} + public void createInitialGrantExpectations(GrantType grantType) { if (grantType.equals(GrantType.CLIENT_CREDENTIALS)) { ImmutableClientCredentialsExpectation.of(this).create(); @@ -979,11 +908,6 @@ public void createRefreshTokenExpectations() { } } - public void createCatalogExpectations() { - ImmutableConfigEndpointExpectation.of(this).create(); - ImmutableLoadTableEndpointExpectation.of(this).create(); - } - public void createMetadataDiscoveryExpectations() { ImmutableMetadataDiscoveryExpectation.of(this).create(); } @@ -997,7 +921,7 @@ public void createErrorExpectations() { @Override public final int hashCode() { - return java.lang.System.identityHashCode(this); + return System.identityHashCode(this); } @Override @@ -1009,4 +933,10 @@ public final boolean equals(Object obj) { public final String toString() { return "TestEnvironment"; } + + static Map stripPrefix(Map map, String prefix) { + return map.entrySet().stream() + .filter(e -> e.getKey().startsWith(prefix)) + .collect(Collectors.toMap(e -> e.getKey().substring(prefix.length()), Map.Entry::getValue)); + } } diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironmentExtension.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironmentExtension.java similarity index 87% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironmentExtension.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironmentExtension.java index 4ab23a8f..31e6c299 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestEnvironmentExtension.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestEnvironmentExtension.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment.Builder; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment.Builder; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolutionException; @@ -46,6 +46,5 @@ public Object resolveParameter( throw new ParameterResolutionException("Unsupported parameter type"); } - protected abstract ImmutableTestEnvironment.Builder newTestEnvironmentBuilder( - ExtensionContext extensionContext); + protected abstract Builder newTestEnvironmentBuilder(ExtensionContext extensionContext); } diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestServer.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestServer.java similarity index 97% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestServer.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestServer.java index 51ca940a..22d1316c 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TestServer.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TestServer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; import java.io.IOException; import java.nio.file.Files; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TokenAssertions.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TokenAssertions.java similarity index 95% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TokenAssertions.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TokenAssertions.java index d5a73ec1..0142c52f 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/TokenAssertions.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/TokenAssertions.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test; +package com.dremio.iceberg.authmgr.oauth2.agent; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.flow.TokensResult; +import com.dremio.iceberg.authmgr.oauth2.agent.flow.TokensResult; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.RefreshToken; import jakarta.annotation.Nullable; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ExpectationUtils.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractExpectation.java similarity index 56% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ExpectationUtils.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractExpectation.java index 84abf227..6b7aae3d 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ExpectationUtils.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractExpectation.java @@ -13,40 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.apache.iceberg.rest.RESTResponse; -import org.apache.iceberg.rest.RESTSerializers; +import org.immutables.value.Value; import org.mockserver.model.JsonBody; import org.mockserver.model.Parameter; import org.mockserver.model.ParameterBody; -public final class ExpectationUtils { +public abstract class AbstractExpectation { - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().findAndRegisterModules(); + @Value.Parameter(order = 1) + protected abstract TestEnvironment getTestEnvironment(); - static { - RESTSerializers.registerAll(OBJECT_MAPPER); - } - - public static JsonBody getJsonBody(RESTResponse body) { - try { - return JsonBody.json(OBJECT_MAPPER.writeValueAsString(body)); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } + public abstract void create(); - public static JsonBody getJsonBody(Map response) { + protected JsonBody getJsonBody(Map response) { return JsonBody.json(response); } - public static ParameterBody getParameterBody(Map request) { + protected ParameterBody getParameterBody(Map request) { List parameters = request.entrySet().stream() .map(entry -> Parameter.param(entry.getKey(), entry.getValue())) diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractTokenEndpointExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractTokenEndpointExpectation.java similarity index 88% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractTokenEndpointExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractTokenEndpointExpectation.java index 37411d72..e498d11c 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractTokenEndpointExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AbstractTokenEndpointExpectation.java @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_ID2; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_SECRET1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_SECRET2; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ExpectationUtils.getJsonBody; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_ID2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_SECRET1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_SECRET2; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; @@ -50,7 +49,7 @@ protected HttpRequest request() { .withHeader("Content-Type", "application/x-www-form-urlencoded(; charset=UTF-8)?") .withHeader("Accept", "application/json") .withHeaders(requestHeaders().build()) - .withBody(ExpectationUtils.getParameterBody(requestBody().build())); + .withBody(getParameterBody(requestBody().build())); } protected HttpResponse response( diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AuthorizationCodeExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AuthorizationCodeExpectation.java similarity index 90% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AuthorizationCodeExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AuthorizationCodeExpectation.java index c71e76d5..8a672277 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AuthorizationCodeExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/AuthorizationCodeExpectation.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_ID1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.CLIENT_ID2; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ErrorExpectation.AUTHORIZATION_SERVER_ERROR_RESPONSE; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_ID1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.CLIENT_ID2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.expectation.ErrorExpectation.AUTHORIZATION_SERVER_ERROR_RESPONSE; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.AuthorizationCode; @@ -45,8 +45,7 @@ public abstract class AuthorizationCodeExpectation extends InitialTokenFetchExpe /** A map of pending authorization requests, keyed by the redirect URI. */ @Value.Lazy - protected ConcurrentMap - getPendingAuthRequests() { + protected ConcurrentMap getPendingAuthRequests() { return new ConcurrentHashMap<>(); } diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ClientCredentialsExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ClientCredentialsExpectation.java similarity index 84% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ClientCredentialsExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ClientCredentialsExpectation.java index 7401421f..a210499e 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ClientCredentialsExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ClientCredentialsExpectation.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/DeviceCodeExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/DeviceCodeExpectation.java similarity index 93% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/DeviceCodeExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/DeviceCodeExpectation.java index bee2a6c8..2a323f1a 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/DeviceCodeExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/DeviceCodeExpectation.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ErrorExpectation.AUTHORIZATION_SERVER_ERROR_RESPONSE; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.expectation.ErrorExpectation.AUTHORIZATION_SERVER_ERROR_RESPONSE; import static org.mockserver.model.Parameter.param; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; @@ -44,8 +44,7 @@ public abstract class DeviceCodeExpectation extends InitialTokenFetchExpectation /** A map of pending authorization requests, keyed by the user and device code. */ @Value.Lazy - protected ConcurrentMap - getPendingAuthRequests() { + protected ConcurrentMap getPendingAuthRequests() { return new ConcurrentHashMap<>(); } diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ErrorExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ErrorExpectation.java similarity index 94% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ErrorExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ErrorExpectation.java index 8c27354d..8cd2216d 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ErrorExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/ErrorExpectation.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/InitialTokenFetchExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/InitialTokenFetchExpectation.java similarity index 87% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/InitialTokenFetchExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/InitialTokenFetchExpectation.java index cc7ac23a..c6ee3147 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/InitialTokenFetchExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/InitialTokenFetchExpectation.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_INITIAL; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.nimbusds.jwt.SignedJWT; import java.text.ParseException; import org.mockserver.model.HttpRequest; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/JwtBearerExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/JwtBearerExpectation.java similarity index 91% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/JwtBearerExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/JwtBearerExpectation.java index 406835e9..e62e329c 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/JwtBearerExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/JwtBearerExpectation.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/MetadataDiscoveryExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/MetadataDiscoveryExpectation.java similarity index 90% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/MetadataDiscoveryExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/MetadataDiscoveryExpectation.java index 89519a45..074df80a 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/MetadataDiscoveryExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/MetadataDiscoveryExpectation.java @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ExpectationUtils.getJsonBody; - -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import java.net.URI; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/PasswordExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/PasswordExpectation.java similarity index 75% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/PasswordExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/PasswordExpectation.java index ac2a228a..a4c0062a 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/PasswordExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/PasswordExpectation.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.PASSWORD; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.USERNAME; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.PASSWORD; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.USERNAME; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/RefreshTokenExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/RefreshTokenExpectation.java similarity index 75% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/RefreshTokenExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/RefreshTokenExpectation.java index 839eef98..7450149c 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/RefreshTokenExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/RefreshTokenExpectation.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.REFRESH_TOKEN_REFRESHED; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.REFRESH_TOKEN_REFRESHED; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/TokenExchangeExpectation.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/TokenExchangeExpectation.java similarity index 82% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/TokenExchangeExpectation.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/TokenExchangeExpectation.java index 9a255b24..a77e388b 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/TokenExchangeExpectation.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/expectation/TokenExchangeExpectation.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.agent.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.AUDIENCE; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.RESOURCE; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE1; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.SCOPE2; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.AUDIENCE; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.RESOURCE; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE1; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.SCOPE2; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/AutheliaExtension.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/AutheliaExtension.java similarity index 86% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/AutheliaExtension.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/AutheliaExtension.java index ab13e7ad..5db9df55 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/AutheliaExtension.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/AutheliaExtension.java @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.junit; +package com.dremio.iceberg.authmgr.oauth2.agent.junit; -import com.dremio.iceberg.authmgr.oauth2.http.HttpClientType; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironmentExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestCertificates; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironmentExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.http.HttpClientType; import com.dremio.iceberg.authmgr.oauth2.test.container.AutheliaContainer; import com.nimbusds.oauth2.sdk.Scope; import org.junit.jupiter.api.extension.AfterAllCallback; @@ -65,7 +64,7 @@ protected ImmutableTestEnvironment.Builder newTestEnvironmentBuilder(ExtensionCo context .getStore(ExtensionContext.Namespace.GLOBAL) .get(AutheliaContainer.class.getName(), AutheliaContainer.class); - return TestEnvironment.builder() + return ImmutableTestEnvironment.builder() .unitTest(false) .discoveryEnabled(true) .sslTrustAll(true) diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/EnumLike.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/EnumLike.java similarity index 97% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/EnumLike.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/EnumLike.java index f96eea84..904ddbd4 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/EnumLike.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/EnumLike.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.junit; +package com.dremio.iceberg.authmgr.oauth2.agent.junit; -import com.dremio.iceberg.authmgr.oauth2.config.ConfigUtils; +import com.dremio.iceberg.authmgr.oauth2.agent.config.ConfigUtils; import com.nimbusds.oauth2.sdk.GrantType; import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod; import java.lang.annotation.ElementType; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/HydraExtension.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/HydraExtension.java similarity index 89% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/HydraExtension.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/HydraExtension.java index 20bb52c8..249b8762 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/HydraExtension.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/HydraExtension.java @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.junit; +package com.dremio.iceberg.authmgr.oauth2.agent.junit; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironmentExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironmentExtension; import com.dremio.iceberg.authmgr.oauth2.test.container.HydraContainer; import com.nimbusds.oauth2.sdk.Scope; import org.junit.jupiter.api.extension.AfterAllCallback; @@ -71,7 +70,7 @@ protected ImmutableTestEnvironment.Builder newTestEnvironmentBuilder(ExtensionCo .get(HydraContainer.class.getName(), HydraContainer.class); // Note: Hydra doesn't support device code flow nor token exchange // Note: cannot use metadata discovery, the URLs are internal to the container network - return TestEnvironment.builder() + return ImmutableTestEnvironment.builder() .unitTest(false) .discoveryEnabled(false) .scope(new Scope(SCOPE1)) diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/KeycloakExtension.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/KeycloakExtension.java similarity index 96% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/KeycloakExtension.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/KeycloakExtension.java index 06c698ba..db173067 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/KeycloakExtension.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/KeycloakExtension.java @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.junit; +package com.dremio.iceberg.authmgr.oauth2.agent.junit; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_BASIC; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_JWT; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.NONE; import static com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.PRIVATE_KEY_JWT; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestCertificates; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironmentExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestCertificates; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironmentExtension; import com.dremio.iceberg.authmgr.oauth2.test.container.KeycloakContainer; import com.google.common.base.Preconditions; import com.nimbusds.jose.JWSAlgorithm; @@ -173,7 +172,7 @@ protected ImmutableTestEnvironment.Builder newTestEnvironmentBuilder(ExtensionCo .getStore(ExtensionContext.Namespace.GLOBAL) .get(KeycloakContainer.class.getName(), KeycloakContainer.class); Preconditions.checkNotNull(keycloak, "Keycloak container not found in extension context"); - return TestEnvironment.builder() + return ImmutableTestEnvironment.builder() .unitTest(false) .serverRootUrl(keycloak.getRootUrl()) .authorizationServerUrl(keycloak.getIssuerUrl()) diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/PolarisExtension.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/PolarisExtension.java similarity index 88% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/PolarisExtension.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/PolarisExtension.java index dfe1d948..89814f78 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/junit/PolarisExtension.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/junit/PolarisExtension.java @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.junit; +package com.dremio.iceberg.authmgr.oauth2.agent.junit; -import com.dremio.iceberg.authmgr.oauth2.test.ImmutableTestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironmentExtension; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironmentExtension; import com.dremio.iceberg.authmgr.oauth2.test.container.PolarisContainer; import com.nimbusds.oauth2.sdk.Scope; import java.time.Clock; @@ -64,7 +63,7 @@ protected ImmutableTestEnvironment.Builder newTestEnvironmentBuilder(ExtensionCo context .getStore(ExtensionContext.Namespace.GLOBAL) .get(PolarisContainer.class.getName(), PolarisContainer.class); - return TestEnvironment.builder() + return ImmutableTestEnvironment.builder() .unitTest(false) .discoveryEnabled(false) .serverRootUrl(polaris.baseUri()) diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/AuthorizationCodeUserFlow.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/AuthorizationCodeUserFlow.java similarity index 98% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/AuthorizationCodeUserFlow.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/AuthorizationCodeUserFlow.java index 2afc9d13..3d9bea3f 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/AuthorizationCodeUserFlow.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/AuthorizationCodeUserFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; import static java.net.HttpURLConnection.HTTP_OK; import static org.assertj.core.api.Assertions.assertThat; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/DeviceCodeUserFlow.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/DeviceCodeUserFlow.java similarity index 98% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/DeviceCodeUserFlow.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/DeviceCodeUserFlow.java index ae2e88a0..97a9d21a 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/DeviceCodeUserFlow.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/DeviceCodeUserFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; import static java.net.HttpURLConnection.HTTP_OK; import static org.assertj.core.api.Assertions.assertThat; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/InteractiveUserEmulator.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/InteractiveUserEmulator.java similarity index 99% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/InteractiveUserEmulator.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/InteractiveUserEmulator.java index 7cacc886..ace592cd 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/InteractiveUserEmulator.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/InteractiveUserEmulator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserBehavior.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserBehavior.java similarity index 95% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserBehavior.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserBehavior.java index 13e14308..a0c4853d 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserBehavior.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserBehavior.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import java.util.Optional; import org.immutables.value.Value; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserEmulator.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserEmulator.java similarity index 96% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserEmulator.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserEmulator.java index ea953854..9a8f399c 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserEmulator.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserEmulator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; import java.io.PrintStream; import java.util.function.Consumer; diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserFlow.java b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserFlow.java similarity index 99% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserFlow.java rename to oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserFlow.java index a141e11c..08aec703 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/user/UserFlow.java +++ b/oauth2/agent/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/agent/user/UserFlow.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.user; +package com.dremio.iceberg.authmgr.oauth2.agent.user; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; import static java.net.HttpURLConnection.HTTP_MOVED_TEMP; diff --git a/oauth2/core/build.gradle.kts b/oauth2/core/build.gradle.kts index c1f1e365..42146efe 100644 --- a/oauth2/core/build.gradle.kts +++ b/oauth2/core/build.gradle.kts @@ -14,9 +14,6 @@ * limitations under the License. */ -import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds - plugins { id("authmgr-java-production") id("authmgr-java-testing") @@ -27,195 +24,40 @@ description = "Core OAuth2 implementation for Dremio AuthManager for Apache Iceb ext { set("mavenName", "Auth Manager for Apache Iceberg - OAuth2 - Core") } -val docs by - configurations.creating { - description = "Dependencies for generating configuration documentation" - isCanBeResolved = true - isCanBeConsumed = false - isVisible = false - } - dependencies { api(platform(libs.iceberg.bom)) api("org.apache.iceberg:iceberg-api") api("org.apache.iceberg:iceberg-core") - api(libs.nimbus.oauth2.oidc.sdk) { - exclude(group = "com.github.stephenc.jcip", module = "jcip-annotations") - } - api(libs.nimbus.jose.jwt) - - implementation(libs.httpclient5) - - implementation(libs.smallrye.config) { exclude(group = "jakarta.annotation") } - - // optional, but recommended for private_key_jwt - compileOnly(libs.bouncycastle.bcpkix) - - implementation(libs.slf4j.api) - implementation(libs.caffeine) - - implementation(libs.jakarta.annotation.api) - compileOnly(libs.errorprone.annotations) + api(project(":authmgr-oauth2-agent")) compileOnly(project(":authmgr-immutables")) annotationProcessor(project(":authmgr-immutables", configuration = "processor")) - testFixturesApi(project(":authmgr-oauth2-tests")) + testFixturesApi(testFixtures(project(":authmgr-oauth2-agent"))) testFixturesApi(platform(libs.iceberg.bom)) testFixturesApi("org.apache.iceberg:iceberg-api") testFixturesApi("org.apache.iceberg:iceberg-core") - testFixturesApi(platform(libs.junit.bom)) - testFixturesApi("org.junit.jupiter:junit-jupiter") - testFixturesApi(libs.junit.pioneer) - - testFixturesApi(libs.assertj.core) - testFixturesApi(libs.mockito.core) - - testFixturesApi(libs.nimbus.oauth2.oidc.sdk) - testFixturesApi(libs.nimbus.jose.jwt) - - testFixturesApi(libs.guava) - - testFixturesApi(platform(libs.testcontainers.bom)) - testFixturesApi("org.testcontainers:testcontainers") - testFixturesApi("org.testcontainers:testcontainers-junit-jupiter") - testFixturesApi(libs.keycloak.admin.client) - testFixturesApi(libs.testcontainers.keycloak) - - testFixturesImplementation(libs.bouncycastle.bcpkix) - - // Required to compile expectation classes - testFixturesCompileOnly(libs.mockserver.netty) - testFixturesCompileOnly(libs.mockserver.client.java) + testFixturesImplementation(libs.mockserver.netty) + testFixturesImplementation(libs.mockserver.client.java) testFixturesCompileOnly(project(":authmgr-immutables")) testFixturesAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) testCompileOnly(libs.jakarta.annotation.api) + testImplementation(libs.caffeine) testImplementation(libs.mockserver.netty) testImplementation(libs.mockserver.client.java) - testImplementation(libs.bouncycastle.bcpkix) - testCompileOnly(project(":authmgr-immutables")) testAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) - - intTestCompileOnly(project(":authmgr-immutables")) - intTestAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) - - intTestRuntimeOnly(libs.bouncycastle.bcpkix) - - longTestCompileOnly(project(":authmgr-immutables")) - longTestAnnotationProcessor(project(":authmgr-immutables", configuration = "processor")) - - docs("com.thoughtworks.qdox:qdox:2.2.0") -} - -tasks.named("test").configure { - configForks(4) - commonTestConfig() -} - -tasks.named("intTest").configure { - configForks(3) - commonTestConfig() -} - -val bouncyCastle = configurations.create("bouncyCastle") - -dependencies { bouncyCastle(libs.bouncycastle.bcpkix) } - -tasks.register("intTestNoBouncyCastle") { - description = "Runs integration tests without BouncyCastle dependencies" - group = "verification" - configForks(3) - commonTestConfig() - shouldRunAfter("test") - useJUnitPlatform() - testClassesDirs = sourceSets.intTest.get().output.classesDirs - classpath = sourceSets.intTest.get().runtimeClasspath - bouncyCastle -} - -tasks.named("check") { dependsOn("intTestNoBouncyCastle") } - -tasks.named("longTest").configure { - configForks(3) - commonTestConfig() - if (System.getProperty("authmgr.it.long.total") != null) { - val total = Duration.parse(System.getProperty("authmgr.it.long.total")) - systemProperty("authmgr.it.long.total", total.toIsoString()) - // Add a 10-second safety window to the tests default timeout - systemProperty( - "junit.jupiter.execution.timeout.testable.method.default", - (total + 10.seconds).inWholeSeconds.toString() + " s", - ) - } } val mockitoAgent = configurations.create("mockitoAgent") -dependencies { - testImplementation(libs.mockito.core) - testImplementation(libs.logback.classic) - mockitoAgent(libs.mockito.core) { isTransitive = false } -} +dependencies { mockitoAgent(libs.mockito.core) { isTransitive = false } } tasks { test { jvmArgs("-javaagent:${mockitoAgent.asPath}") } } - -fun Test.configForks(forks: Int) { - if (System.getenv("CI") == null) { - maxParallelForks = forks - } -} - -fun Test.commonTestConfig() { - val outputMemoryUsage = System.getProperty("authmgr.test.mockserver.outputMemoryUsage") - if (outputMemoryUsage.toBoolean()) { - val outputDir = - project.layout.buildDirectory.dir("reports/mockserver/${this.name}").get().asFile.absolutePath - outputs.dir(outputDir) - File(outputDir).mkdirs() - systemProperty("authmgr.test.mockserver.memoryUsageCsvDirectory", outputDir) - } -} - -sourceSets.create("docs") { - java.srcDir("src/docs/java") - resources.srcDir("src/docs/resources") - compileClasspath += docs - runtimeClasspath += docs -} - -tasks.named("processDocsResources", ProcessResources::class) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -tasks.register("generateDocs") { - group = "documentation" - description = "Generates configuration documentation from OAuth2Config" - mainClass.set("com.dremio.iceberg.authmgr.oauth2.docs.DocumentationGenerator") - classpath = sourceSets.getByName("docs").runtimeClasspath - - val inputFile = project.file("src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Config.java") - val outputFile = rootProject.file("docs/configuration.md") - - val headerFile = sourceSets.getByName("docs").resources.singleFile - val header = headerFile.readText() - - inputs.files(inputFile, headerFile) - outputs.file(outputFile) - - args(inputFile.absolutePath, header, outputFile.absolutePath) - - doFirst { outputFile.parentFile.mkdirs() } -} - -tasks.named("publish") { dependsOn("generateDocs") } - -rootProject.tasks.named("spotlessMarkdown") { dependsOn(":authmgr-oauth2-core:generateDocs") } - -rootProject.tasks.named("rat") { dependsOn(":authmgr-oauth2-core:generateDocs") } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Manager.java b/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Manager.java index 0a8ad96c..e4b452ee 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Manager.java +++ b/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Manager.java @@ -15,6 +15,7 @@ */ package com.dremio.iceberg.authmgr.oauth2; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import java.util.Map; import java.util.Optional; import java.util.concurrent.ScheduledExecutorService; @@ -137,7 +138,7 @@ private AuthSessionCache getOrCreateSessionCache(Map properties) if (cache == null) { synchronized (this) { if (sessionCache == null) { - OAuth2Config config = OAuth2Config.from(properties); + OAuth2AgentConfig config = OAuth2AgentConfig.from(properties); cache = new AuthSessionCache(name, config.getSystemConfig().getSessionCacheTimeout()); sessionCache = cache; } diff --git a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Session.java b/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Session.java index 94395c34..f5c98382 100644 --- a/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Session.java +++ b/oauth2/core/src/main/java/com/dremio/iceberg/authmgr/oauth2/OAuth2Session.java @@ -16,6 +16,7 @@ package com.dremio.iceberg.authmgr.oauth2; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; @@ -33,7 +34,8 @@ public class OAuth2Session implements AuthSession { public OAuth2Session(Map properties, ScheduledExecutorService executor) { this.properties = Map.copyOf(properties); - this.agent = new OAuth2Agent(OAuth2Config.from(properties), OAuth2AgentRuntime.of(executor)); + this.agent = + new OAuth2Agent(OAuth2AgentConfig.from(properties), OAuth2AgentRuntime.of(executor)); } private OAuth2Session(OAuth2Session toCopy) { diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ManagerTest.java b/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ManagerTest.java index 973d3663..09a27760 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ManagerTest.java +++ b/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2ManagerTest.java @@ -15,16 +15,18 @@ */ package com.dremio.iceberg.authmgr.oauth2; -import static com.dremio.iceberg.authmgr.oauth2.OAuth2Config.PREFIX; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.map; import static org.mockito.Mockito.never; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; -import com.dremio.iceberg.authmgr.oauth2.config.TokenExchangeConfig; -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenExchangeConfig; +import com.dremio.iceberg.authmgr.oauth2.core.IcebergTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.core.ImmutableIcebergTestEnvironment; import com.github.benmanes.caffeine.cache.Cache; import com.google.common.collect.ImmutableMap; import com.nimbusds.oauth2.sdk.GrantType; @@ -70,7 +72,7 @@ class UnitTests { @Test void catalogSessionWithoutInit() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map properties = Map.of( @@ -95,7 +97,7 @@ void catalogSessionWithoutInit() throws IOException { @Test void catalogSessionWithInit() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map properties = Map.of( @@ -126,7 +128,7 @@ void catalogSessionWithInit() throws IOException { @Test void contextualSessionEmptyContext() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map properties = Map.of( @@ -149,7 +151,7 @@ void contextualSessionEmptyContext() throws IOException { @Test void contextualSessionNotCached() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map properties = Map.of( @@ -178,7 +180,7 @@ void contextualSessionNotCached() throws IOException { @Test void contextualSessionCacheMiss() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map catalogProperties = Map.of( @@ -239,7 +241,7 @@ void contextualSessionCacheMiss() throws IOException { @Test void contextualSessionCacheHit() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map catalogProperties = Map.of( @@ -282,7 +284,7 @@ void contextualSessionCacheHit() throws IOException { @Test void tableSessionUnsupported() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map catalogProperties = Map.of( @@ -307,7 +309,7 @@ void tableSessionUnsupported() throws IOException { @Test void signerSession() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map signerProperties = Map.of( @@ -336,7 +338,7 @@ void signerSession() throws IOException { @Test void signerSessionCacheMiss() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map signerProperties1 = Map.of( @@ -370,7 +372,7 @@ void signerSessionCacheMiss() throws IOException { @Test void signerSessionCacheHit() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { Map signerProperties = Map.of( @@ -407,7 +409,7 @@ void close() throws IOException, IllegalAccessException { assertThat(manager).extracting("sessionCache").isNull(); } - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); OAuth2Manager manager = new OAuth2Manager("test")) { AuthSessionCache spyingCache = @@ -492,11 +494,12 @@ class CatalogTests { @Test void testCatalogProperties() throws IOException { - try (TestEnvironment env = TestEnvironment.builder().build(); + try (IcebergTestEnvironment env = ImmutableIcebergTestEnvironment.builder().build(); RESTCatalog catalog = env.newCatalog()) { - Table table = catalog.loadTable(TestConstants.TABLE_IDENTIFIER); + Table table = catalog.loadTable(IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(table).isNotNull(); - assertThat(table.name()).isEqualTo(catalog.name() + "." + TestConstants.TABLE_IDENTIFIER); + assertThat(table.name()) + .isEqualTo(catalog.name() + "." + IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(catalog) .extracting(CATALOG_PROPERTIES, map(String.class, String.class)) .satisfies(this::assertCatalogProperties); @@ -506,12 +509,15 @@ void testCatalogProperties() throws IOException { @Test void testCatalogAndContextProperties() throws IOException { - try (TestEnvironment env = - TestEnvironment.builder().sessionContext(TestConstants.SESSION_CONTEXT).build(); + try (IcebergTestEnvironment env = + ImmutableIcebergTestEnvironment.builder() + .sessionContext(IcebergTestEnvironment.SESSION_CONTEXT) + .build(); RESTCatalog catalog = env.newCatalog()) { - Table table = catalog.loadTable(TestConstants.TABLE_IDENTIFIER); + Table table = catalog.loadTable(IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(table).isNotNull(); - assertThat(table.name()).isEqualTo(catalog.name() + "." + TestConstants.TABLE_IDENTIFIER); + assertThat(table.name()) + .isEqualTo(catalog.name() + "." + IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(catalog) .extracting(CATALOG_PROPERTIES, map(String.class, String.class)) .satisfies(this::assertCatalogProperties); @@ -521,22 +527,23 @@ void testCatalogAndContextProperties() throws IOException { cache -> { assertThat(cache).hasSize(1); String key = cache.keySet().iterator().next(); - assertThat(key).isEqualTo(TestConstants.SESSION_CONTEXT.sessionId()); + assertThat(key).isEqualTo(IcebergTestEnvironment.SESSION_CONTEXT.sessionId()); }); } } @Test void testCatalogAndTableProperties() throws IOException { - try (TestEnvironment env = - TestEnvironment.builder() + try (IcebergTestEnvironment env = + ImmutableIcebergTestEnvironment.builder() .tableProperties( Map.of(PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE2.toString())) .build(); RESTCatalog catalog = env.newCatalog()) { - Table table = catalog.loadTable(TestConstants.TABLE_IDENTIFIER); + Table table = catalog.loadTable(IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(table).isNotNull(); - assertThat(table.name()).isEqualTo(catalog.name() + "." + TestConstants.TABLE_IDENTIFIER); + assertThat(table.name()) + .isEqualTo(catalog.name() + "." + IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(catalog) .extracting(CATALOG_PROPERTIES, map(String.class, String.class)) .satisfies(this::assertCatalogProperties); @@ -547,16 +554,17 @@ void testCatalogAndTableProperties() throws IOException { @Test void testCatalogAndContextAndTableProperties() throws IOException { - try (TestEnvironment env = - TestEnvironment.builder() - .sessionContext(TestConstants.SESSION_CONTEXT) + try (IcebergTestEnvironment env = + ImmutableIcebergTestEnvironment.builder() + .sessionContext(IcebergTestEnvironment.SESSION_CONTEXT) .tableProperties( Map.of(PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE3.toString())) .build(); RESTCatalog catalog = env.newCatalog()) { - Table table = catalog.loadTable(TestConstants.TABLE_IDENTIFIER); + Table table = catalog.loadTable(IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(table).isNotNull(); - assertThat(table.name()).isEqualTo(catalog.name() + "." + TestConstants.TABLE_IDENTIFIER); + assertThat(table.name()) + .isEqualTo(catalog.name() + "." + IcebergTestEnvironment.TABLE_IDENTIFIER); assertThat(catalog) .extracting(CATALOG_PROPERTIES, map(String.class, String.class)) .satisfies(this::assertCatalogProperties); @@ -566,7 +574,7 @@ void testCatalogAndContextAndTableProperties() throws IOException { cache -> { assertThat(cache).hasSize(1); String key = cache.keySet().iterator().next(); - assertThat(key).isEqualTo(TestConstants.SESSION_CONTEXT.sessionId()); + assertThat(key).isEqualTo(IcebergTestEnvironment.SESSION_CONTEXT.sessionId()); }); } } @@ -575,15 +583,15 @@ private void assertCatalogProperties(Map properties) { assertThat(properties).isNotNull(); assertThat(properties) .containsEntry( - OAuth2Config.PREFIX + '.' + BasicConfig.CLIENT_ID, + OAuth2AgentConfig.PREFIX + '.' + BasicConfig.CLIENT_ID, TestConstants.CLIENT_ID1.getValue()); assertThat(properties) .containsEntry( - OAuth2Config.PREFIX + '.' + BasicConfig.CLIENT_SECRET, + OAuth2AgentConfig.PREFIX + '.' + BasicConfig.CLIENT_SECRET, TestConstants.CLIENT_SECRET1.getValue()); assertThat(properties) .containsEntry( - OAuth2Config.PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE1.toString()); + OAuth2AgentConfig.PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE1.toString()); } @SuppressWarnings({"rawtypes", "unchecked"}) diff --git a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2SessionTest.java b/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2SessionTest.java index ed114c87..1728f290 100644 --- a/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2SessionTest.java +++ b/oauth2/core/src/test/java/com/dremio/iceberg/authmgr/oauth2/OAuth2SessionTest.java @@ -15,10 +15,11 @@ */ package com.dremio.iceberg.authmgr.oauth2; -import static com.dremio.iceberg.authmgr.oauth2.test.TestConstants.ACCESS_TOKEN_INITIAL; +import static com.dremio.iceberg.authmgr.oauth2.agent.TestConstants.ACCESS_TOKEN_INITIAL; import static org.assertj.core.api.Assertions.assertThat; -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.ImmutableTestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; import com.nimbusds.jose.util.Base64URL; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; @@ -35,7 +36,7 @@ class OAuth2SessionTest { @Test void testDpop() throws Exception { - try (TestEnvironment env = TestEnvironment.builder().dpopEnabled(true).build(); + try (TestEnvironment env = ImmutableTestEnvironment.builder().dpopEnabled(true).build(); OAuth2Session session = new OAuth2Session(env.getProperties(), env.getExecutor())) { URI rsUri = env.getCatalogServerUrl().resolve("v1/namespaces/ns/tables"); diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/IcebergTestEnvironment.java b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/IcebergTestEnvironment.java new file mode 100644 index 00000000..26b1cede --- /dev/null +++ b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/IcebergTestEnvironment.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2025 Dremio Corporation + * + * Licensed 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 com.dremio.iceberg.authmgr.oauth2.core; + +import static com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig.PREFIX; + +import com.dremio.iceberg.authmgr.oauth2.OAuth2Manager; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestEnvironment; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.SystemConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.user.UserEmulator; +import com.dremio.iceberg.authmgr.oauth2.core.expectation.ImmutableConfigEndpointExpectation; +import com.dremio.iceberg.authmgr.oauth2.core.expectation.ImmutableLoadTableEndpointExpectation; +import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; +import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.MustBeClosed; +import java.io.IOException; +import java.net.URI; +import java.util.Map; +import java.util.UUID; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.catalog.SessionCatalog; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.rest.HTTPClient; +import org.apache.iceberg.rest.RESTCatalog; +import org.apache.iceberg.rest.ResourcePaths; +import org.apache.iceberg.rest.auth.AuthProperties; +import org.apache.iceberg.rest.auth.AuthSession; +import org.immutables.value.Value; + +@AuthManagerImmutable +@Value.Immutable(copy = false) +@SuppressWarnings("immutables:subtype") +public abstract class IcebergTestEnvironment extends TestEnvironment { + + public static final TableIdentifier TABLE_IDENTIFIER = TableIdentifier.of("namespace1", "table1"); + + public static final SessionCatalog.SessionContext SESSION_CONTEXT = + new SessionCatalog.SessionContext( + UUID.randomUUID().toString(), + "user", + Map.of( + PREFIX + '.' + BasicConfig.CLIENT_ID, + TestConstants.CLIENT_ID2.getValue(), + PREFIX + '.' + BasicConfig.CLIENT_SECRET, + TestConstants.CLIENT_SECRET2.getValue()), + Map.of(PREFIX + '.' + BasicConfig.SCOPE, TestConstants.SCOPE2.toString())); + + @Value.Default + public SessionCatalog.SessionContext getSessionContext() { + return SessionCatalog.SessionContext.createEmpty(); + } + + @Value.Default + public URI getLoadTableEndpoint() { + return getCatalogServerUrl() + .resolve( + ResourcePaths.forCatalogProperties(getCatalogProperties()).table(TABLE_IDENTIFIER)); + } + + @Value.Default + public Map getCatalogProperties() { + return ImmutableMap.builder() + .put(CatalogProperties.URI, getCatalogServerUrl().toString()) + .put("prefix", TestConstants.WAREHOUSE) + .put(CatalogProperties.FILE_IO_IMPL, "org.apache.iceberg.inmemory.InMemoryFileIO") + .put(AuthProperties.AUTH_TYPE, OAuth2Manager.class.getName()) + .put(PREFIX + '.' + BasicConfig.GRANT_TYPE, getGrantType().toString()) + .put(PREFIX + '.' + BasicConfig.ISSUER_URL, getAuthorizationServerUrl().toString()) + .put(PREFIX + '.' + BasicConfig.CLIENT_ID, getClientId().getValue()) + .put(PREFIX + '.' + BasicConfig.CLIENT_SECRET, getClientSecret().getValue()) + .put(PREFIX + '.' + BasicConfig.SCOPE, getScope().toString()) + .put(PREFIX + '.' + BasicConfig.EXTRA_PARAMS + ".extra1", "value1") + .put(SystemConfig.PREFIX + '.' + SystemConfig.AGENT_NAME, getAgentName()) + .build(); + } + + public HTTPClient.Builder newIcebergRestClientBuilder(Map properties) { + return HTTPClient.builder(properties) + .uri(getCatalogServerUrl()) + .withAuthSession(AuthSession.EMPTY); + } + + @MustBeClosed + public RESTCatalog newCatalog() { + RESTCatalog catalog = + new RESTCatalog(getSessionContext(), config -> newIcebergRestClientBuilder(config).build()); + UserEmulator user = getUser(); + user.addErrorListener( + e -> { + try { + catalog.close(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + }); + catalog.initialize("catalog-" + java.lang.System.nanoTime(), getCatalogProperties()); + return catalog; + } + + @Override + public void createOtherExpectations() { + ImmutableConfigEndpointExpectation.of(this).create(); + ImmutableLoadTableEndpointExpectation.of(this).create(); + } +} diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ConfigEndpointExpectation.java b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/ConfigEndpointExpectation.java similarity index 88% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ConfigEndpointExpectation.java rename to oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/ConfigEndpointExpectation.java index ffc23ba0..3e84c9fd 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/ConfigEndpointExpectation.java +++ b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/ConfigEndpointExpectation.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.core.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ExpectationUtils.getJsonBody; - -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import com.google.common.collect.ImmutableList; import java.util.HashMap; @@ -27,11 +25,13 @@ import org.apache.iceberg.rest.Endpoint; import org.apache.iceberg.rest.ResourcePaths; import org.apache.iceberg.rest.responses.ConfigResponse; +import org.immutables.value.Value; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; @AuthManagerImmutable -public abstract class ConfigEndpointExpectation extends AbstractExpectation { +@Value.Style(strictBuilder = true) +public abstract class ConfigEndpointExpectation extends IcebergRestExpectation { @Override public void create() { diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/IcebergRestExpectation.java b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/IcebergRestExpectation.java new file mode 100644 index 00000000..95c7589b --- /dev/null +++ b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/IcebergRestExpectation.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2025 Dremio Corporation + * + * Licensed 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 com.dremio.iceberg.authmgr.oauth2.core.expectation; + +import com.dremio.iceberg.authmgr.oauth2.agent.expectation.AbstractExpectation; +import com.dremio.iceberg.authmgr.oauth2.core.IcebergTestEnvironment; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.iceberg.rest.RESTResponse; +import org.apache.iceberg.rest.RESTSerializers; +import org.immutables.value.Value; +import org.mockserver.model.JsonBody; + +public abstract class IcebergRestExpectation extends AbstractExpectation { + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + static { + RESTSerializers.registerAll(OBJECT_MAPPER); + } + + @Value.Parameter(order = 1) + @Override + protected abstract IcebergTestEnvironment getTestEnvironment(); + + protected JsonBody getJsonBody(RESTResponse response) { + try { + return JsonBody.json(OBJECT_MAPPER.writeValueAsString(response)); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } +} diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/LoadTableEndpointExpectation.java b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/LoadTableEndpointExpectation.java similarity index 86% rename from oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/LoadTableEndpointExpectation.java rename to oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/LoadTableEndpointExpectation.java index 2a5b21b3..ad354a62 100644 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/LoadTableEndpointExpectation.java +++ b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/core/expectation/LoadTableEndpointExpectation.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.dremio.iceberg.authmgr.oauth2.test.expectation; +package com.dremio.iceberg.authmgr.oauth2.core.expectation; -import static com.dremio.iceberg.authmgr.oauth2.test.expectation.ExpectationUtils.getJsonBody; - -import com.dremio.iceberg.authmgr.oauth2.test.TestConstants; -import com.dremio.iceberg.authmgr.oauth2.test.TestServer; +import com.dremio.iceberg.authmgr.oauth2.agent.TestConstants; +import com.dremio.iceberg.authmgr.oauth2.agent.TestServer; import com.dremio.iceberg.authmgr.tools.immutables.AuthManagerImmutable; import java.util.UUID; import java.util.regex.Pattern; @@ -28,11 +26,13 @@ import org.apache.iceberg.TableMetadata; import org.apache.iceberg.rest.responses.LoadTableResponse; import org.apache.iceberg.types.Types; +import org.immutables.value.Value; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; @AuthManagerImmutable -public abstract class LoadTableEndpointExpectation extends AbstractExpectation { +@Value.Style(strictBuilder = true) +public abstract class LoadTableEndpointExpectation extends IcebergRestExpectation { @Override public void create() { diff --git a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractExpectation.java b/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractExpectation.java deleted file mode 100644 index 8af5db7e..00000000 --- a/oauth2/core/src/testFixtures/java/com/dremio/iceberg/authmgr/oauth2/test/expectation/AbstractExpectation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2025 Dremio Corporation - * - * Licensed 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 com.dremio.iceberg.authmgr.oauth2.test.expectation; - -import com.dremio.iceberg.authmgr.oauth2.test.TestEnvironment; -import org.immutables.value.Value; - -public abstract class AbstractExpectation { - - @Value.Parameter(order = 1) - protected abstract TestEnvironment getTestEnvironment(); - - public abstract void create(); -} diff --git a/oauth2/flink-tests/build.gradle.kts b/oauth2/flink-tests/build.gradle.kts index 5a6cf9ba..743948fb 100644 --- a/oauth2/flink-tests/build.gradle.kts +++ b/oauth2/flink-tests/build.gradle.kts @@ -57,7 +57,6 @@ dependencies { intTestBase(platform(libs.junit.bom)) intTestBase("org.junit.jupiter:junit-jupiter") - intTestBase("org.junit.jupiter:junit-jupiter-api") intTestBase("org.junit.platform:junit-platform-launcher") intTestBase(libs.guava) diff --git a/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/FlinkPolarisRemoteIT.java b/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/FlinkPolarisRemoteIT.java index 105676ad..5b7abde3 100644 --- a/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/FlinkPolarisRemoteIT.java +++ b/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/FlinkPolarisRemoteIT.java @@ -17,7 +17,7 @@ import static com.dremio.iceberg.authmgr.oauth2.test.flink.RemoteAuthServerSupport.OAUTH2_AGENT_CONFIG_ENV; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; import com.google.common.collect.ImmutableMap; import java.util.Map; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; diff --git a/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/RemoteAuthServerSupport.java b/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/RemoteAuthServerSupport.java index a010e3e5..006308a2 100644 --- a/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/RemoteAuthServerSupport.java +++ b/oauth2/flink-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/flink/RemoteAuthServerSupport.java @@ -15,10 +15,10 @@ */ package com.dremio.iceberg.authmgr.oauth2.test.flink; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import java.io.IOException; @@ -100,7 +100,7 @@ public String fetchNewToken() { Map agentConfig = new HashMap<>(getAgentConfig()); agentConfig.put(TokenRefreshConfig.PREFIX + '.' + TokenRefreshConfig.ENABLED, "false"); try (var agent = - new OAuth2Agent(OAuth2Config.from(agentConfig), OAuth2AgentRuntime.of(executor))) { + new OAuth2Agent(OAuth2AgentConfig.from(agentConfig), OAuth2AgentRuntime.of(executor))) { return agent.authenticate().getValue(); } } finally { diff --git a/oauth2/kafka-tests/build.gradle.kts b/oauth2/kafka-tests/build.gradle.kts index 38c2e191..d8528070 100644 --- a/oauth2/kafka-tests/build.gradle.kts +++ b/oauth2/kafka-tests/build.gradle.kts @@ -66,7 +66,6 @@ dependencies { intTestBase(platform(libs.junit.bom)) intTestBase("org.junit.jupiter:junit-jupiter") - intTestBase("org.junit.jupiter:junit-jupiter-api") intTestBase("org.junit.platform:junit-platform-launcher") intTestBase(libs.httpclient5) diff --git a/oauth2/spark-tests/build.gradle.kts b/oauth2/spark-tests/build.gradle.kts index ea5da136..b88cdc36 100644 --- a/oauth2/spark-tests/build.gradle.kts +++ b/oauth2/spark-tests/build.gradle.kts @@ -55,7 +55,6 @@ dependencies { intTestBase(platform(libs.junit.bom)) intTestBase("org.junit.jupiter:junit-jupiter") - intTestBase("org.junit.jupiter:junit-jupiter-api") intTestBase("org.junit.platform:junit-platform-launcher") intTestBase(libs.guava) diff --git a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/RemoteAuthServerSupport.java b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/RemoteAuthServerSupport.java index 9f2ee7bd..2eb35c26 100644 --- a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/RemoteAuthServerSupport.java +++ b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/RemoteAuthServerSupport.java @@ -15,10 +15,10 @@ */ package com.dremio.iceberg.authmgr.oauth2.test.spark.remote; -import com.dremio.iceberg.authmgr.oauth2.OAuth2Config; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2Agent; +import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentConfig; import com.dremio.iceberg.authmgr.oauth2.agent.OAuth2AgentRuntime; -import com.dremio.iceberg.authmgr.oauth2.config.TokenRefreshConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.TokenRefreshConfig; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import java.io.IOException; @@ -100,7 +100,7 @@ public String fetchNewToken() { Map agentConfig = new HashMap<>(getAgentConfig()); agentConfig.put(TokenRefreshConfig.PREFIX + '.' + TokenRefreshConfig.ENABLED, "false"); try (var agent = - new OAuth2Agent(OAuth2Config.from(agentConfig), OAuth2AgentRuntime.of(executor))) { + new OAuth2Agent(OAuth2AgentConfig.from(agentConfig), OAuth2AgentRuntime.of(executor))) { return agent.authenticate().getValue(); } } finally { diff --git a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkNessieRemoteIT.java b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkNessieRemoteIT.java index dfd8947c..5f051cdf 100644 --- a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkNessieRemoteIT.java +++ b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkNessieRemoteIT.java @@ -17,7 +17,7 @@ import static com.dremio.iceberg.authmgr.oauth2.test.spark.remote.RemoteAuthServerSupport.OAUTH2_AGENT_CONFIG_ENV; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; import com.dremio.iceberg.authmgr.oauth2.test.spark.SparkITBase; import com.google.common.collect.ImmutableMap; import java.net.URI; diff --git a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkPolarisRemoteIT.java b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkPolarisRemoteIT.java index 2da83f0b..f5198126 100644 --- a/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkPolarisRemoteIT.java +++ b/oauth2/spark-tests/src/intTest/java/com/dremio/iceberg/authmgr/oauth2/test/spark/remote/SparkPolarisRemoteIT.java @@ -17,7 +17,7 @@ import static com.dremio.iceberg.authmgr.oauth2.test.spark.remote.RemoteAuthServerSupport.OAUTH2_AGENT_CONFIG_ENV; -import com.dremio.iceberg.authmgr.oauth2.config.BasicConfig; +import com.dremio.iceberg.authmgr.oauth2.agent.config.BasicConfig; import com.dremio.iceberg.authmgr.oauth2.test.spark.SparkITBase; import com.google.common.collect.ImmutableMap; import java.net.URI; diff --git a/oauth2/tests/src/main/java/com/dremio/iceberg/authmgr/oauth2/test/container/PolarisContainer.java b/oauth2/tests/src/main/java/com/dremio/iceberg/authmgr/oauth2/test/container/PolarisContainer.java index 43549da3..235a08b1 100644 --- a/oauth2/tests/src/main/java/com/dremio/iceberg/authmgr/oauth2/test/container/PolarisContainer.java +++ b/oauth2/tests/src/main/java/com/dremio/iceberg/authmgr/oauth2/test/container/PolarisContainer.java @@ -47,7 +47,7 @@ public class PolarisContainer extends GenericContainer { @SuppressWarnings("resource") public PolarisContainer() { - super("apache/polaris:1.3.0-incubating"); + super("apache/polaris:1.5.0"); withNetworkAliases("polaris"); withLogConsumer(new Slf4jLogConsumer(LOGGER)); withExposedPorts(8181, 8182);