diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2c4f434b21d6..50b58795b2af 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -574,12 +574,15 @@ jobs:
ABFS_FLAT_ACCESS_KEY: todo
ABFS_HIERARCHICAL_ACCOUNT: todo
ABFS_HIERARCHICAL_ACCESS_KEY: todo
+ ABFS_OAUTH_TENANT_ID: todo
+ ABFS_OAUTH_CLIENT_ID: todo
+ ABFS_OAUTH_CLIENT_SECRET: todo
# todo(https://github.com/trinodb/trino/issues/18998) Enable when we have env variables in place
# Run tests only if any of the secrets are present
if: >-
false &&
contains(matrix.modules, 'trino-filesystem-azure') && contains(matrix.profile, 'cloud-tests') &&
- (env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || env.ABFS_FLAT_ACCESS_KEY != '' || env.ABFS_HIERARCHICAL_ACCESS_KEY != '')
+ (env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || env.ABFS_FLAT_ACCESS_KEY != '' || env.ABFS_HIERARCHICAL_ACCESS_KEY != '' || env.ABFS_OAUTH_CLIENT_SECRET != '')
run: |
$MAVEN test ${MAVEN_TEST} -pl ${{ matrix.modules }} ${{ format('-P {0}', matrix.profile) }}
- name: GCS FileSystem Cloud Tests
diff --git a/lib/trino-filesystem-azure/pom.xml b/lib/trino-filesystem-azure/pom.xml
index 37daab223363..c5debdafdd3b 100644
--- a/lib/trino-filesystem-azure/pom.xml
+++ b/lib/trino-filesystem-azure/pom.xml
@@ -189,6 +189,8 @@
**/TestAzureFileSystemGen2Flat.java
**/TestAzureFileSystemGen2Hierarchical.java
+ **/TestAzureFileSystemOAuthGen2Flat.java
+ **/TestAzureFileSystemOAuthGen2Hierarchical.java
@@ -207,6 +209,8 @@
**/TestAzureFileSystemGen2Flat.java
**/TestAzureFileSystemGen2Hierarchical.java
+ **/TestAzureFileSystemOAuthGen2Flat.java
+ **/TestAzureFileSystemOAuthGen2Hierarchical.java
diff --git a/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/AbstractTestAzureFileSystem.java b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/AbstractTestAzureFileSystem.java
index ffff5a458888..ec38692a7bde 100644
--- a/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/AbstractTestAzureFileSystem.java
+++ b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/AbstractTestAzureFileSystem.java
@@ -68,6 +68,13 @@ protected void initializeWithAccessKey(String account, String accountKey, Accoun
initialize(account, new AzureAuthAccessKey(accountKey), accountKind);
}
+ protected void initializeWithOAuth(String account, String tenantId, String clientId, String clientSecret, AccountKind accountKind)
+ throws IOException
+ {
+ String clientEndpoint = "https://login.microsoftonline.com/%s/oauth2/v2.0/token".formatted(tenantId);
+ initialize(account, new AzureAuthOauth(clientEndpoint, tenantId, clientId, clientSecret), accountKind);
+ }
+
private void initialize(String account, AzureAuth azureAuth, AccountKind accountKind)
throws IOException
{
diff --git a/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Flat.java b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Flat.java
new file mode 100644
index 000000000000..82c3ac4efb55
--- /dev/null
+++ b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Flat.java
@@ -0,0 +1,38 @@
+/*
+ * 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 io.trino.filesystem.azure;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+
+import java.io.IOException;
+
+import static io.trino.filesystem.azure.AbstractTestAzureFileSystem.AccountKind.FLAT;
+
+@TestInstance(Lifecycle.PER_CLASS)
+public class TestAzureFileSystemOAuthGen2Flat
+ extends AbstractTestAzureFileSystem
+{
+ @BeforeAll
+ void setup()
+ throws IOException
+ {
+ String account = getRequiredEnvironmentVariable("ABFS_FLAT_ACCOUNT");
+ String tenantId = getRequiredEnvironmentVariable("ABFS_OAUTH_TENANT_ID");
+ String clientId = getRequiredEnvironmentVariable("ABFS_OAUTH_CLIENT_ID");
+ String clientSecret = getRequiredEnvironmentVariable("ABFS_OAUTH_CLIENT_SECRET");
+ initializeWithOAuth(account, tenantId, clientId, clientSecret, FLAT);
+ }
+}
diff --git a/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Hierarchical.java b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Hierarchical.java
new file mode 100644
index 000000000000..0276a6542b25
--- /dev/null
+++ b/lib/trino-filesystem-azure/src/test/java/io/trino/filesystem/azure/TestAzureFileSystemOAuthGen2Hierarchical.java
@@ -0,0 +1,38 @@
+/*
+ * 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 io.trino.filesystem.azure;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+
+import java.io.IOException;
+
+import static io.trino.filesystem.azure.AbstractTestAzureFileSystem.AccountKind.HIERARCHICAL;
+
+@TestInstance(Lifecycle.PER_CLASS)
+public class TestAzureFileSystemOAuthGen2Hierarchical
+ extends AbstractTestAzureFileSystem
+{
+ @BeforeAll
+ void setup()
+ throws IOException
+ {
+ String account = getRequiredEnvironmentVariable("ABFS_HIERARCHICAL_ACCOUNT");
+ String tenantId = getRequiredEnvironmentVariable("ABFS_OAUTH_TENANT_ID");
+ String clientId = getRequiredEnvironmentVariable("ABFS_OAUTH_CLIENT_ID");
+ String clientSecret = getRequiredEnvironmentVariable("ABFS_OAUTH_CLIENT_SECRET");
+ initializeWithOAuth(account, tenantId, clientId, clientSecret, HIERARCHICAL);
+ }
+}