Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3773ec1

Browse files
committed
fix: serve test derp map locally
1 parent4672849 commit3773ec1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

‎cli/cliutil/awscheck_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestIPV4Check(t *testing.T) {
4141
},
4242
})
4343
}))
44+
t.Cleanup(srv.Close)
4445
ctx:=testutil.Context(t,testutil.WaitShort)
4546
ranges,err:=FetchAWSIPRanges(ctx,srv.URL)
4647
require.NoError(t,err)

‎cli/server_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ import (
4545
"github.com/coder/coder/v2/cli/config"
4646
"github.com/coder/coder/v2/coderd/coderdtest"
4747
"github.com/coder/coder/v2/coderd/database/dbtestutil"
48+
"github.com/coder/coder/v2/coderd/httpapi"
4849
"github.com/coder/coder/v2/coderd/telemetry"
4950
"github.com/coder/coder/v2/codersdk"
5051
"github.com/coder/coder/v2/cryptorand"
5152
"github.com/coder/coder/v2/pty/ptytest"
53+
"github.com/coder/coder/v2/tailnet/tailnettest"
5254
"github.com/coder/coder/v2/testutil"
5355
)
5456

@@ -1832,6 +1834,12 @@ func TestServer_InvalidDERP(t *testing.T) {
18321834
funcTestServer_DisabledDERP(t*testing.T) {
18331835
t.Parallel()
18341836

1837+
derpMap,_:=tailnettest.RunDERPAndSTUN(t)
1838+
srv:=httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
1839+
httpapi.Write(context.Background(),w,http.StatusOK,derpMap)
1840+
}))
1841+
t.Cleanup(srv.Close)
1842+
18351843
ctx,cancelFunc:=context.WithTimeout(context.Background(),testutil.WaitShort)
18361844
defercancelFunc()
18371845

@@ -1843,7 +1851,7 @@ func TestServer_DisabledDERP(t *testing.T) {
18431851
"--http-address",":0",
18441852
"--access-url","http://example.com",
18451853
"--derp-server-enable=false",
1846-
"--derp-config-url","https://controlplane.tailscale.com/derpmap/default",
1854+
"--derp-config-url",srv.URL,
18471855
)
18481856
clitest.Start(t,inv.WithContext(ctx))
18491857
accessURL:=waitAccessURL(t,cfg)

‎enterprise/coderd/coderd_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"net/http"
8+
"net/http/httptest"
89
"reflect"
910
"strings"
1011
"testing"
@@ -16,7 +17,9 @@ import (
1617
"go.uber.org/goleak"
1718

1819
"cdr.dev/slog/sloggers/slogtest"
20+
"github.com/coder/coder/v2/coderd/httpapi"
1921
"github.com/coder/coder/v2/coderd/rbac/policy"
22+
"github.com/coder/coder/v2/tailnet/tailnettest"
2023

2124
agplaudit"github.com/coder/coder/v2/coderd/audit"
2225
"github.com/coder/coder/v2/coderd/coderdtest"
@@ -456,13 +459,19 @@ func TestMultiReplica_EmptyRelayAddress(t *testing.T) {
456459
funcTestMultiReplica_EmptyRelayAddress_DisabledDERP(t*testing.T) {
457460
t.Parallel()
458461

462+
derpMap,_:=tailnettest.RunDERPAndSTUN(t)
463+
srv:=httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
464+
httpapi.Write(context.Background(),w,http.StatusOK,derpMap)
465+
}))
466+
t.Cleanup(srv.Close)
467+
459468
ctx:=testutil.Context(t,testutil.WaitLong)
460469
db,ps:=dbtestutil.NewDB(t)
461470
logger:=slogtest.Make(t,nil)
462471

463472
dv:=coderdtest.DeploymentValues(t)
464473
dv.DERP.Server.Enable=serpent.Bool(false)
465-
dv.DERP.Config.URL=serpent.String("https://controlplane.tailscale.com/derpmap/default")
474+
dv.DERP.Config.URL=serpent.String(srv.URL)
466475

467476
_,_=coderdenttest.New(t,&coderdenttest.Options{
468477
EntitlementsUpdateInterval:25*time.Millisecond,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp