From b0d58a618e2f83403cfe863b4bcd3b2c5db2d155 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sun, 21 Aug 2022 21:32:53 -0400 Subject: [PATCH] Fix test --- server/server_matrix.go | 2 +- server/server_matrix_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server_matrix.go b/server/server_matrix.go index ebc2913..7204bfa 100644 --- a/server/server_matrix.go +++ b/server/server_matrix.go @@ -124,7 +124,7 @@ func newRequestFromMatrixJSON(r *http.Request, baseURL string, messageLimit int) } pushKey := m.Notification.Devices[0].PushKey // We ignore other devices for now, see discussion in #316 if !strings.HasPrefix(pushKey, baseURL+"/") { - return nil, &errMatrix{pushKey: pushKey, err: wrapErrHTTP(errHTTPBadRequestMatrixPushkeyBaseURLMismatch, "; received pushKey: %s, configured base url: %s", pushKey, baseURL)} + return nil, &errMatrix{pushKey: pushKey, err: wrapErrHTTP(errHTTPBadRequestMatrixPushkeyBaseURLMismatch, "received push key: %s, configured base URL: %s", pushKey, baseURL)} } newRequest, err := http.NewRequest(http.MethodPost, pushKey, io.NopCloser(bytes.NewReader(body.PeekedBytes))) if err != nil { diff --git a/server/server_matrix_test.go b/server/server_matrix_test.go index 9129d6c..b2f9b1d 100644 --- a/server/server_matrix_test.go +++ b/server/server_matrix_test.go @@ -56,7 +56,7 @@ func TestMatrix_NewRequestFromMatrixJSON_MismatchingPushKey(t *testing.T) { _, err := newRequestFromMatrixJSON(r, baseURL, maxLength) matrixErr, ok := err.(*errMatrix) require.True(t, ok) - require.Equal(t, errHTTPBadRequestMatrixPushkeyBaseURLMismatch, matrixErr.err) + require.Equal(t, "invalid request: push key must be prefixed with base URL, received push key: https://ntfy.example.com/upABCDEFGHI?up=1, configured base URL: https://ntfy.sh", matrixErr.err.Error()) require.Equal(t, "https://ntfy.example.com/upABCDEFGHI?up=1", matrixErr.pushKey) }