Skip to content

Commit f9f8687

Browse files
committed
small bug on paths check
1 parent 86942a7 commit f9f8687

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

api/middleware/middleware.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ func VerifyWebhookPayload(pskey string, ckoskey string) echo.MiddlewareFunc {
110110
var validateFunc func([]byte, string, string) bool
111111

112112
switch c.Path() {
113-
case "webhooks/checkout":
113+
case "/webhooks/checkout":
114114
signatureHeaderName = "Cko-Signature"
115115
secretKey = ckoskey
116116
validateFunc = validateSignatureCheckout
117-
case "webhooks/persona":
117+
case "/webhooks/persona":
118118
signatureHeaderName = "Persona-Signature"
119119
secretKey = pskey
120120
validateFunc = validateSignaturePersona

api/middleware/middleware_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,31 @@ func TestVerifyWebhookPayload(t *testing.T) {
2828
}{
2929
{
3030
name: "Test unauthorized access due to invalid signature for Checkout",
31-
path: "webhooks/checkout",
31+
path: "/webhooks/checkout",
3232
signatureKey: "invalid_signature",
3333
signatureName: "Cko-Signature",
3434
secretKey: checkoutSecretKey,
3535
expectCode: http.StatusUnauthorized,
3636
},
3737
{
3838
name: "Test successful access for Checkout",
39-
path: "webhooks/checkout",
39+
path: "/webhooks/checkout",
4040
signatureKey: computeHmacSha256("hello", checkoutSecretKey),
4141
signatureName: "Cko-Signature",
4242
secretKey: checkoutSecretKey,
4343
expectCode: http.StatusOK,
4444
},
4545
{
4646
name: "Test unauthorized access due to invalid signature for Persona",
47-
path: "webhooks/persona",
47+
path: "/webhooks/persona",
4848
signatureKey: "t=1629478952,v1=invalid_signature",
4949
signatureName: "Persona-Signature",
5050
secretKey: personaSecretKey,
5151
expectCode: http.StatusUnauthorized,
5252
},
5353
{
5454
name: "Test successful access for Persona",
55-
path: "webhooks/persona",
55+
path: "/webhooks/persona",
5656
signatureKey: fmt.Sprintf("t=1629478952,v1=%s", computeHmacSha256("1629478952.hello", personaSecretKey)),
5757
signatureName: "Persona-Signature",
5858
secretKey: personaSecretKey,

0 commit comments

Comments
 (0)