Skip to content

Allows different ports in host mismatch check #2681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ilyakuz-db
Copy link
Contributor

Changes

Allow different ports to be defined in profile/env and config host

Why

In Web Terminal DATABRICKS_HOST variable is set with explicit 443 port

Tests

Unit test

@ilyakuz-db ilyakuz-db temporarily deployed to test-trigger-is April 8, 2025 15:02 — with GitHub Actions Inactive
@ilyakuz-db ilyakuz-db temporarily deployed to test-trigger-is April 8, 2025 15:08 — with GitHub Actions Inactive
@@ -37,7 +37,7 @@ func MatchHost(host1, host2 string) bool {
if err != nil {
return false
}
return u1.Host == u2.Host
return u1.Hostname() == u2.Hostname()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any cases when port difference should be not allowed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general different port means different URL, so https://x.com should be equal to https://x.com:443 but not to any other port.

@@ -28,6 +28,7 @@ func TestNormalizeHost(t *testing.T) {
func TestMatchHost(t *testing.T) {
assert.True(t, MatchHost("https://foo.com", "https://foo.com"))
assert.True(t, MatchHost("https://foo.com", "foo.com"))
assert.True(t, MatchHost("https://foo.com", "https://foo.com:443"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for

assert.False(t, MatchHost("https://foo.com", "https://foo.com:4430"))
assert.False(t, MatchHost("https://foo.com", "https://foo.com:80"))

@@ -37,7 +37,7 @@ func MatchHost(host1, host2 string) bool {
if err != nil {
return false
}
return u1.Host == u2.Host
return u1.Hostname() == u2.Hostname()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general different port means different URL, so https://x.com should be equal to https://x.com:443 but not to any other port.

@ilyakuz-db
Copy link
Contributor Author

We can probably close this one as original feature for DATABRICKS_HOST mismatch check was reverted

@ilyakuz-db ilyakuz-db closed this Apr 29, 2025
@ilyakuz-db
Copy link
Contributor Author

Closing as DATABRICKS_HOST mismatch check was reverted

@pietern pietern deleted the allow-443-port-in-mismatch branch April 29, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants