Skip to content

Commit

Permalink
Merge pull request #95 from fingerprintjs/bugfix/INTER-913-webhook
Browse files Browse the repository at this point in the history
fix: change `ModelMap` to contain any possible property, not just strings
  • Loading branch information
TheUnderScorer authored Sep 27, 2024
2 parents ee7e07b + f4a0749 commit 1a09cd2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cuddly-wasps-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fingerprint-pro-server-api-go-sdk": major
---

Change `ModelMap` to contain any possible property, not just strings
2 changes: 1 addition & 1 deletion sdk/model_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package sdk

type Model struct{}

type ModelMap map[string]string
type ModelMap map[string]any
10 changes: 10 additions & 0 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import (
"os"
)

func readFromFileAndUnmarshalWithError(path string, i interface{}) error {
data, err := os.ReadFile(path)

if err != nil {
return err
}

return json.Unmarshal(data, &i)
}

func readFromFileAndUnmarshal(path string, i interface{}) {
data, err := os.ReadFile(path)

Expand Down
9 changes: 9 additions & 0 deletions test/webhook_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test

import (
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk"
"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v6/sdk/webhook"
"github.com/stretchr/testify/assert"
"testing"
Expand All @@ -9,6 +10,14 @@ import (
const secret = "secret"
const data = "data"

func TestWebhookModel(t *testing.T) {
t.Run("Check if webhook response can be unmarshalled", func(t *testing.T) {
var mockResponse sdk.WebhookVisit
err := readFromFileAndUnmarshalWithError("../test/mocks/webhook.json", &mockResponse)
assert.NoError(t, err)
})
}

func TestIsValidWebhookSignature(t *testing.T) {
const validHeader = "v1=1b2c16b75bd2a870c114153ccda5bcfca63314bc722fa160d690de133ccbb9db"

Expand Down

0 comments on commit 1a09cd2

Please sign in to comment.