Skip to content
Draft
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 @@ -240,7 +240,7 @@ private void tryResolveHostMetadata() {
}
try {
resolveHostMetadata();
} catch (Exception e) {
} catch (Throwable e) {
LOG.debug("Failed to resolve host metadata: {}", e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ void clientAndConsentTest() throws IOException {
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
200)
.build();
FixtureServer.FixtureMapping wellKnownFixture =
new FixtureServer.FixtureMapping.Builder()
.validateMethod("GET")
.validatePath("/.well-known/databricks-config")
.withResponse("{}", 404)
.build();
try (FixtureServer fixtures = new FixtureServer()) {
fixtures.with(fixture).with(fixture);
fixtures.with(wellKnownFixture).with(fixture).with(fixture);
DatabricksConfig config =
new DatabricksConfig()
.setAuthType("external-browser")
Expand Down Expand Up @@ -81,8 +87,14 @@ void clientAndConsentTestWithCustomRedirectUrl() throws IOException {
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
200)
.build();
FixtureServer.FixtureMapping wellKnownFixture =
new FixtureServer.FixtureMapping.Builder()
.validateMethod("GET")
.validatePath("/.well-known/databricks-config")
.withResponse("{}", 404)
.build();
try (FixtureServer fixtures = new FixtureServer()) {
fixtures.with(fixture).with(fixture);
fixtures.with(wellKnownFixture).with(fixture).with(fixture);
DatabricksConfig config =
new DatabricksConfig()
.setAuthType("external-browser")
Expand Down Expand Up @@ -126,9 +138,7 @@ void openIDConnectEndPointsTestAccounts() throws IOException {
new DatabricksConfig()
.setAuthType("external-browser")
.setHost("https://accounts.cloud.databricks.com")
.setHttpClient(new CommonsHttpClient.Builder().withTimeoutSeconds(30).build())
.setAccountId("testAccountId");
config.resolve();

String prefix = "https://accounts.cloud.databricks.com/oidc/accounts/" + config.getAccountId();
assertEquals(prefix + "/v1/token", config.getDatabricksOidcEndpoints().getTokenEndpoint());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.databricks.sdk.integration;

import static org.junit.jupiter.api.Assertions.*;

import com.databricks.sdk.core.DatabricksConfig;
import com.databricks.sdk.integration.framework.EnvContext;
import com.databricks.sdk.integration.framework.EnvOrSkip;
import com.databricks.sdk.integration.framework.EnvTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Integration test for host metadata resolution via /.well-known/databricks-config. Port of Go SDK
* #1546.
*/
@ExtendWith(EnvTest.class)
@EnvContext("ucws")
public class HostMetadataIT {
private static final Logger LOG = LoggerFactory.getLogger(HostMetadataIT.class);

@Test
void testResolvePopulatesFieldsFromMetadata(@EnvOrSkip("DATABRICKS_HOST") String host) {
DatabricksConfig config = new DatabricksConfig().setHost(host);
config.resolve();

LOG.info(
"Resolved metadata for {}: accountId={}, workspaceId={}, discoveryUrl={}",
host,
config.getAccountId(),
config.getWorkspaceId(),
config.getDiscoveryUrl());

// After resolve(), host metadata should have been resolved
assertNotNull(config.getDiscoveryUrl(), "Expected discoveryUrl to be populated after resolve");
assertFalse(config.getDiscoveryUrl().isEmpty(), "Expected non-empty discoveryUrl");
assertNotNull(config.getAccountId(), "Expected accountId to be populated after resolve");
assertFalse(config.getAccountId().isEmpty(), "Expected non-empty accountId");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading