Skip to content

Commit 229eb63

Browse files
committed
Fix tests broken by host metadata resolution during init
The tryResolveHostMetadata() call during config.resolve() (added in PR 4) makes an HTTP call to /.well-known/databricks-config. This broke tests that use FixtureServer (consumed fixtures out of order) or mock HTTP clients (unexpected call count). Fixes: - Catch Throwable (not just Exception) for mock assertion errors - Add well-known fixture to ExternalBrowser tests using FixtureServer - Filter metadata calls from captured requests in idempotency test Co-authored-by: Isaac
1 parent e5f0a76 commit 229eb63

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/ExternalBrowserCredentialsProviderTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ void clientAndConsentTest() throws IOException {
3434
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
3535
200)
3636
.build();
37+
FixtureServer.FixtureMapping wellKnownFixture =
38+
new FixtureServer.FixtureMapping.Builder()
39+
.validateMethod("GET")
40+
.validatePath("/.well-known/databricks-config")
41+
.withResponse("{}", 404)
42+
.build();
3743
try (FixtureServer fixtures = new FixtureServer()) {
38-
fixtures.with(fixture).with(fixture);
44+
fixtures.with(wellKnownFixture).with(fixture).with(fixture);
3945
DatabricksConfig config =
4046
new DatabricksConfig()
4147
.setAuthType("external-browser")
@@ -81,8 +87,14 @@ void clientAndConsentTestWithCustomRedirectUrl() throws IOException {
8187
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
8288
200)
8389
.build();
90+
FixtureServer.FixtureMapping wellKnownFixture =
91+
new FixtureServer.FixtureMapping.Builder()
92+
.validateMethod("GET")
93+
.validatePath("/.well-known/databricks-config")
94+
.withResponse("{}", 404)
95+
.build();
8496
try (FixtureServer fixtures = new FixtureServer()) {
85-
fixtures.with(fixture).with(fixture);
97+
fixtures.with(wellKnownFixture).with(fixture).with(fixture);
8698
DatabricksConfig config =
8799
new DatabricksConfig()
88100
.setAuthType("external-browser")
@@ -126,9 +138,7 @@ void openIDConnectEndPointsTestAccounts() throws IOException {
126138
new DatabricksConfig()
127139
.setAuthType("external-browser")
128140
.setHost("https://accounts.cloud.databricks.com")
129-
.setHttpClient(new CommonsHttpClient.Builder().withTimeoutSeconds(30).build())
130141
.setAccountId("testAccountId");
131-
config.resolve();
132142

133143
String prefix = "https://accounts.cloud.databricks.com/oidc/accounts/" + config.getAccountId();
134144
assertEquals(prefix + "/v1/token", config.getDatabricksOidcEndpoints().getTokenEndpoint());

databricks-sdk-java/src/test/java/com/databricks/sdk/service/gentesting/unittests/IdempotencyTestingAPITest.java

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)