Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e163d9

Browse files
committed
Fix access url passing
1 parent d6a1217 commit 1e163d9

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

enterprise/coderd/coderdenttest/proxytest.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,20 @@ import (
2222
"github.com/coder/coder/coderd/httpapi"
2323
"github.com/stretchr/testify/require"
2424

25-
"github.com/coder/coder/coderd/coderdtest"
26-
27-
"github.com/coder/coder/coderd/rbac"
2825
"github.com/prometheus/client_golang/prometheus"
2926

3027
"cdr.dev/slog"
3128
"cdr.dev/slog/sloggers/slogtest"
32-
"github.com/coder/coder/coderd/database"
33-
"github.com/coder/coder/coderd/database/dbauthz"
34-
"github.com/coder/coder/coderd/database/dbtestutil"
3529
)
3630

3731
type ProxyOptions struct {
3832
Name string
3933

40-
Database database.Store
41-
Pubsub database.Pubsub
42-
Authorizer rbac.Authorizer
4334
TLSCertificates []tls.Certificate
44-
ProxyURL *url.URL
4535
AppHostname string
36+
37+
// ProxyURL is optional
38+
ProxyURL *url.URL
4639
}
4740

4841
// NewWorkspaceProxy will configure a wsproxy.Server with the given options.
@@ -57,17 +50,6 @@ func NewWorkspaceProxy(t *testing.T, coderd *coderd.API, owner *codersdk.Client,
5750
options = &ProxyOptions{}
5851
}
5952

60-
if options.Authorizer == nil {
61-
options.Authorizer = &coderdtest.RecordingAuthorizer{
62-
Wrapped: rbac.NewCachingAuthorizer(prometheus.NewRegistry()),
63-
}
64-
}
65-
66-
if options.Database == nil {
67-
options.Database, options.Pubsub = dbtestutil.NewDB(t)
68-
options.Database = dbauthz.New(options.Database, options.Authorizer, slogtest.Make(t, nil).Leveled(slog.LevelDebug))
69-
}
70-
7153
// HTTP Server
7254
var mutex sync.RWMutex
7355
var handler http.Handler
@@ -132,11 +114,12 @@ func NewWorkspaceProxy(t *testing.T, coderd *coderd.API, owner *codersdk.Client,
132114
URL: accessURL.String(),
133115
WildcardHostname: options.AppHostname,
134116
})
117+
require.NoError(t, err, "failed to create workspace proxy")
135118

136119
wssrv, err := wsproxy.New(&wsproxy.Options{
137120
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),
138121
PrimaryAccessURL: coderd.AccessURL,
139-
AccessURL: options.ProxyURL,
122+
AccessURL: accessURL,
140123
AppHostname: options.AppHostname,
141124
AppHostnameRegex: appHostnameRegex,
142125
RealIPConfig: coderd.RealIPConfig,

enterprise/wsproxy/proxy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func (o *Options) Validate() error {
6868
errs.Required("PrimaryAccessURL", o.PrimaryAccessURL)
6969
errs.Required("AccessURL", o.AccessURL)
7070
errs.Required("RealIPConfig", o.RealIPConfig)
71-
errs.Required("Tracing", o.Tracing)
7271
errs.Required("PrometheusRegistry", o.PrometheusRegistry)
7372
errs.NotEmpty("ProxySessionToken", o.ProxySessionToken)
7473
errs.NotEmpty("AppSecurityKey", o.AppSecurityKey)

enterprise/wsproxy/proxy_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import (
44
"net"
55
"testing"
66

7-
"github.com/coder/coder/enterprise/coderd/license"
8-
9-
"github.com/coder/coder/codersdk"
10-
11-
"github.com/coder/coder/enterprise/coderd/coderdenttest"
12-
137
"github.com/coder/coder/cli/clibase"
148
"github.com/coder/coder/coderd/coderdtest"
159
"github.com/coder/coder/coderd/httpmw"
1610
"github.com/coder/coder/coderd/workspaceapps/apptest"
11+
"github.com/coder/coder/codersdk"
12+
"github.com/coder/coder/enterprise/coderd/coderdenttest"
13+
"github.com/coder/coder/enterprise/coderd/license"
1714
)
1815

1916
func TestExternalProxyWorkspaceApps(t *testing.T) {
@@ -56,8 +53,10 @@ func TestExternalProxyWorkspaceApps(t *testing.T) {
5653
})
5754

5855
// Create the external proxy
59-
proxyAPI := coderdenttest.NewWorkspaceProxy(t, api, client, &coderdenttest.ProxyOptions{})
60-
var _ = proxyAPI
56+
proxyAPI := coderdenttest.NewWorkspaceProxy(t, api, client, &coderdenttest.ProxyOptions{
57+
Name: "best-proxy",
58+
AppHostname: opts.AppHost,
59+
})
6160

6261
return &apptest.Deployment{
6362
Options: opts,

0 commit comments

Comments
 (0)