Skip to content

Commit 3ddedf1

Browse files
committed
more tests
1 parent 352a01d commit 3ddedf1

File tree

4 files changed

+89
-4
lines changed

4 files changed

+89
-4
lines changed

databricks-sdk-java/src/test/java/com/databricks/sdk/integration/OidcAccountEndpointIT.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.databricks.sdk.integration;
22

33
import com.databricks.sdk.AccountClient;
4+
import com.databricks.sdk.core.DatabricksConfig;
45
import com.databricks.sdk.core.oauth.OpenIDConnectEndpoints;
56
import com.databricks.sdk.integration.framework.EnvContext;
67
import com.databricks.sdk.integration.framework.EnvTest;
78
import java.io.IOException;
89
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
911
import org.junit.jupiter.api.extension.ExtendWith;
1012

1113
@EnvContext("account")
1214
@ExtendWith(EnvTest.class)
1315
public class OidcAccountEndpointIT {
1416
@Test
15-
void lists(AccountClient a) throws IOException {
17+
void checkEndpoints(AccountClient a) throws IOException {
1618
OpenIDConnectEndpoints endpoints = a.config().getOidcEndpoints();
1719
String host = a.config().getHost();
1820
String accountId = a.config().getAccountId();
@@ -28,4 +30,33 @@ void lists(AccountClient a) throws IOException {
2830
.equals(host + "/oidc/accounts/" + accountId + "/v1/token");
2931
}
3032
}
33+
34+
@Test
35+
void unifiedEndpoints(AccountClient a) throws IOException {
36+
DatabricksConfig cfg = a.config();
37+
cfg.setExperimentalIsUnifiedHost(true);
38+
OpenIDConnectEndpoints endpoints = cfg.getOidcEndpoints();
39+
String host = cfg.getHost();
40+
String accountId = cfg.getAccountId();
41+
assert endpoints
42+
.getAuthorizationEndpoint()
43+
.equals(host + "/oidc/accounts/" + accountId + "/v1/authorize");
44+
assert endpoints.getTokenEndpoint().equals(host + "/oidc/accounts/" + accountId + "/v1/token");
45+
}
46+
47+
@Test
48+
@EnabledIfEnvironmentVariable(named = "UNIFIED_HOST", matches = ".+")
49+
void unifiedEndpointsForSpog(AccountClient a) throws IOException {
50+
String unifiedHost = System.getenv("UNIFIED_HOST");
51+
DatabricksConfig cfg = a.config();
52+
cfg.setHost(unifiedHost);
53+
cfg.setExperimentalIsUnifiedHost(true);
54+
OpenIDConnectEndpoints endpoints = cfg.getOidcEndpoints();
55+
String host = cfg.getHost();
56+
String accountId = cfg.getAccountId();
57+
assert endpoints
58+
.getAuthorizationEndpoint()
59+
.equals(host + "/oidc/accounts/" + accountId + "/v1/authorize");
60+
assert endpoints.getTokenEndpoint().equals(host + "/oidc/accounts/" + accountId + "/v1/token");
61+
}
3162
}

databricks-sdk-java/src/test/java/com/databricks/sdk/integration/OidcUcAccountEndpointIT.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.databricks.sdk.integration;
22

33
import com.databricks.sdk.AccountClient;
4+
import com.databricks.sdk.core.DatabricksConfig;
45
import com.databricks.sdk.core.oauth.OpenIDConnectEndpoints;
56
import com.databricks.sdk.integration.framework.EnvContext;
67
import com.databricks.sdk.integration.framework.EnvTest;
78
import java.io.IOException;
89
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
911
import org.junit.jupiter.api.extension.ExtendWith;
1012

1113
@EnvContext("ucacct")
1214
@ExtendWith(EnvTest.class)
1315
public class OidcUcAccountEndpointIT {
1416
@Test
15-
void lists(AccountClient a) throws IOException {
17+
void checkEndpoints(AccountClient a) throws IOException {
1618
OpenIDConnectEndpoints endpoints = a.config().getOidcEndpoints();
1719
String host = a.config().getHost();
1820
String accountId = a.config().getAccountId();
@@ -28,4 +30,20 @@ void lists(AccountClient a) throws IOException {
2830
.equals(host + "/oidc/accounts/" + accountId + "/v1/token");
2931
}
3032
}
33+
34+
@Test
35+
@EnabledIfEnvironmentVariable(named = "UNIFIED_HOST", matches = ".+")
36+
void unifiedEndpointsForSpog(AccountClient a) throws IOException {
37+
String unifiedHost = System.getenv("UNIFIED_HOST");
38+
DatabricksConfig cfg = a.config();
39+
cfg.setHost(unifiedHost);
40+
cfg.setExperimentalIsUnifiedHost(true);
41+
OpenIDConnectEndpoints endpoints = cfg.getOidcEndpoints();
42+
String host = cfg.getHost();
43+
String accountId = cfg.getAccountId();
44+
assert endpoints
45+
.getAuthorizationEndpoint()
46+
.equals(host + "/oidc/accounts/" + accountId + "/v1/authorize");
47+
assert endpoints.getTokenEndpoint().equals(host + "/oidc/accounts/" + accountId + "/v1/token");
48+
}
3149
}
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
package com.databricks.sdk.integration;
22

33
import com.databricks.sdk.WorkspaceClient;
4+
import com.databricks.sdk.core.DatabricksConfig;
45
import com.databricks.sdk.core.oauth.OpenIDConnectEndpoints;
56
import com.databricks.sdk.integration.framework.EnvContext;
67
import com.databricks.sdk.integration.framework.EnvTest;
78
import java.io.IOException;
89
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
911
import org.junit.jupiter.api.extension.ExtendWith;
1012

1113
@EnvContext("ucws")
1214
@ExtendWith(EnvTest.class)
1315
public class OidcUcWorkspaceEndpointIT {
1416
@Test
15-
void lists(WorkspaceClient w) throws IOException {
17+
void checkEndpoints(WorkspaceClient w) throws IOException {
1618
OpenIDConnectEndpoints endpoints = w.config().getOidcEndpoints();
1719
String host = w.config().getHost();
1820
assert endpoints.getAuthorizationEndpoint().equals(host + "/oidc/v1/authorize");
1921
assert endpoints.getTokenEndpoint().equals(host + "/oidc/v1/token");
2022
}
23+
24+
@Test
25+
@EnabledIfEnvironmentVariable(named = "UNIFIED_HOST", matches = ".+")
26+
void unifiedEndpointsForSpog(WorkspaceClient c) throws IOException {
27+
String unifiedHost = System.getenv("UNIFIED_HOST");
28+
DatabricksConfig cfg = c.config();
29+
cfg.setHost(unifiedHost);
30+
cfg.setExperimentalIsUnifiedHost(true);
31+
OpenIDConnectEndpoints endpoints = cfg.getOidcEndpoints();
32+
String host = cfg.getHost();
33+
String accountId = cfg.getAccountId();
34+
assert endpoints
35+
.getAuthorizationEndpoint()
36+
.equals(host + "/oidc/accounts/" + accountId + "/v1/authorize");
37+
assert endpoints.getTokenEndpoint().equals(host + "/oidc/accounts/" + accountId + "/v1/token");
38+
}
2139
}
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
package com.databricks.sdk.integration;
22

33
import com.databricks.sdk.WorkspaceClient;
4+
import com.databricks.sdk.core.DatabricksConfig;
45
import com.databricks.sdk.core.oauth.OpenIDConnectEndpoints;
56
import com.databricks.sdk.integration.framework.EnvContext;
67
import com.databricks.sdk.integration.framework.EnvTest;
78
import java.io.IOException;
89
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
911
import org.junit.jupiter.api.extension.ExtendWith;
1012

1113
@EnvContext("workspace")
1214
@ExtendWith(EnvTest.class)
1315
public class OidcWorkspaceEndpointIT {
1416
@Test
15-
void lists(WorkspaceClient w) throws IOException {
17+
void checkEndpoints(WorkspaceClient w) throws IOException {
1618
OpenIDConnectEndpoints endpoints = w.config().getOidcEndpoints();
1719
String host = w.config().getHost();
1820
assert endpoints.getAuthorizationEndpoint().equals(host + "/oidc/v1/authorize");
1921
assert endpoints.getTokenEndpoint().equals(host + "/oidc/v1/token");
2022
}
23+
24+
@Test
25+
@EnabledIfEnvironmentVariable(named = "UNIFIED_HOST", matches = ".+")
26+
void unifiedEndpointsForSpog(WorkspaceClient c) throws IOException {
27+
String unifiedHost = System.getenv("UNIFIED_HOST");
28+
DatabricksConfig cfg = c.config();
29+
cfg.setHost(unifiedHost);
30+
cfg.setExperimentalIsUnifiedHost(true);
31+
OpenIDConnectEndpoints endpoints = cfg.getOidcEndpoints();
32+
String host = cfg.getHost();
33+
String accountId = cfg.getAccountId();
34+
assert endpoints
35+
.getAuthorizationEndpoint()
36+
.equals(host + "/oidc/accounts/" + accountId + "/v1/authorize");
37+
assert endpoints.getTokenEndpoint().equals(host + "/oidc/accounts/" + accountId + "/v1/token");
38+
}
2139
}

0 commit comments

Comments
 (0)