MCPcopy Index your code
hub / github.com/coder/coder / TestValidateWebpushEndpoint

Function TestValidateWebpushEndpoint

coderd/webpush_internal_test.go:10–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestValidateWebpushEndpoint(t *testing.T) {
11 t.Parallel()
12
13 tests := []struct {
14 name string
15 endpoint string
16 wantErr bool
17 errSubstr string
18 }{
19 {
20 name: "valid https endpoint",
21 endpoint: "https://fcm.googleapis.com/fcm/send/abc123",
22 wantErr: false,
23 },
24 {
25 name: "valid https endpoint with port",
26 endpoint: "https://push.example.com:8443/subscription",
27 wantErr: false,
28 },
29 {
30 name: "relative URL",
31 endpoint: "/push/subscription",
32 wantErr: true,
33 errSubstr: "absolute URL",
34 },
35 {
36 name: "http scheme rejected",
37 endpoint: "http://push.example.com/subscription",
38 wantErr: true,
39 errSubstr: "scheme must be https",
40 },
41 {
42 name: "custom scheme rejected",
43 endpoint: "ws://push.example.com/subscription",
44 wantErr: true,
45 errSubstr: "scheme must be https",
46 },
47 {
48 name: "empty host",
49 endpoint: "https:///path",
50 wantErr: true,
51 errSubstr: "host is required",
52 },
53 {
54 name: "userinfo rejected",
55 endpoint: "https://user:pass@push.example.com/subscription",
56 wantErr: true,
57 errSubstr: "must not include userinfo",
58 },
59 {
60 name: "localhost rejected",
61 endpoint: "https://localhost/subscription",
62 wantErr: true,
63 errSubstr: "must not be localhost",
64 },
65 {
66 name: "subdomain of localhost rejected",
67 endpoint: "https://foo.localhost/subscription",

Callers

nothing calls this directly

Calls 4

validateWebpushEndpointFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected