Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.polaris.service.it.env;

import static org.apache.polaris.service.it.env.PolarisApiEndpoints.REALM_HEADER;
import static org.apache.polaris.service.it.test.PolarisApplicationIntegrationTest.PRINCIPAL_ROLE_ALL;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
Expand All @@ -33,10 +32,12 @@ public final class IcebergHelper {
private IcebergHelper() {}

public static RESTCatalog restCatalog(
PolarisClient client,
PolarisApiEndpoints endpoints,
PrincipalWithCredentials credentials,
String catalog,
Map<String, String> extraProperties) {
String authToken = client.obtainToken(credentials);
SessionCatalog.SessionContext context = SessionCatalog.SessionContext.createEmpty();
RESTCatalog restCatalog =
new RESTCatalog(
Expand All @@ -50,12 +51,7 @@ public static RESTCatalog restCatalog(
ImmutableMap.<String, String>builder()
.put(
org.apache.iceberg.CatalogProperties.URI, endpoints.catalogApiEndpoint().toString())
.put(
OAuth2Properties.CREDENTIAL,
credentials.getCredentials().getClientId()
+ ":"
+ credentials.getCredentials().getClientSecret())
.put(OAuth2Properties.SCOPE, PRINCIPAL_ROLE_ALL)
.put(OAuth2Properties.TOKEN, authToken)
.put(
org.apache.iceberg.CatalogProperties.FILE_IO_IMPL,
"org.apache.iceberg.inmemory.InMemoryFileIO")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class PolarisApplicationIntegrationTest {
private static PolarisClient client;
private static ClientCredentials clientCredentials;
private static ClientPrincipal admin;
private static String authToken;

private String principalRoleName;
private String internalCatalogName;
Expand All @@ -118,6 +119,7 @@ public static void setup(PolarisApiEndpoints apiEndpoints, ClientPrincipal admin
realm = endpoints.realm();
admin = adminCredentials;
clientCredentials = adminCredentials.credentials();
authToken = client.obtainToken(clientCredentials);

testDir = Path.of("build/test_data/iceberg/" + realm);
FileUtils.deleteQuietly(testDir.toFile());
Expand Down Expand Up @@ -158,7 +160,7 @@ public void before(TestInfo testInfo) {
}

@AfterEach
public void cleanUp() throws Exception {
public void cleanUp() {
client.cleanUp(clientCredentials);
}

Expand Down Expand Up @@ -235,10 +237,8 @@ private static RESTSessionCatalog newSessionCatalog(String catalog) {
Map.of(
"uri",
endpoints.catalogApiEndpoint().toString(),
OAuth2Properties.CREDENTIAL,
clientCredentials.clientId() + ":" + clientCredentials.clientSecret(),
OAuth2Properties.SCOPE,
PRINCIPAL_ROLE_ALL,
OAuth2Properties.TOKEN,
authToken,
"warehouse",
catalog,
"header." + REALM_HEADER,
Expand Down Expand Up @@ -579,10 +579,8 @@ public void testWarehouseNotSpecified() throws IOException {
Map.of(
"uri",
endpoints.catalogApiEndpoint().toString(),
OAuth2Properties.CREDENTIAL,
clientCredentials.clientId() + ":" + clientCredentials.clientSecret(),
OAuth2Properties.SCOPE,
PRINCIPAL_ROLE_ALL,
OAuth2Properties.TOKEN,
authToken,
"warehouse",
emptyEnvironmentVariable,
"header." + REALM_HEADER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ public void before(TestInfo testInfo) {

restCatalog =
IcebergHelper.restCatalog(
endpoints, principalCredentials, currentCatalogName, extraPropertiesBuilder.build());
client,
endpoints,
principalCredentials,
currentCatalogName,
extraPropertiesBuilder.build());
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public void before(TestInfo testInfo) {
.build();
managementApi.createCatalog(principalRoleName, catalog);

restCatalog = IcebergHelper.restCatalog(endpoints, principalCredentials, catalogName, Map.of());
restCatalog =
IcebergHelper.restCatalog(client, endpoints, principalCredentials, catalogName, Map.of());
}

@AfterEach
Expand Down
Loading