-
Notifications
You must be signed in to change notification settings - Fork 894
feat: allow prefixes at the beginning of subdomain app hostnames #10150
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat: allow prefixes at the beginning of subdomain app hostnames
- Loading branch information
commit 2a7f2e3726d6f6fa9260aed115bc6f93d358128d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,14 @@ import ( | |
"github.com/coder/coder/v2/coderd/workspaceapps" | ||
"github.com/coder/coder/v2/codersdk" | ||
"github.com/coder/coder/v2/codersdk/agentsdk" | ||
"github.com/coder/coder/v2/cryptorand" | ||
"github.com/coder/coder/v2/provisioner/echo" | ||
"github.com/coder/coder/v2/provisionersdk/proto" | ||
"github.com/coder/coder/v2/testutil" | ||
) | ||
|
||
const ( | ||
proxyTestAgentName = "agent-name" | ||
proxyTestAgentName = "agnt-name" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol did we hit a limit in the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we hit the 62 char limit lol, Marcin reverted his PR though so it should be fine now hopefully |
||
proxyTestAppNameFake = "taf" | ||
proxyTestAppNameOwner = "tao" | ||
proxyTestAppNameAuthenticated = "taa" | ||
|
@@ -88,7 +89,9 @@ type App struct { | |
AgentName string | ||
AppSlugOrPort string | ||
|
||
Query string | ||
// Prefix should have ---. | ||
Prefix string | ||
Query string | ||
} | ||
|
||
// Details are the full test details returned from setupProxyTestWithFactory. | ||
|
@@ -143,6 +146,7 @@ func (d *Details) PathAppURL(app App) *url.URL { | |
// SubdomainAppURL returns the URL for the given subdomain app. | ||
func (d *Details) SubdomainAppURL(app App) *url.URL { | ||
appHost := httpapi.ApplicationURL{ | ||
Prefix: app.Prefix, | ||
AppSlugOrPort: app.AppSlugOrPort, | ||
AgentName: app.AgentName, | ||
WorkspaceName: app.WorkspaceName, | ||
|
@@ -252,6 +256,7 @@ func appServer(t *testing.T, headers http.Header, isHTTPS bool) uint16 { | |
_, err := r.Cookie(codersdk.SessionTokenCookie) | ||
assert.ErrorIs(t, err, http.ErrNoCookie) | ||
w.Header().Set("X-Forwarded-For", r.Header.Get("X-Forwarded-For")) | ||
w.Header().Set("X-Got-Host", r.Host) | ||
for name, values := range headers { | ||
for _, value := range values { | ||
w.Header().Add(name, value) | ||
|
@@ -290,6 +295,17 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U | |
scheme = "https" | ||
} | ||
|
||
// Workspace name needs to be short to avoid hitting 62 char hostname | ||
// segment limit. | ||
workspaceName, err := cryptorand.String(6) | ||
require.NoError(t, err) | ||
workspaceName = "ws-" + workspaceName | ||
workspaceMutators = append([]func(*codersdk.CreateWorkspaceRequest){ | ||
func(req *codersdk.CreateWorkspaceRequest) { | ||
req.Name = workspaceName | ||
}, | ||
}, workspaceMutators...) | ||
|
||
appURL := fmt.Sprintf("%s://127.0.0.1:%d?%s", scheme, port, proxyTestAppQuery) | ||
protoApps := []*proto.App{ | ||
{ | ||
|
@@ -354,6 +370,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U | |
require.True(t, app.Subdomain) | ||
|
||
appURL := httpapi.ApplicationURL{ | ||
Prefix: "", | ||
// findProtoApp is needed as the order of apps returned from PG database | ||
// is not guaranteed. | ||
AppSlugOrPort: findProtoApp(t, protoApps, app.Slug).Slug, | ||
|
@@ -382,6 +399,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U | |
require.NoError(t, err) | ||
|
||
appHost := httpapi.ApplicationURL{ | ||
Prefix: "", | ||
AppSlugOrPort: "{{port}}", | ||
AgentName: proxyTestAgentName, | ||
WorkspaceName: workspace.Name, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.