| 509 | } |
| 510 | |
| 511 | func assertWebpushPayload(t testing.TB, r *http.Request) { |
| 512 | t.Helper() |
| 513 | assert.Equal(t, http.MethodPost, r.Method) |
| 514 | assert.Equal(t, "application/octet-stream", r.Header.Get("Content-Type")) |
| 515 | assert.Equal(t, r.Header.Get("content-encoding"), "aes128gcm") |
| 516 | assert.Contains(t, r.Header.Get("Authorization"), "vapid") |
| 517 | |
| 518 | // Attempting to decode the request body as JSON should fail as it is |
| 519 | // encrypted. |
| 520 | assert.Error(t, json.NewDecoder(r.Body).Decode(io.Discard)) |
| 521 | } |
| 522 | |
| 523 | // setupPushTest creates a common test setup for webpush notification tests. |
| 524 | // The test HTTP client bypasses SSRF protection so that httptest.Server |