tinyrelayfile
tinyrelay/internal/daemon/site_host_test.go/

internal/daemon/site_host_test.go raw
1package daemon
2
3import (
4 "context"
5 "net/http"
6 "net/http/httptest"
7 "strings"
8 "testing"
9)
10
11func TestUnclaimedSubdomainsOfTheSiteDomainAreNotFound(t *testing.T) {
12 ctx := context.Background()
13 app, err := New(ctx, Config{DataDir: t.TempDir(), DefaultTenant: "main", PublicURL: "https://relay.test"})
14 if err != nil {
15 t.Fatal(err)
16 }
17 defer app.Close(ctx)
18 meta, err := app.Create(ctx, CreateOptions{Name: "main", Owner: strings.Repeat("a", 64), Template: "default"})
19 if err != nil {
20 t.Fatal(err)
21 }
22 tenant, err := app.tenant(ctx, meta, "https://relay.test")
23 if err != nil {
24 t.Fatal(err)
25 }
26 for host, want := range map[string]int{"relay.test": http.StatusOK, "bauhaus.relay.test": http.StatusNotFound, "tiny.tailnet.example": http.StatusOK, "127.0.0.1:7447": http.StatusOK} {
27 req := httptest.NewRequest(http.MethodGet, "http://"+host+"/", nil)
28 req.Host = host
29 res := httptest.NewRecorder()
30 tenant.ServeHTTP(res, req)
31 if res.Code != want {
32 t.Errorf("host %s: status %d, want %d", host, res.Code, want)
33 }
34 }
35}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs