Skip to content

Commit 9676aaf

Browse files
committed
Remove redundant resolveHostMetadata() calls, use host_type metadata
- Remove redundant explicit resolveHostMetadata() calls since resolve() already triggers it internally via tryResolveHostMetadata(). Revert to single fixtures where the second call was removed. - Keep double fixture only for testResolveHostMetadataDoesNotOverwriteExistingHostType which genuinely needs a second resolveHostMetadata() call. - Use host_type in metadata response instead of experimentalIsUnifiedHost flag (removed by PR #720) to make getClientType() return ACCOUNT.
1 parent 1986cf8 commit 9676aaf

1 file changed

Lines changed: 7 additions & 28 deletions

File tree

databricks-sdk-java/src/test/java/com/databricks/sdk/core/DatabricksConfigTest.java

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,9 @@ public void testResolveHostMetadataPopulatesResolvedHostType() throws IOExceptio
668668
+ "\","
669669
+ "\"host_type\":\"workspace\"}";
670670
try (FixtureServer server =
671-
new FixtureServer()
672-
.with("GET", "/.well-known/databricks-config", response, 200)
673-
.with("GET", "/.well-known/databricks-config", response, 200)) {
671+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
674672
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
675673
config.resolve(emptyEnv());
676-
config.resolveHostMetadata();
677674
assertEquals(HostType.WORKSPACE, config.getResolvedHostType());
678675
}
679676
}
@@ -707,12 +704,9 @@ public void testResolveHostMetadataUnknownHostTypeIgnored() throws IOException {
707704
+ "\","
708705
+ "\"host_type\":\"unknown_value\"}";
709706
try (FixtureServer server =
710-
new FixtureServer()
711-
.with("GET", "/.well-known/databricks-config", response, 200)
712-
.with("GET", "/.well-known/databricks-config", response, 200)) {
707+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
713708
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
714709
config.resolve(emptyEnv());
715-
config.resolveHostMetadata();
716710
assertNull(config.getResolvedHostType());
717711
}
718712
}
@@ -726,12 +720,9 @@ public void testResolveHostMetadataHostTypeAccount() throws IOException {
726720
+ "\","
727721
+ "\"host_type\":\"account\"}";
728722
try (FixtureServer server =
729-
new FixtureServer()
730-
.with("GET", "/.well-known/databricks-config", response, 200)
731-
.with("GET", "/.well-known/databricks-config", response, 200)) {
723+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
732724
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
733725
config.resolve(emptyEnv());
734-
config.resolveHostMetadata();
735726
assertEquals(HostType.ACCOUNTS, config.getResolvedHostType());
736727
}
737728
}
@@ -745,12 +736,9 @@ public void testResolveHostMetadataHostTypeUnified() throws IOException {
745736
+ "\","
746737
+ "\"host_type\":\"unified\"}";
747738
try (FixtureServer server =
748-
new FixtureServer()
749-
.with("GET", "/.well-known/databricks-config", response, 200)
750-
.with("GET", "/.well-known/databricks-config", response, 200)) {
739+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
751740
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
752741
config.resolve(emptyEnv());
753-
config.resolveHostMetadata();
754742
assertEquals(HostType.UNIFIED, config.getResolvedHostType());
755743
}
756744
}
@@ -766,12 +754,9 @@ public void testResolveHostMetadataSetsTokenAudienceFromDefaultOidcAudience() th
766754
+ "\","
767755
+ "\"default_oidc_audience\":\"https://ws.databricks.com/oidc/v1/token\"}";
768756
try (FixtureServer server =
769-
new FixtureServer()
770-
.with("GET", "/.well-known/databricks-config", response, 200)
771-
.with("GET", "/.well-known/databricks-config", response, 200)) {
757+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
772758
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
773759
config.resolve(emptyEnv());
774-
config.resolveHostMetadata();
775760
assertEquals("https://ws.databricks.com/oidc/v1/token", config.getTokenAudience());
776761
}
777762
}
@@ -788,13 +773,10 @@ public void testResolveHostMetadataDefaultOidcAudiencePriorityOverAccountIdFallb
788773
+ "\"host_type\":\"account\","
789774
+ "\"default_oidc_audience\":\"custom-audience\"}";
790775
try (FixtureServer server =
791-
new FixtureServer()
792-
.with("GET", "/.well-known/databricks-config", response, 200)
793-
.with("GET", "/.well-known/databricks-config", response, 200)) {
776+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
794777
DatabricksConfig config =
795778
new DatabricksConfig().setHost(server.getUrl()).setAccountId(DUMMY_ACCOUNT_ID);
796779
config.resolve(emptyEnv());
797-
config.resolveHostMetadata();
798780
// Should use default_oidc_audience, NOT account_id
799781
assertEquals("custom-audience", config.getTokenAudience());
800782
}
@@ -810,13 +792,10 @@ public void testResolveHostMetadataDoesNotOverrideExistingTokenAudienceWithOidcA
810792
+ "\","
811793
+ "\"default_oidc_audience\":\"metadata-audience\"}";
812794
try (FixtureServer server =
813-
new FixtureServer()
814-
.with("GET", "/.well-known/databricks-config", response, 200)
815-
.with("GET", "/.well-known/databricks-config", response, 200)) {
795+
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
816796
DatabricksConfig config =
817797
new DatabricksConfig().setHost(server.getUrl()).setTokenAudience("existing-audience");
818798
config.resolve(emptyEnv());
819-
config.resolveHostMetadata();
820799
assertEquals("existing-audience", config.getTokenAudience());
821800
}
822801
}

0 commit comments

Comments
 (0)