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

Function TestWebpushSubscribeRejectsInvalidEndpoint

coderd/webpush_test.go:148–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestWebpushSubscribeRejectsInvalidEndpoint(t *testing.T) {
149 t.Parallel()
150
151 ctx := testutil.Context(t, testutil.WaitShort)
152 client := coderdtest.New(t, &coderdtest.Options{
153 WebpushDispatcher: &testWebpushDispatcher{},
154 })
155 owner := coderdtest.CreateFirstUser(t, client)
156 memberClient, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
157
158 err := memberClient.PostWebpushSubscription(ctx, "me", codersdk.WebpushSubscription{
159 Endpoint: "http://127.0.0.1:8080/subscription",
160 AuthKey: validEndpointAuthKey,
161 P256DHKey: validEndpointP256dhKey,
162 })
163 var sdkError *codersdk.Error
164 require.Error(t, err)
165 require.ErrorAsf(t, err, &sdkError, "error should be of type *codersdk.Error")
166 require.Equal(t, http.StatusBadRequest, sdkError.StatusCode())
167 require.Contains(t, sdkError.Error(), "endpoint URL scheme must be https")
168}
169
170// testWebpushErrorStore wraps a real database.Store and allows injecting
171// errors into GetWebpushSubscriptionsByUserID.

Callers

nothing calls this directly

Calls 10

StatusCodeMethod · 0.95
ErrorMethod · 0.95
ContextFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
ErrorMethod · 0.45
EqualMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected