summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrynn Crowley <littlehill723@gmail.com>2025-02-27 19:47:29 -0800
committerGitHub <noreply@github.com>2025-02-28 14:47:29 +1100
commit5d539ebc3c9f0ece55e52c86b66020b0d73da946 (patch)
tree2e5d7abae344aa24a3d64be6931b3440c7299e1c
parent09d003c9ed37e89aca84110547a0833a2fa05f70 (diff)
test(handlers): fix failing webauthn test with regex (#8846)
Fix test failing due to different call path on local systems vs buildkite. Signed-off-by: Brynn Crowley <littlehill723@gmail.com> Co-authored-by: James Elliott <james-d-elliott@users.noreply.github.com>
-rw-r--r--internal/handlers/func_test.go7
-rw-r--r--internal/handlers/handler_sign_webauthn_test.go3
2 files changed, 8 insertions, 2 deletions
diff --git a/internal/handlers/func_test.go b/internal/handlers/func_test.go
index 9a7fea267..75879e6d7 100644
--- a/internal/handlers/func_test.go
+++ b/internal/handlers/func_test.go
@@ -1,6 +1,7 @@
package handlers
import (
+ "strings"
"testing"
"github.com/sirupsen/logrus"
@@ -29,7 +30,11 @@ func AssertLogEntryMessageAndError(t *testing.T, entry *logrus.Entry, message, e
assert.True(t, ok)
require.NotNil(t, theErr)
- assert.EqualError(t, theErr, err)
+ if strings.HasPrefix(err, "^") && strings.HasSuffix(err, "$") {
+ assert.Regexp(t, err, theErr.Error())
+ } else {
+ assert.EqualError(t, theErr, err)
+ }
}
}
diff --git a/internal/handlers/handler_sign_webauthn_test.go b/internal/handlers/handler_sign_webauthn_test.go
index d5ee6ce8d..a975372eb 100644
--- a/internal/handlers/handler_sign_webauthn_test.go
+++ b/internal/handlers/handler_sign_webauthn_test.go
@@ -623,7 +623,8 @@ func TestWebAuthnAssertionPOST(t *testing.T) {
"",
fasthttp.StatusBadRequest,
func(t *testing.T, mock *mocks.MockAutheliaCtx) {
- AssertLogEntryMessageAndError(t, mock.Hook.LastEntry(), "Error occurred validating a WebAuthn authentication challenge for user 'john': error parsing the request body", "Parse error for Assertion (invalid_request): json: cannot unmarshal bool into Go struct field CredentialAssertionResponse.id of type string")
+ AssertLogEntryMessageAndError(t, mock.Hook.LastEntry(),
+ "Error occurred validating a WebAuthn authentication challenge for user 'john': error parsing the request body", "^Parse error for Assertion \\(invalid_request\\): json: cannot unmarshal bool into Go struct field CredentialAssertionResponse(\\.PublicKeyCredential\\.Credential)?\\.id of type string$")
},
},
{