From 39d30d330bd51d8db07c0bc8936e56dec34c2034 Mon Sep 17 00:00:00 2001 From: Leonidas Vrachnis Date: Tue, 23 Jul 2024 16:30:45 +0200 Subject: [PATCH] chore: provide go test cases for webhook sources (#3549) --- go/.gitignore | 2 + go/README.md | 23 + go/go.mod | 11 + go/go.sum | 9 + go/webhook/testcases/testcases.go | 99 ++++ go/webhook/testcases/testdata/context.json | 5 + .../testcases/adjust/simple_track_call.json | 66 +++ ...e_track_call_with_no_query_parameters.json | 25 + .../auth0/add_member_to_an_organization.json | 126 ++++ .../testdata/testcases/auth0/empty_batch.json | 21 + .../testcases/auth0/missing_user_id.json | 97 +++ ...er_id_for_all_the_requests_in_a_batch.json | 143 +++++ .../testcases/auth0/successful_signup.json | 506 ++++++++++++++++ .../auth0/update_tenant_settings.json | 557 ++++++++++++++++++ .../testcases/close_crm/group_creation.json | 102 ++++ .../testcases/close_crm/lead_deletion.json | 105 ++++ .../testcases/close_crm/lead_update.json | 147 +++++ .../testcases/moengage/batch_of_events.json | 389 ++++++++++++ .../testcases/moengage/simple_track_call.json | 246 ++++++++ .../testcases/ortto/simple_track_call.json | 108 ++++ ...mple_track_call_with_unknown_field_id.json | 104 ++++ .../revenuecat/initial_purchase_event.json | 121 ++++ .../purchase_event_with_anonymous_user.json | 112 ++++ .../revenuecat/simple_track_call.json | 149 +++++ .../testcases/shopify/carts_create.json | 16 + .../shopify/fullfillments_updated_event.json | 251 ++++++++ .../testcases/shopify/identify_call.json | 174 ++++++ .../testcases/shopify/invalid_topic.json | 24 + .../testcases/shopify/no_query_params.json | 19 + .../shopify/unsupported_checkout_event.json | 50 ++ .../shopify/unsupported_event_type.json | 16 + .../testcases/slack/message_event.json | 145 +++++ .../testdata/testcases/slack/msg_event.json | 149 +++++ .../testdata/testcases/slack/team_joined.json | 89 +++ .../testcases/slack/team_joined_event.json | 85 +++ .../testcases/slack/verification.json | 31 + .../slack/webhook_url_verificatin_event.json | 26 + test/integrations/sources/adjust/data.ts | 3 + test/integrations/sources/auth0/data.ts | 6 + test/integrations/testTypes.ts | 3 + test/integrations/testUtils.ts | 6 +- test/scripts/generateJson.ts | 141 +++++ tsconfig.json | 2 +- 43 files changed, 4506 insertions(+), 3 deletions(-) create mode 100644 go/.gitignore create mode 100644 go/README.md create mode 100644 go/go.mod create mode 100644 go/go.sum create mode 100644 go/webhook/testcases/testcases.go create mode 100644 go/webhook/testcases/testdata/context.json create mode 100644 go/webhook/testcases/testdata/testcases/adjust/simple_track_call.json create mode 100644 go/webhook/testcases/testdata/testcases/adjust/simple_track_call_with_no_query_parameters.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/add_member_to_an_organization.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/empty_batch.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/missing_user_id.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/missing_user_id_for_all_the_requests_in_a_batch.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/successful_signup.json create mode 100644 go/webhook/testcases/testdata/testcases/auth0/update_tenant_settings.json create mode 100644 go/webhook/testcases/testdata/testcases/close_crm/group_creation.json create mode 100644 go/webhook/testcases/testdata/testcases/close_crm/lead_deletion.json create mode 100644 go/webhook/testcases/testdata/testcases/close_crm/lead_update.json create mode 100644 go/webhook/testcases/testdata/testcases/moengage/batch_of_events.json create mode 100644 go/webhook/testcases/testdata/testcases/moengage/simple_track_call.json create mode 100644 go/webhook/testcases/testdata/testcases/ortto/simple_track_call.json create mode 100644 go/webhook/testcases/testdata/testcases/ortto/simple_track_call_with_unknown_field_id.json create mode 100644 go/webhook/testcases/testdata/testcases/revenuecat/initial_purchase_event.json create mode 100644 go/webhook/testcases/testdata/testcases/revenuecat/purchase_event_with_anonymous_user.json create mode 100644 go/webhook/testcases/testdata/testcases/revenuecat/simple_track_call.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/carts_create.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/fullfillments_updated_event.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/identify_call.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/invalid_topic.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/no_query_params.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/unsupported_checkout_event.json create mode 100644 go/webhook/testcases/testdata/testcases/shopify/unsupported_event_type.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/message_event.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/msg_event.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/team_joined.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/team_joined_event.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/verification.json create mode 100644 go/webhook/testcases/testdata/testcases/slack/webhook_url_verificatin_event.json create mode 100644 test/scripts/generateJson.ts diff --git a/go/.gitignore b/go/.gitignore new file mode 100644 index 0000000000..d1147c6492 --- /dev/null +++ b/go/.gitignore @@ -0,0 +1,2 @@ +go.work +go.work.sum \ No newline at end of file diff --git a/go/README.md b/go/README.md new file mode 100644 index 0000000000..5286119183 --- /dev/null +++ b/go/README.md @@ -0,0 +1,23 @@ +# GO libraries + +## webhook/testdata + +To generate the test files use: + +```bash +go generate ./... +``` + +Work against local rudder-server: + +```bash +go work init +go work use . +go work use ../../rudder-server +``` + +Then run the webhook tests: + +```bash +go test github.com/rudderlabs/rudder-server/gateway/webhook -count 1 -timeout 2m +``` diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 0000000000..26ebf86140 --- /dev/null +++ b/go/go.mod @@ -0,0 +1,11 @@ +module github.com/rudderlabs/rudder-transformer/go + +go 1.22.4 + +require github.com/stretchr/testify v1.9.0 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go/go.sum b/go/go.sum new file mode 100644 index 0000000000..e20fa14b0b --- /dev/null +++ b/go/go.sum @@ -0,0 +1,9 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/webhook/testcases/testcases.go b/go/webhook/testcases/testcases.go new file mode 100644 index 0000000000..92a808dcbd --- /dev/null +++ b/go/webhook/testcases/testcases.go @@ -0,0 +1,99 @@ +package testcases + +import ( + "embed" + "encoding/json" + "io/fs" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +type Setup struct { + Context Context + Cases []Case +} + +type Context struct { + Now time.Time + RequestIP string `json:"request_ip"` +} + +type Case struct { + Name string + Description string + Skip string + Input Input + Output Output +} + +type Input struct { + Request Request +} +type Request struct { + Method string + RawQuery string `json:"query"` + Headers map[string]string + Body json.RawMessage +} + +type Output struct { + Response Response + Queue []json.RawMessage + ErrQueue []json.RawMessage `json:"err_queue"` +} + +type Response struct { + Body json.RawMessage + StatusCode int `json:"status"` +} + +//go:generate npx ts-node ../../../test/scripts/generateJson.ts sources ./testdata/testcases +//go:generate npx prettier --write ./testdata/**/*.json + +//go:embed testdata/context.json +var contextData []byte + +//go:embed testdata/testcases/**/*.json +var testdata embed.FS + +func Load(t *testing.T) Setup { + t.Helper() + + var tc Context + err := json.Unmarshal(contextData, &tc) + require.NoError(t, err) + + var tcs []Case + err = fs.WalkDir(testdata, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if d.IsDir() { + return nil + } + + f, err := testdata.Open(path) + if err != nil { + return err + } + defer f.Close() + + var tc Case + err = json.NewDecoder(f).Decode(&tc) + if err != nil { + return err + } + tcs = append(tcs, tc) + + return nil + }) + require.NoError(t, err) + + return Setup{ + Context: tc, + Cases: tcs, + } +} diff --git a/go/webhook/testcases/testdata/context.json b/go/webhook/testcases/testdata/context.json new file mode 100644 index 0000000000..1b1f135638 --- /dev/null +++ b/go/webhook/testcases/testdata/context.json @@ -0,0 +1,5 @@ +{ + "request_ip_comment": "192.0.2.x/24 - This block is assigned as \"TEST-NET\" for use in documentation and example code.", + "request_ip": "192.0.2.30", + "now": "2024-03-03T04:48:29.000Z" +} diff --git a/go/webhook/testcases/testdata/testcases/adjust/simple_track_call.json b/go/webhook/testcases/testdata/testcases/adjust/simple_track_call.json new file mode 100644 index 0000000000..ce508cacff --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/adjust/simple_track_call.json @@ -0,0 +1,66 @@ +{ + "name": "adjust", + "description": "Simple track call", + "input": { + "request": { + "body": { + "id": "adjust", + "query_parameters": { + "gps_adid": ["38400000-8cf0-11bd-b23e-10b96e40000d"], + "adid": ["18546f6171f67e29d1cb983322ad1329"], + "tracker_token": ["abc"], + "custom": ["custom"], + "tracker_name": ["dummy"], + "created_at": ["1404214665"], + "event_name": ["Click"] + }, + "updated_at": "2023-02-10T12:16:07.251Z", + "created_at": "2023-02-10T12:05:04.402Z" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "Adjust" + }, + "device": { + "id ": "18546f6171f67e29d1cb983322ad1329" + } + }, + "integrations": { + "Adjust": false + }, + "type": "track", + "event": "Click", + "originalTimestamp": "2014-07-01T11:37:45.000Z", + "timestamp": "2014-07-01T11:37:45.000Z", + "properties": { + "gps_adid": "38400000-8cf0-11bd-b23e-10b96e40000d", + "tracker_token": "abc", + "custom": "custom", + "tracker_name": "dummy" + }, + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "FIXME" +} diff --git a/go/webhook/testcases/testdata/testcases/adjust/simple_track_call_with_no_query_parameters.json b/go/webhook/testcases/testdata/testcases/adjust/simple_track_call_with_no_query_parameters.json new file mode 100644 index 0000000000..f8e5a480a0 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/adjust/simple_track_call_with_no_query_parameters.json @@ -0,0 +1,25 @@ +{ + "name": "adjust", + "description": "Simple track call with no query parameters", + "input": { + "request": { + "body": { + "id": "adjust", + "updated_at": "2023-02-10T12:16:07.251Z", + "created_at": "2023-02-10T12:05:04.402Z" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 400, + "body": "Query_parameters is missing" + }, + "queue": [], + "errQueue": [null] + }, + "skip": "FIXME" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/add_member_to_an_organization.json b/go/webhook/testcases/testdata/testcases/auth0/add_member_to_an_organization.json new file mode 100644 index 0000000000..77fbd643c8 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/add_member_to_an_organization.json @@ -0,0 +1,126 @@ +{ + "name": "auth0", + "description": "add member to an organization", + "input": { + "request": { + "body": { + "log_id": "90020221031061004280169676882609459981150114445973782546", + "data": { + "date": "2022-10-31T06:09:59.135Z", + "type": "sapi", + "description": "Add members to an organization", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "ip": "35.167.74.121", + "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "details": { + "request": { + "ip": "35.167.74.121", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "google-oauth2|123456" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f" + } + }, + "body": { + "members": ["auth0|123456"] + }, + "path": "/api/v2/organizations/org_eoe8p2atZ7furBxg/members", + "query": {}, + "method": "post", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": {}, + "statusCode": 204 + } + }, + "user_id": "google-oauth2|123456", + "log_id": "90020221031061004280169676882609459981150114445973782546" + } + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "group", + "sentAt": "2022-10-31T06:09:59.135Z", + "userId": "google-oauth2|123456", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "traits": { + "userId": "google-oauth2|123456" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "request_ip": "35.167.74.121", + "integration": { + "name": "Auth0" + } + }, + "groupId": "org_eoe8p2atZ7furBxg", + "properties": { + "log_id": "90020221031061004280169676882609459981150114445973782546", + "details": { + "request": { + "ip": "35.167.74.121", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "google-oauth2|123456" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f" + } + }, + "body": { + "members": ["auth0|123456"] + }, + "path": "/api/v2/organizations/org_eoe8p2atZ7furBxg/members", + "query": {}, + "method": "post", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": {}, + "statusCode": 204 + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "description": "Add members to an organization", + "source_type": "sapi" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T06:09:59.135Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/empty_batch.json b/go/webhook/testcases/testdata/testcases/auth0/empty_batch.json new file mode 100644 index 0000000000..709ee35525 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/empty_batch.json @@ -0,0 +1,21 @@ +{ + "name": "auth0", + "description": "empty batch", + "input": { + "request": { + "body": [], + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/missing_user_id.json b/go/webhook/testcases/testdata/testcases/auth0/missing_user_id.json new file mode 100644 index 0000000000..8dc148b4c2 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/missing_user_id.json @@ -0,0 +1,97 @@ +{ + "name": "auth0", + "description": "missing userId", + "input": { + "request": { + "body": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "data": { + "date": "2022-10-31T05:57:06.859Z", + "type": "ss", + "description": "", + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "ip": "35.166.202.113", + "user_agent": "unknown", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "user_id": "", + "user_name": "testRudderlabs+21@gmail.com", + "strategy": "auth0", + "strategy_type": "database", + "log_id": "90020221031055712103169676686005480714681762668315934738" + } + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "identify", + "sentAt": "2022-10-31T05:57:06.859Z", + "traits": { + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S" + }, + "userId": "", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "traits": { + "userId": "", + "user_name": "testRudderlabs+21@gmail.com" + }, + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "unknown", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "description": "", + "source_type": "ss" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.859Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/missing_user_id_for_all_the_requests_in_a_batch.json b/go/webhook/testcases/testdata/testcases/auth0/missing_user_id_for_all_the_requests_in_a_batch.json new file mode 100644 index 0000000000..774ab7e7e2 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/missing_user_id_for_all_the_requests_in_a_batch.json @@ -0,0 +1,143 @@ +{ + "name": "auth0", + "description": "missing userId for all the requests in a batch", + "input": { + "request": { + "body": [ + { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "data": { + "date": "2022-10-31T05:57:06.859Z", + "type": "ss", + "description": "", + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "ip": "35.166.202.113", + "user_agent": "unknown", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "user_id": "", + "user_name": "testRudderlabs+21@gmail.com", + "strategy": "auth0", + "strategy_type": "database", + "log_id": "90020221031055712103169676686005480714681762668315934738" + } + }, + { + "log_id": "90020221031055712103169676686007898566320991926665347090", + "data": { + "date": "2022-10-31T05:57:06.874Z", + "type": "sapi", + "description": "Create a User", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "ip": "35.166.202.113", + "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "log_id": "90020221031055712103169676686007898566320991926665347090" + } + } + ], + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "identify", + "userId": "", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "sentAt": "2022-10-31T05:57:06.859Z", + "traits": { + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S" + }, + "context": { + "traits": { + "userId": "", + "user_name": "testRudderlabs+21@gmail.com" + }, + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "unknown", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "description": "", + "source_type": "ss" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.859Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + }, + { + "type": "track", + "event": "Success API Operation", + "sentAt": "2022-10-31T05:57:06.874Z", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686007898566320991926665347090", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "description": "Create a User", + "source_type": "sapi" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.874Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/successful_signup.json b/go/webhook/testcases/testdata/testcases/auth0/successful_signup.json new file mode 100644 index 0000000000..91fba2bd4b --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/successful_signup.json @@ -0,0 +1,506 @@ +{ + "name": "auth0", + "description": "successful signup", + "input": { + "request": { + "body": [ + { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "data": { + "date": "2022-10-31T05:57:06.859Z", + "type": "ss", + "description": "", + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "ip": "35.166.202.113", + "user_agent": "unknown", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "user_id": "auth0|dummyPassword", + "user_name": "testRudderlabs+21@gmail.com", + "strategy": "auth0", + "strategy_type": "database", + "log_id": "90020221031055712103169676686005480714681762668315934738" + } + }, + { + "log_id": "90020221031055712103169676686007898566320991926665347090", + "data": { + "date": "2022-10-31T05:57:06.874Z", + "type": "sapi", + "description": "Create a User", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "ip": "35.166.202.113", + "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "details": { + "request": { + "ip": "35.166.202.113", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "auth0|dummyPassword" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f", + "scopes": [ + "create:actions", + "create:actions_log_sessions", + "create:client_credentials", + "create:client_grants", + "create:clients", + "create:connections", + "create:custom_domains", + "create:email_provider", + "create:email_templates", + "create:guardian_enrollment_tickets", + "create:integrations", + "create:log_streams", + "create:organization_connections", + "create:organization_invitations", + "create:organization_member_roles", + "create:organization_members", + "create:organizations", + "create:requested_scopes", + "create:resource_servers", + "create:roles", + "create:rules", + "create:shields", + "create:signing_keys", + "create:tenant_invitations", + "create:test_email_dispatch", + "create:users", + "delete:actions", + "delete:anomaly_blocks", + "delete:branding", + "delete:client_credentials", + "delete:client_grants", + "delete:clients", + "delete:connections", + "delete:custom_domains", + "delete:device_credentials", + "delete:email_provider", + "delete:email_templates", + "delete:grants", + "delete:guardian_enrollments", + "delete:integrations", + "delete:log_streams", + "delete:organization_connections", + "delete:organization_invitations", + "delete:organization_member_roles", + "delete:organization_members", + "delete:organizations", + "delete:owners", + "delete:requested_scopes", + "delete:resource_servers", + "delete:roles", + "delete:rules", + "delete:rules_configs", + "delete:shields", + "delete:tenant_invitations", + "delete:tenant_members", + "delete:tenants", + "delete:users", + "read:actions", + "read:anomaly_blocks", + "read:attack_protection", + "read:branding", + "read:checks", + "read:client_credentials", + "read:client_grants", + "read:client_keys", + "read:clients", + "read:connections", + "read:custom_domains", + "read:device_credentials", + "read:email_provider", + "read:email_templates", + "read:email_triggers", + "read:entity_counts", + "read:grants", + "read:guardian_factors", + "read:insights", + "read:integrations", + "read:log_streams", + "read:logs", + "read:mfa_policies", + "read:organization_connections", + "read:organization_invitations", + "read:organization_member_roles", + "read:organization_members", + "read:organizations", + "read:prompts", + "read:requested_scopes", + "read:resource_servers", + "read:roles", + "read:rules", + "read:rules_configs", + "read:shields", + "read:signing_keys", + "read:stats", + "read:tenant_invitations", + "read:tenant_members", + "read:tenant_settings", + "read:triggers", + "read:users", + "run:checks", + "update:actions", + "update:attack_protection", + "update:branding", + "update:client_credentials", + "update:client_grants", + "update:client_keys", + "update:clients", + "update:connections", + "update:custom_domains", + "update:email_provider", + "update:email_templates", + "update:email_triggers", + "update:guardian_factors", + "update:integrations", + "update:log_streams", + "update:mfa_policies", + "update:organization_connections", + "update:organizations", + "update:prompts", + "update:requested_scopes", + "update:resource_servers", + "update:roles", + "update:rules", + "update:rules_configs", + "update:shields", + "update:signing_keys", + "update:tenant_members", + "update:tenant_settings", + "update:triggers", + "update:users" + ] + } + }, + "body": { + "email": "testRudderlabs+21@gmail.com", + "password": "dummyPassword", + "connection": "Username-Password-Authentication" + }, + "path": "/api/v2/users", + "query": {}, + "method": "post", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": { + "name": "testRudderlabs+21@gmail.com", + "email": "testRudderlabs+21@gmail.com", + "picture": "https://s.gravatar.com/avatar/0902f9d02b92aed9f0ac59aaf9475b60?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fbh.png", + "user_id": "auth0|dummyPassword", + "nickname": "testRudderlabs+21", + "created_at": "2022-10-31T05:57:06.864Z", + "identities": [ + { + "user_id": "auth0|dummyPassword", + "isSocial": false, + "provider": "auth0", + "connection": "Username-Password-Authentication" + } + ], + "updated_at": "2022-10-31T05:57:06.864Z", + "email_verified": false + }, + "statusCode": 201 + } + }, + "user_id": "auth0|dummyPassword", + "log_id": "90020221031055712103169676686007898566320991926665347090" + } + } + ], + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "identify", + "sentAt": "2022-10-31T05:57:06.859Z", + "traits": { + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S" + }, + "userId": "auth0|dummyPassword", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "traits": { + "userId": "auth0|dummyPassword", + "user_name": "testRudderlabs+21@gmail.com" + }, + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "unknown", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "description": "", + "source_type": "ss" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.859Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + }, + { + "type": "track", + "event": "Success API Operation", + "sentAt": "2022-10-31T05:57:06.874Z", + "userId": "auth0|dummyPassword", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "traits": { + "userId": "auth0|dummyPassword" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686007898566320991926665347090", + "details": { + "request": { + "ip": "35.166.202.113", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "auth0|dummyPassword" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f", + "scopes": [ + "create:actions", + "create:actions_log_sessions", + "create:client_credentials", + "create:client_grants", + "create:clients", + "create:connections", + "create:custom_domains", + "create:email_provider", + "create:email_templates", + "create:guardian_enrollment_tickets", + "create:integrations", + "create:log_streams", + "create:organization_connections", + "create:organization_invitations", + "create:organization_member_roles", + "create:organization_members", + "create:organizations", + "create:requested_scopes", + "create:resource_servers", + "create:roles", + "create:rules", + "create:shields", + "create:signing_keys", + "create:tenant_invitations", + "create:test_email_dispatch", + "create:users", + "delete:actions", + "delete:anomaly_blocks", + "delete:branding", + "delete:client_credentials", + "delete:client_grants", + "delete:clients", + "delete:connections", + "delete:custom_domains", + "delete:device_credentials", + "delete:email_provider", + "delete:email_templates", + "delete:grants", + "delete:guardian_enrollments", + "delete:integrations", + "delete:log_streams", + "delete:organization_connections", + "delete:organization_invitations", + "delete:organization_member_roles", + "delete:organization_members", + "delete:organizations", + "delete:owners", + "delete:requested_scopes", + "delete:resource_servers", + "delete:roles", + "delete:rules", + "delete:rules_configs", + "delete:shields", + "delete:tenant_invitations", + "delete:tenant_members", + "delete:tenants", + "delete:users", + "read:actions", + "read:anomaly_blocks", + "read:attack_protection", + "read:branding", + "read:checks", + "read:client_credentials", + "read:client_grants", + "read:client_keys", + "read:clients", + "read:connections", + "read:custom_domains", + "read:device_credentials", + "read:email_provider", + "read:email_templates", + "read:email_triggers", + "read:entity_counts", + "read:grants", + "read:guardian_factors", + "read:insights", + "read:integrations", + "read:log_streams", + "read:logs", + "read:mfa_policies", + "read:organization_connections", + "read:organization_invitations", + "read:organization_member_roles", + "read:organization_members", + "read:organizations", + "read:prompts", + "read:requested_scopes", + "read:resource_servers", + "read:roles", + "read:rules", + "read:rules_configs", + "read:shields", + "read:signing_keys", + "read:stats", + "read:tenant_invitations", + "read:tenant_members", + "read:tenant_settings", + "read:triggers", + "read:users", + "run:checks", + "update:actions", + "update:attack_protection", + "update:branding", + "update:client_credentials", + "update:client_grants", + "update:client_keys", + "update:clients", + "update:connections", + "update:custom_domains", + "update:email_provider", + "update:email_templates", + "update:email_triggers", + "update:guardian_factors", + "update:integrations", + "update:log_streams", + "update:mfa_policies", + "update:organization_connections", + "update:organizations", + "update:prompts", + "update:requested_scopes", + "update:resource_servers", + "update:roles", + "update:rules", + "update:rules_configs", + "update:shields", + "update:signing_keys", + "update:tenant_members", + "update:tenant_settings", + "update:triggers", + "update:users" + ] + } + }, + "body": { + "email": "testRudderlabs+21@gmail.com", + "password": "dummyPassword", + "connection": "Username-Password-Authentication" + }, + "path": "/api/v2/users", + "query": {}, + "method": "post", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": { + "name": "testRudderlabs+21@gmail.com", + "email": "testRudderlabs+21@gmail.com", + "picture": "https://s.gravatar.com/avatar/0902f9d02b92aed9f0ac59aaf9475b60?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fbh.png", + "user_id": "auth0|dummyPassword", + "nickname": "testRudderlabs+21", + "created_at": "2022-10-31T05:57:06.864Z", + "identities": [ + { + "user_id": "auth0|dummyPassword", + "isSocial": false, + "provider": "auth0", + "connection": "Username-Password-Authentication" + } + ], + "updated_at": "2022-10-31T05:57:06.864Z", + "email_verified": false + }, + "statusCode": 201 + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "description": "Create a User", + "source_type": "sapi" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.874Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/auth0/update_tenant_settings.json b/go/webhook/testcases/testdata/testcases/auth0/update_tenant_settings.json new file mode 100644 index 0000000000..da005184ad --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/auth0/update_tenant_settings.json @@ -0,0 +1,557 @@ +{ + "name": "auth0", + "description": "update tenant settings", + "input": { + "request": { + "body": [ + { + "log_id": "90020221031061527239169676960191065529099349299958906898", + "data": { + "date": "2022-10-31T06:15:25.201Z", + "type": "sapi", + "description": "Update tenant settings", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "ip": "35.160.3.103", + "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "details": { + "request": { + "ip": "35.160.3.103", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "google-oauth2|123456" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f", + "scopes": [ + "create:actions", + "create:actions_log_sessions", + "create:client_credentials", + "create:client_grants", + "create:clients", + "create:connections", + "create:custom_domains", + "create:email_provider", + "create:email_templates", + "create:guardian_enrollment_tickets", + "create:integrations", + "create:log_streams", + "create:organization_connections", + "create:organization_invitations", + "create:organization_member_roles", + "create:organization_members", + "create:organizations", + "create:requested_scopes", + "create:resource_servers", + "create:roles", + "create:rules", + "create:shields", + "create:signing_keys", + "create:tenant_invitations", + "create:test_email_dispatch", + "create:users", + "delete:actions", + "delete:anomaly_blocks", + "delete:branding", + "delete:client_credentials", + "delete:client_grants", + "delete:clients", + "delete:connections", + "delete:custom_domains", + "delete:device_credentials", + "delete:email_provider", + "delete:email_templates", + "delete:grants", + "delete:guardian_enrollments", + "delete:integrations", + "delete:log_streams", + "delete:organization_connections", + "delete:organization_invitations", + "delete:organization_member_roles", + "delete:organization_members", + "delete:organizations", + "delete:owners", + "delete:requested_scopes", + "delete:resource_servers", + "delete:roles", + "delete:rules", + "delete:rules_configs", + "delete:shields", + "delete:tenant_invitations", + "delete:tenant_members", + "delete:tenants", + "delete:users", + "read:actions", + "read:anomaly_blocks", + "read:attack_protection", + "read:branding", + "read:checks", + "read:client_credentials", + "read:client_grants", + "read:client_keys", + "read:clients", + "read:connections", + "read:custom_domains", + "read:device_credentials", + "read:email_provider", + "read:email_templates", + "read:email_triggers", + "read:entity_counts", + "read:grants", + "read:guardian_factors", + "read:insights", + "read:integrations", + "read:log_streams", + "read:logs", + "read:mfa_policies", + "read:organization_connections", + "read:organization_invitations", + "read:organization_member_roles", + "read:organization_members", + "read:organizations", + "read:prompts", + "read:requested_scopes", + "read:resource_servers", + "read:roles", + "read:rules", + "read:rules_configs", + "read:shields", + "read:signing_keys", + "read:stats", + "read:tenant_invitations", + "read:tenant_members", + "read:tenant_settings", + "read:triggers", + "read:users", + "run:checks", + "update:actions", + "update:attack_protection", + "update:branding", + "update:client_credentials", + "update:client_grants", + "update:client_keys", + "update:clients", + "update:connections", + "update:custom_domains", + "update:email_provider", + "update:email_templates", + "update:email_triggers", + "update:guardian_factors", + "update:integrations", + "update:log_streams", + "update:mfa_policies", + "update:organization_connections", + "update:organizations", + "update:prompts", + "update:requested_scopes", + "update:resource_servers", + "update:roles", + "update:rules", + "update:rules_configs", + "update:shields", + "update:signing_keys", + "update:tenant_members", + "update:tenant_settings", + "update:triggers", + "update:users" + ] + } + }, + "body": { + "picture_url": "", + "support_url": "", + "friendly_name": "mecro-action", + "support_email": "support@test.com" + }, + "path": "/api/v2/tenants/settings", + "query": {}, + "method": "patch", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": { + "flags": { + "enable_sso": true, + "universal_login": true, + "disable_impersonation": true, + "allow_changing_enable_sso": false, + "revoke_refresh_token_grant": false, + "disable_clickjack_protection_headers": false, + "new_universal_login_experience_enabled": true, + "enforce_client_authentication_on_passwordless_start": true, + "cannot_change_enforce_client_authentication_on_passwordless_start": true + }, + "picture_url": "", + "support_url": "", + "friendly_name": "mecro-action", + "support_email": "support@test.com", + "enabled_locales": ["en"], + "sandbox_version": "16", + "universal_login": {} + }, + "statusCode": 200 + } + }, + "user_id": "google-oauth2|123456", + "log_id": "90020221031061527239169676960191065529099349299958906898" + } + }, + { + "log_id": "90020221031061530247169676961198100736838335677367058450", + "data": { + "date": "2022-10-31T06:15:25.196Z", + "type": "gd_tenant_update", + "description": "Guardian - Updates tenant settings", + "ip": "35.160.3.103", + "details": { + "request": { + "ip": "35.160.3.103", + "auth": { + "scopes": [ + "read:authenticators", + "remove:authenticators", + "update:authenticators", + "create:authenticators", + "read:enrollments", + "delete:enrollments", + "read:factors", + "update:factors", + "update:tenant_settings", + "update:users", + "create:enrollment_tickets", + "create:users" + ], + "subject": "google-oauth2|123456", + "strategy": "jwt_api2_internal_token" + }, + "body": { + "picture_url": "[REDACTED]", + "friendly_name": "[REDACTED]" + }, + "path": "/api/tenants/settings", + "query": {}, + "method": "PATCH" + }, + "response": { + "body": { + "name": "dev-cu4jy2zgao6yx15x", + "picture_url": "[REDACTED]", + "friendly_name": "[REDACTED]", + "guardian_mfa_page": "[REDACTED]" + }, + "statusCode": 200 + } + }, + "user_id": "google-oauth2|123456", + "log_id": "90020221031061530247169676961198100736838335677367058450" + } + } + ], + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "track", + "event": "Success API Operation", + "sentAt": "2022-10-31T06:15:25.201Z", + "userId": "google-oauth2|123456", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "traits": { + "userId": "google-oauth2|123456" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "request_ip": "35.160.3.103", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031061527239169676960191065529099349299958906898", + "details": { + "request": { + "ip": "35.160.3.103", + "auth": { + "user": { + "name": "rudder test", + "email": "test@rudderstack.com", + "user_id": "google-oauth2|123456" + }, + "strategy": "jwt", + "credentials": { + "jti": "571921bf7833a97efabf08d765a0ec8f", + "scopes": [ + "create:actions", + "create:actions_log_sessions", + "create:client_credentials", + "create:client_grants", + "create:clients", + "create:connections", + "create:custom_domains", + "create:email_provider", + "create:email_templates", + "create:guardian_enrollment_tickets", + "create:integrations", + "create:log_streams", + "create:organization_connections", + "create:organization_invitations", + "create:organization_member_roles", + "create:organization_members", + "create:organizations", + "create:requested_scopes", + "create:resource_servers", + "create:roles", + "create:rules", + "create:shields", + "create:signing_keys", + "create:tenant_invitations", + "create:test_email_dispatch", + "create:users", + "delete:actions", + "delete:anomaly_blocks", + "delete:branding", + "delete:client_credentials", + "delete:client_grants", + "delete:clients", + "delete:connections", + "delete:custom_domains", + "delete:device_credentials", + "delete:email_provider", + "delete:email_templates", + "delete:grants", + "delete:guardian_enrollments", + "delete:integrations", + "delete:log_streams", + "delete:organization_connections", + "delete:organization_invitations", + "delete:organization_member_roles", + "delete:organization_members", + "delete:organizations", + "delete:owners", + "delete:requested_scopes", + "delete:resource_servers", + "delete:roles", + "delete:rules", + "delete:rules_configs", + "delete:shields", + "delete:tenant_invitations", + "delete:tenant_members", + "delete:tenants", + "delete:users", + "read:actions", + "read:anomaly_blocks", + "read:attack_protection", + "read:branding", + "read:checks", + "read:client_credentials", + "read:client_grants", + "read:client_keys", + "read:clients", + "read:connections", + "read:custom_domains", + "read:device_credentials", + "read:email_provider", + "read:email_templates", + "read:email_triggers", + "read:entity_counts", + "read:grants", + "read:guardian_factors", + "read:insights", + "read:integrations", + "read:log_streams", + "read:logs", + "read:mfa_policies", + "read:organization_connections", + "read:organization_invitations", + "read:organization_member_roles", + "read:organization_members", + "read:organizations", + "read:prompts", + "read:requested_scopes", + "read:resource_servers", + "read:roles", + "read:rules", + "read:rules_configs", + "read:shields", + "read:signing_keys", + "read:stats", + "read:tenant_invitations", + "read:tenant_members", + "read:tenant_settings", + "read:triggers", + "read:users", + "run:checks", + "update:actions", + "update:attack_protection", + "update:branding", + "update:client_credentials", + "update:client_grants", + "update:client_keys", + "update:clients", + "update:connections", + "update:custom_domains", + "update:email_provider", + "update:email_templates", + "update:email_triggers", + "update:guardian_factors", + "update:integrations", + "update:log_streams", + "update:mfa_policies", + "update:organization_connections", + "update:organizations", + "update:prompts", + "update:requested_scopes", + "update:resource_servers", + "update:roles", + "update:rules", + "update:rules_configs", + "update:shields", + "update:signing_keys", + "update:tenant_members", + "update:tenant_settings", + "update:triggers", + "update:users" + ] + } + }, + "body": { + "picture_url": "", + "support_url": "", + "friendly_name": "mecro-action", + "support_email": "support@test.com" + }, + "path": "/api/v2/tenants/settings", + "query": {}, + "method": "patch", + "channel": "https://manage.auth0.com/", + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + }, + "response": { + "body": { + "flags": { + "enable_sso": true, + "universal_login": true, + "disable_impersonation": true, + "allow_changing_enable_sso": false, + "revoke_refresh_token_grant": false, + "disable_clickjack_protection_headers": false, + "new_universal_login_experience_enabled": true, + "enforce_client_authentication_on_passwordless_start": true, + "cannot_change_enforce_client_authentication_on_passwordless_start": true + }, + "picture_url": "", + "support_url": "", + "friendly_name": "mecro-action", + "support_email": "support@test.com", + "enabled_locales": ["en"], + "sandbox_version": "16", + "universal_login": {} + }, + "statusCode": 200 + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "description": "Update tenant settings", + "source_type": "sapi" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T06:15:25.201Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + }, + { + "type": "track", + "event": "Guardian tenant update", + "sentAt": "2022-10-31T06:15:25.196Z", + "userId": "google-oauth2|123456", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "traits": { + "userId": "google-oauth2|123456" + }, + "request_ip": "35.160.3.103", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031061530247169676961198100736838335677367058450", + "details": { + "request": { + "ip": "35.160.3.103", + "auth": { + "scopes": [ + "read:authenticators", + "remove:authenticators", + "update:authenticators", + "create:authenticators", + "read:enrollments", + "delete:enrollments", + "read:factors", + "update:factors", + "update:tenant_settings", + "update:users", + "create:enrollment_tickets", + "create:users" + ], + "subject": "google-oauth2|123456", + "strategy": "jwt_api2_internal_token" + }, + "body": { + "picture_url": "[REDACTED]", + "friendly_name": "[REDACTED]" + }, + "path": "/api/tenants/settings", + "query": {}, + "method": "PATCH" + }, + "response": { + "body": { + "name": "dev-cu4jy2zgao6yx15x", + "picture_url": "[REDACTED]", + "friendly_name": "[REDACTED]", + "guardian_mfa_page": "[REDACTED]" + }, + "statusCode": 200 + } + }, + "description": "Guardian - Updates tenant settings", + "source_type": "gd_tenant_update" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T06:15:25.196Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + }, + "skip": "dynamic anonymousId" +} diff --git a/go/webhook/testcases/testdata/testcases/close_crm/group_creation.json b/go/webhook/testcases/testdata/testcases/close_crm/group_creation.json new file mode 100644 index 0000000000..bff58cdf04 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/close_crm/group_creation.json @@ -0,0 +1,102 @@ +{ + "name": "close_crm", + "description": "group creation", + "input": { + "request": { + "body": { + "event": { + "subscription_id": "whsub_123", + "event": { + "id": "ev_123", + "date_created": "2024-06-13T03:53:33.917000", + "date_updated": "2024-06-13T03:53:33.917000", + "organization_id": "orga_123", + "user_id": "user_123", + "request_id": "req_123", + "api_key_id": null, + "oauth_client_id": null, + "oauth_scope": null, + "object_type": "group", + "object_id": "group_123", + "lead_id": null, + "action": "created", + "changed_fields": [], + "meta": { + "request_path": "/api/v1/graphql/", + "request_method": "POST" + }, + "data": { + "id": "group_123", + "name": "Test group", + "members": [ + { + "user_id": "user_123" + } + ] + }, + "previous_data": {} + } + }, + "source": {} + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "context": { + "integration": { + "name": "CloseCRM" + }, + "library": { + "name": "unknown", + "version": "unknown" + } + }, + "event": "group created", + "integrations": { + "CloseCRM": false + }, + "messageId": "ev_123", + "originalTimestamp": "2024-06-ThT03:53:33.917+00:00", + "properties": { + "action": "created", + "data": { + "id": "group_123", + "members": [ + { + "user_id": "user_123" + } + ], + "name": "Test group" + }, + "date_created": "2024-06-13T03:53:33.917000", + "date_updated": "2024-06-13T03:53:33.917000", + "id": "ev_123", + "meta": { + "request_method": "POST", + "request_path": "/api/v1/graphql/" + }, + "object_id": "group_123", + "object_type": "group", + "organization_id": "orga_123", + "request_id": "req_123", + "subscription_id": "whsub_123", + "user_id": "user_123" + }, + "type": "track", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/close_crm/lead_deletion.json b/go/webhook/testcases/testdata/testcases/close_crm/lead_deletion.json new file mode 100644 index 0000000000..4e7076e03d --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/close_crm/lead_deletion.json @@ -0,0 +1,105 @@ +{ + "name": "close_crm", + "description": "lead deletion", + "input": { + "request": { + "body": { + "event": { + "subscription_id": "whsub_123", + "event": { + "id": "ev_123", + "date_created": "2024-06-14T05:16:04.138000", + "date_updated": "2024-06-14T05:16:04.138000", + "organization_id": "orga_123", + "user_id": "user_123", + "request_id": "req_123", + "api_key_id": "api_123", + "oauth_client_id": null, + "oauth_scope": null, + "object_type": "lead", + "object_id": "lead_123", + "lead_id": "lead_123", + "action": "deleted", + "changed_fields": [], + "meta": { + "request_path": "/api/v1/lead/lead_123/", + "request_method": "DELETE" + }, + "data": {}, + "previous_data": { + "created_by_name": "Rudder User", + "addresses": [], + "description": "", + "url": null, + "date_created": "2024-06-14T05:13:42.239000+00:00", + "status_id": "stat_123", + "contact_ids": ["cont_123"], + "id": "lead_12", + "date_updated": "2024-06-14T05:13:42.262000+00:00", + "updated_by_name": "Rudder User", + "status_label": "Potential", + "name": "test name", + "display_name": "test name", + "organization_id": "orga_123", + "updated_by": "user_123", + "created_by": "user_123" + } + } + }, + "source": {} + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "CloseCRM" + } + }, + "integrations": { + "CloseCRM": false + }, + "type": "track", + "event": "lead deleted", + "userId": "lead_123", + "messageId": "ev_123", + "originalTimestamp": "2024-06-FrT05:16:04.138+00:00", + "properties": { + "id": "ev_123", + "date_created": "2024-06-14T05:16:04.138000", + "date_updated": "2024-06-14T05:16:04.138000", + "organization_id": "orga_123", + "user_id": "user_123", + "request_id": "req_123", + "api_key_id": "api_123", + "object_type": "lead", + "object_id": "lead_123", + "lead_id": "lead_123", + "action": "deleted", + "meta": { + "request_path": "/api/v1/lead/lead_123/", + "request_method": "DELETE" + }, + "data": {}, + "subscription_id": "whsub_123" + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/close_crm/lead_update.json b/go/webhook/testcases/testdata/testcases/close_crm/lead_update.json new file mode 100644 index 0000000000..186724a793 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/close_crm/lead_update.json @@ -0,0 +1,147 @@ +{ + "name": "close_crm", + "description": "lead update", + "input": { + "request": { + "body": { + "event": { + "event": { + "date_created": "2019-01-15T12:48:23.395000", + "meta": { + "request_method": "PUT", + "request_path": "/api/v1/opportunity/object_id/" + }, + "id": "ev_123", + "action": "updated", + "date_updated": "2019-01-15T12:48:23.395000", + "changed_fields": [ + "confidence", + "date_updated", + "status_id", + "status_label", + "status_type" + ], + "previous_data": { + "status_type": "active", + "confidence": 70, + "date_updated": "2019-01-15T12:47:39.873000+00:00", + "status_id": "stat_123", + "status_label": "Active" + }, + "organization_id": "orga_123", + "data": { + "contact_name": "Mr. Jones", + "user_name": "Joe Kemp", + "value_period": "one_time", + "updated_by_name": "Joe Kemp", + "date_created": "2019-01-15T12:41:24.496000+00:00", + "user_id": "user_123", + "updated_by": "user_123", + "value_currency": "USD", + "organization_id": "orga_123", + "status_label": "Won", + "contact_id": "cont_123", + "status_type": "won", + "created_by_name": "Joe Kemp", + "id": "id_12", + "lead_name": "KLine", + "date_lost": null, + "note": "", + "date_updated": "2019-01-15T12:48:23.392000+00:00", + "status_id": "stat_12", + "value": 100000, + "created_by": "user_123", + "value_formatted": "$1,000", + "date_won": "2019-01-15", + "lead_id": "lead_123", + "confidence": 100 + }, + "request_id": "req_123", + "object_id": "object_id", + "user_id": "user_123", + "object_type": "opportunity", + "lead_id": "lead_123" + }, + "subscription_id": "whsub_123" + }, + "source": {} + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "CloseCRM" + } + }, + "integrations": { + "CloseCRM": false + }, + "type": "track", + "event": "opportunity updated", + "messageId": "ev_123", + "userId": "lead_123", + "originalTimestamp": "2019-01-TuT12:48:23.395+00:00", + "properties": { + "date_created": "2019-01-15T12:48:23.395000", + "meta": { + "request_method": "PUT", + "request_path": "/api/v1/opportunity/object_id/" + }, + "id": "ev_123", + "action": "updated", + "date_updated": "2019-01-15T12:48:23.395000", + "organization_id": "orga_123", + "data": { + "contact_name": "Mr. Jones", + "user_name": "Joe Kemp", + "value_period": "one_time", + "updated_by_name": "Joe Kemp", + "date_created": "2019-01-15T12:41:24.496000+00:00", + "user_id": "user_123", + "updated_by": "user_123", + "value_currency": "USD", + "organization_id": "orga_123", + "status_label": "Won", + "contact_id": "cont_123", + "status_type": "won", + "created_by_name": "Joe Kemp", + "id": "id_12", + "lead_name": "KLine", + "note": "", + "date_updated": "2019-01-15T12:48:23.392000+00:00", + "status_id": "stat_12", + "value": 100000, + "created_by": "user_123", + "value_formatted": "$1,000", + "date_won": "2019-01-15", + "lead_id": "lead_123", + "confidence": 100 + }, + "request_id": "req_123", + "object_id": "object_id", + "user_id": "user_123", + "object_type": "opportunity", + "lead_id": "lead_123", + "subscription_id": "whsub_123" + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/moengage/batch_of_events.json b/go/webhook/testcases/testdata/testcases/moengage/batch_of_events.json new file mode 100644 index 0000000000..76f72961ca --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/moengage/batch_of_events.json @@ -0,0 +1,389 @@ +{ + "name": "moengage", + "description": "Batch of events", + "input": { + "request": { + "body": { + "batch": [ + { + "type": "page", + "event": "home", + "sentAt": "2020-11-12T21:12:54.117Z", + "userId": "sajal", + "channel": "mobile", + "context": { + "traits": {}, + "library": { + "name": "rudder-sdk-ruby-sync", + "version": "1.0.7" + }, + "page": { + "path": "/Rectified.html", + "referrer": "http://localhost:1112/", + "search": "", + "title": "", + "url": "http://localhost:1112/Rectified.html" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 10; Redmi K20 Pro MIUI/V12.0.3.0.QFKINXM)" + }, + "rudderId": "asdfasdfsadf", + "properties": { + "name": "asdfsadf" + }, + "timestamp": "2020-11-12T21:12:41.320Z", + "anonymousId": "123123123123" + }, + { + "anonymousId": "4eb021e9-a2af-4926-ae82-fe996d12f3c5", + "channel": "web", + "context": { + "timezone": "Asia/Tokyo", + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.6" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.6" + }, + "locale": "en-GB", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/testing/script-test.html", + "referrer": "", + "search": "", + "title": "", + "url": "http://localhost:3243/testing/script-test.html" + }, + "screen": { + "density": 2 + }, + "traits": { + "company": { + "id": "abc123" + }, + "createdAt": "Thu Mar 24 2016 17:46:45 GMT+0000 (UTC)", + "email": "rudderTest@gmail.com", + "name": "Rudder Test", + "plan": "Enterprise" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" + }, + "event": "Order Completed", + "integrations": { + "All": true + }, + "messageId": "a0adfab9-baf7-4e09-a2ce-bbe2844c324a", + "originalTimestamp": "2020-10-16T08:10:12.782Z", + "properties": { + "checkout_id": "what is checkout id here??", + "coupon": "APPARELSALE", + "currency": "GBP", + "order_id": "transactionId", + "category": "some category", + "originalArray": [ + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + } + ], + "products": [ + { + "brand": "", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/bacon-jam.jpg", + "name": "Food/Drink", + "position": 1, + "price": 3, + "product_id": "product-bacon-jam", + "quantity": 2, + "sku": "sku-1", + "typeOfProduct": "Food", + "url": "https://www.example.com/product/bacon-jam", + "value": 6, + "variant": "Extra topped" + }, + { + "brand": "Levis", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/t-shirt.jpg", + "name": "T-Shirt", + "position": 2, + "price": 12.99, + "product_id": "product-t-shirt", + "quantity": 1, + "sku": "sku-2", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/t-shirt", + "value": 12.99, + "variant": "White" + }, + { + "brand": "Levis", + "category": "Merch", + "coupon": "APPARELSALE", + "currency": "GBP", + "image_url": "https://www.example.com/product/offer-t-shirt.jpg", + "name": "T-Shirt-on-offer", + "position": 1, + "price": 12.99, + "product_id": "offer-t-shirt", + "quantity": 1, + "sku": "sku-3", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/offer-t-shirt", + "value": 12.99, + "variant": "Black" + } + ], + "revenue": 31.98, + "shipping": 4, + "value": 31.98 + }, + "receivedAt": "2020-10-16T13:40:12.792+05:30", + "request_ip": "[::1]", + "sentAt": "2020-10-16T08:10:12.783Z", + "timestamp": "2020-10-16T13:40:12.791+05:30", + "type": "track", + "userId": "rudder123" + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "type": "page", + "event": "home", + "sentAt": "2020-11-12T21:12:54.117Z", + "userId": "sajal", + "channel": "mobile", + "context": { + "traits": {}, + "library": { + "name": "rudder-sdk-ruby-sync", + "version": "1.0.7" + }, + "page": { + "path": "/Rectified.html", + "referrer": "http://localhost:1112/", + "search": "", + "title": "", + "url": "http://localhost:1112/Rectified.html" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 10; Redmi K20 Pro MIUI/V12.0.3.0.QFKINXM)" + }, + "rudderId": "asdfasdfsadf", + "properties": { + "name": "asdfsadf" + }, + "timestamp": "2020-11-12T21:12:41.320Z", + "anonymousId": "123123123123", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + }, + { + "anonymousId": "4eb021e9-a2af-4926-ae82-fe996d12f3c5", + "channel": "web", + "context": { + "timezone": "Asia/Tokyo", + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.6" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.6" + }, + "locale": "en-GB", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/testing/script-test.html", + "referrer": "", + "search": "", + "title": "", + "url": "http://localhost:3243/testing/script-test.html" + }, + "screen": { + "density": 2 + }, + "traits": { + "company": { + "id": "abc123" + }, + "createdAt": "Thu Mar 24 2016 17:46:45 GMT+0000 (UTC)", + "email": "rudderTest@gmail.com", + "name": "Rudder Test", + "plan": "Enterprise" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" + }, + "event": "Order Completed", + "integrations": { + "All": true + }, + "messageId": "a0adfab9-baf7-4e09-a2ce-bbe2844c324a", + "originalTimestamp": "2020-10-16T08:10:12.782Z", + "properties": { + "checkout_id": "what is checkout id here??", + "coupon": "APPARELSALE", + "currency": "GBP", + "order_id": "transactionId", + "category": "some category", + "originalArray": [ + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + }, + { + "nested_field": "nested value", + "tags": ["tag_1", "tag_2", "tag_3"] + } + ], + "products": [ + { + "brand": "", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/bacon-jam.jpg", + "name": "Food/Drink", + "position": 1, + "price": 3, + "product_id": "product-bacon-jam", + "quantity": 2, + "sku": "sku-1", + "typeOfProduct": "Food", + "url": "https://www.example.com/product/bacon-jam", + "value": 6, + "variant": "Extra topped" + }, + { + "brand": "Levis", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/t-shirt.jpg", + "name": "T-Shirt", + "position": 2, + "price": 12.99, + "product_id": "product-t-shirt", + "quantity": 1, + "sku": "sku-2", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/t-shirt", + "value": 12.99, + "variant": "White" + }, + { + "brand": "Levis", + "category": "Merch", + "coupon": "APPARELSALE", + "currency": "GBP", + "image_url": "https://www.example.com/product/offer-t-shirt.jpg", + "name": "T-Shirt-on-offer", + "position": 1, + "price": 12.99, + "product_id": "offer-t-shirt", + "quantity": 1, + "sku": "sku-3", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/offer-t-shirt", + "value": 12.99, + "variant": "Black" + } + ], + "revenue": 31.98, + "shipping": 4, + "value": 31.98 + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "sentAt": "2020-10-16T08:10:12.783Z", + "timestamp": "2020-10-16T13:40:12.791+05:30", + "type": "track", + "userId": "rudder123" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/moengage/simple_track_call.json b/go/webhook/testcases/testdata/testcases/moengage/simple_track_call.json new file mode 100644 index 0000000000..f9b11bffb4 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/moengage/simple_track_call.json @@ -0,0 +1,246 @@ +{ + "name": "moengage", + "description": "Simple track call", + "input": { + "request": { + "body": { + "anonymousId": "4eb021e9-a2af-4926-ae82-fe996d12f3c5", + "channel": "web", + "context": { + "timezone": "Wrong/Timezone", + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.6" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.6" + }, + "locale": "en-GB", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/testing/script-test.html", + "referrer": "", + "search": "", + "title": "", + "url": "http://localhost:3243/testing/script-test.html" + }, + "screen": { + "density": 2 + }, + "traits": { + "company": { + "id": "abc123" + }, + "createdAt": "Thu Mar 24 2016 17:46:45 GMT+0000 (UTC)", + "email": "rudderTest@gmail.com", + "name": "Rudder Test", + "plan": "Enterprise" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" + }, + "event": "Order Completed", + "integrations": { + "All": true + }, + "messageId": "a0adfab9-baf7-4e09-a2ce-bbe2844c324a", + "originalTimestamp": "2020-10-16T08:10:12.782Z", + "properties": { + "checkout_id": "what is checkout id here??", + "coupon": "APPARELSALE", + "currency": "GBP", + "order_id": "transactionId", + "products": [ + { + "brand": "", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/bacon-jam.jpg", + "name": "Food/Drink", + "position": 1, + "price": 3, + "product_id": "product-bacon-jam", + "quantity": 2, + "sku": "sku-1", + "typeOfProduct": "Food", + "url": "https://www.example.com/product/bacon-jam", + "value": 6, + "variant": "Extra topped" + }, + { + "brand": "Levis", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/t-shirt.jpg", + "name": "T-Shirt", + "position": 2, + "price": 12.99, + "product_id": "product-t-shirt", + "quantity": 1, + "sku": "sku-2", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/t-shirt", + "value": 12.99, + "variant": "White" + }, + { + "brand": "Levis", + "category": "Merch", + "coupon": "APPARELSALE", + "currency": "GBP", + "image_url": "https://www.example.com/product/offer-t-shirt.jpg", + "name": "T-Shirt-on-offer", + "position": 1, + "price": 12.99, + "product_id": "offer-t-shirt", + "quantity": 1, + "sku": "sku-3", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/offer-t-shirt", + "value": 12.99, + "variant": "Black" + } + ], + "revenue": 31.98, + "shipping": 4, + "value": 31.98 + }, + "sentAt": "2020-10-16T08:10:12.783Z", + "timestamp": "2020-10-16T13:40:12.791+05:30", + "type": "track", + "userId": "rudder123" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "anonymousId": "4eb021e9-a2af-4926-ae82-fe996d12f3c5", + "channel": "web", + "context": { + "timezone": "Wrong/Timezone", + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.6" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.6" + }, + "locale": "en-GB", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/testing/script-test.html", + "referrer": "", + "search": "", + "title": "", + "url": "http://localhost:3243/testing/script-test.html" + }, + "screen": { + "density": 2 + }, + "traits": { + "company": { + "id": "abc123" + }, + "createdAt": "Thu Mar 24 2016 17:46:45 GMT+0000 (UTC)", + "email": "rudderTest@gmail.com", + "name": "Rudder Test", + "plan": "Enterprise" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" + }, + "event": "Order Completed", + "integrations": { + "All": true + }, + "messageId": "a0adfab9-baf7-4e09-a2ce-bbe2844c324a", + "originalTimestamp": "2020-10-16T08:10:12.782Z", + "properties": { + "checkout_id": "what is checkout id here??", + "coupon": "APPARELSALE", + "currency": "GBP", + "order_id": "transactionId", + "products": [ + { + "brand": "", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/bacon-jam.jpg", + "name": "Food/Drink", + "position": 1, + "price": 3, + "product_id": "product-bacon-jam", + "quantity": 2, + "sku": "sku-1", + "typeOfProduct": "Food", + "url": "https://www.example.com/product/bacon-jam", + "value": 6, + "variant": "Extra topped" + }, + { + "brand": "Levis", + "category": "Merch", + "currency": "GBP", + "image_url": "https://www.example.com/product/t-shirt.jpg", + "name": "T-Shirt", + "position": 2, + "price": 12.99, + "product_id": "product-t-shirt", + "quantity": 1, + "sku": "sku-2", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/t-shirt", + "value": 12.99, + "variant": "White" + }, + { + "brand": "Levis", + "category": "Merch", + "coupon": "APPARELSALE", + "currency": "GBP", + "image_url": "https://www.example.com/product/offer-t-shirt.jpg", + "name": "T-Shirt-on-offer", + "position": 1, + "price": 12.99, + "product_id": "offer-t-shirt", + "quantity": 1, + "sku": "sku-3", + "typeOfProduct": "Shirt", + "url": "https://www.example.com/product/offer-t-shirt", + "value": 12.99, + "variant": "Black" + } + ], + "revenue": 31.98, + "shipping": 4, + "value": 31.98 + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "sentAt": "2020-10-16T08:10:12.783Z", + "timestamp": "2020-10-16T13:40:12.791+05:30", + "type": "track", + "userId": "rudder123" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/ortto/simple_track_call.json b/go/webhook/testcases/testdata/testcases/ortto/simple_track_call.json new file mode 100644 index 0000000000..81e7241355 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/ortto/simple_track_call.json @@ -0,0 +1,108 @@ +{ + "name": "ortto", + "description": "Simple track call", + "input": { + "request": { + "body": { + "activity": { + "id": "00651b946bfef7e80478efee", + "field_id": "act::s-all", + "created": "2023-10-03T04:11:23Z", + "attr": { + "str::is": "API", + "str::s-ctx": "Subscribed via API" + } + }, + "contact": { + "external_id": "user_x", + "city": { + "name": "Kolkata", + "id": 0, + "lat": 37751000, + "lng": -97822000 + }, + "country": { + "name": "United States", + "id": 6252001, + "lat": 0, + "lng": 0 + }, + "email": "xyz@email.com", + "first_name": "Ujjwal", + "last_name": "Ujjwal", + "birthday": { + "year": 1980, + "month": 12, + "day": 11, + "timezone": "Australia/Sydney" + }, + "phone_number": { + "c": "91", + "n": "401234567" + } + }, + "id": "00651b946cef87c7af64f4f3", + "time": "2023-10-03T04:11:24.25726779Z", + "webhook_id": "651b8aec8002153e16319fd3" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "userId": "user_x", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "ortto" + }, + "traits": { + "email": "xyz@email.com", + "birthday": "1980-12-11", + "firstName": "Ujjwal", + "lastName": "Ujjwal", + "phone": "91401234567", + "address": { + "city": "Kolkata", + "country": "United States" + } + } + }, + "event": "Resubscribe globally", + "integrations": { + "ortto": false + }, + "type": "track", + "messageId": "00651b946cef87c7af64f4f3", + "originalTimestamp": "2023-10-03T04:11:24.000Z", + "properties": { + "activity.id": "00651b946bfef7e80478efee", + "activity.created": "2023-10-03T04:11:23Z", + "activity.attr.str::is": "API", + "activity.attr.str::s-ctx": "Subscribed via API", + "contact.birthday.timezone": "Australia/Sydney", + "contact.city.id": 0, + "contact.city.lat": 37751000, + "contact.city.lng": -97822000, + "contact.country.id": 6252001, + "contact.country.lat": 0, + "contact.country.lng": 0, + "webhook_id": "651b8aec8002153e16319fd3" + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/ortto/simple_track_call_with_unknown_field_id.json b/go/webhook/testcases/testdata/testcases/ortto/simple_track_call_with_unknown_field_id.json new file mode 100644 index 0000000000..6ee5ab4237 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/ortto/simple_track_call_with_unknown_field_id.json @@ -0,0 +1,104 @@ +{ + "name": "ortto", + "description": "Simple track call with unknown field id", + "input": { + "request": { + "body": { + "activity": { + "id": "00651b946bfef7e80478efee", + "field_id": "act::test_webhook", + "created": "2023-10-03T04:11:23Z", + "attr": { + "str::is": "API", + "str::s-ctx": "Subscribed via API" + } + }, + "contact": { + "external_id": "user_x", + "city": { + "name": "Kolkata", + "id": 0, + "lat": 37751000, + "lng": -97822000 + }, + "contact_id": "006524f0b8d370050056e400", + "country": { + "name": "United States", + "id": 6252001, + "lat": 0, + "lng": 0 + }, + "email": "xyz@email.com", + "first_name": "Ujjwal", + "last_name": "Ujjwal", + "birthday": { + "year": 1980, + "month": 3, + "day": 4, + "timezone": "Australia/Sydney" + }, + "phone_number": { + "c": "91", + "n": "401234567" + } + }, + "id": "00651b946cef87c7af64f4f3", + "time": "2023-10-03T04:11:24.25726779Z", + "webhook_id": "651b8aec8002153e16319fd3" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": { + "activity": { + "id": "00651b946bfef7e80478efee", + "field_id": "act::test_webhook", + "created": "2023-10-03T04:11:23Z", + "attr": { + "str::is": "API", + "str::s-ctx": "Subscribed via API" + } + }, + "contact": { + "external_id": "user_x", + "city": { + "name": "Kolkata", + "id": 0, + "lat": 37751000, + "lng": -97822000 + }, + "contact_id": "006524f0b8d370050056e400", + "country": { + "name": "United States", + "id": 6252001, + "lat": 0, + "lng": 0 + }, + "email": "xyz@email.com", + "first_name": "Ujjwal", + "last_name": "Ujjwal", + "birthday": { + "year": 1980, + "month": 3, + "day": 4, + "timezone": "Australia/Sydney" + }, + "phone_number": { + "c": "91", + "n": "401234567" + } + }, + "id": "00651b946cef87c7af64f4f3", + "time": "2023-10-03T04:11:24.25726779Z", + "webhook_id": "651b8aec8002153e16319fd3" + } + }, + "queue": [], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/revenuecat/initial_purchase_event.json b/go/webhook/testcases/testdata/testcases/revenuecat/initial_purchase_event.json new file mode 100644 index 0000000000..6dbcbd6622 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/revenuecat/initial_purchase_event.json @@ -0,0 +1,121 @@ +{ + "name": "revenuecat", + "description": "Initial purchase event", + "input": { + "request": { + "body": { + "api_version": "1.0", + "event": { + "aliases": ["yourCustomerAliasedID", "yourCustomerAliasedID"], + "app_id": "yourAppID", + "app_user_id": "yourCustomerAppUserID", + "commission_percentage": 0.3, + "country_code": "US", + "currency": "USD", + "entitlement_id": "pro_cat", + "entitlement_ids": ["pro_cat"], + "environment": "PRODUCTION", + "event_timestamp_ms": 1591121855319, + "expiration_at_ms": 1591726653000, + "id": "UniqueIdentifierOfEvent", + "is_family_share": false, + "offer_code": "free_month", + "original_app_user_id": "OriginalAppUserID", + "original_transaction_id": "1530648507000", + "period_type": "NORMAL", + "presented_offering_id": "OfferingID", + "price": 2.49, + "price_in_purchased_currency": 2.49, + "product_id": "onemonth_no_trial", + "purchased_at_ms": 1591121853000, + "store": "APP_STORE", + "subscriber_attributes": { + "$Favorite Cat": { + "updated_at_ms": 1581121853000, + "value": "Garfield" + } + }, + "takehome_percentage": 0.7, + "tax_percentage": 0.3, + "transaction_id": "170000869511114", + "type": "INITIAL_PURCHASE" + } + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "RevenueCat" + }, + "externalId": [ + { + "type": "revenuecatAppUserId", + "id": "yourCustomerAppUserID" + } + ] + }, + "integrations": { + "RevenueCat": false + }, + "type": "track", + "properties": { + "aliases": ["yourCustomerAliasedID", "yourCustomerAliasedID"], + "appId": "yourAppID", + "appUserId": "yourCustomerAppUserID", + "commissionPercentage": 0.3, + "countryCode": "US", + "currency": "USD", + "entitlementId": "pro_cat", + "entitlementIds": ["pro_cat"], + "environment": "PRODUCTION", + "eventTimestampMs": 1591121855319, + "expirationAtMs": 1591726653000, + "id": "UniqueIdentifierOfEvent", + "isFamilyShare": false, + "offerCode": "free_month", + "originalAppUserId": "OriginalAppUserID", + "originalTransactionId": "1530648507000", + "periodType": "NORMAL", + "presentedOfferingId": "OfferingID", + "price": 2.49, + "priceInPurchasedCurrency": 2.49, + "productId": "onemonth_no_trial", + "purchasedAtMs": 1591121853000, + "store": "APP_STORE", + "subscriberAttributes": { + "$Favorite Cat": { + "updated_at_ms": 1581121853000, + "value": "Garfield" + } + }, + "takehomePercentage": 0.7, + "taxPercentage": 0.3, + "transactionId": "170000869511114", + "type": "INITIAL_PURCHASE" + }, + "event": "INITIAL_PURCHASE", + "userId": "yourCustomerAppUserID", + "messageId": "UniqueIdentifierOfEvent", + "originalTimestamp": "2020-06-02T18:17:35.319Z", + "sentAt": "2020-06-02T18:17:35.319Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/revenuecat/purchase_event_with_anonymous_user.json b/go/webhook/testcases/testdata/testcases/revenuecat/purchase_event_with_anonymous_user.json new file mode 100644 index 0000000000..12e2f4ba11 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/revenuecat/purchase_event_with_anonymous_user.json @@ -0,0 +1,112 @@ +{ + "name": "revenuecat", + "description": "Purchase event with anonymous user", + "input": { + "request": { + "body": { + "api_version": "1.0", + "event": { + "aliases": ["yourCustomerAliasedID", "yourCustomerAliasedID"], + "app_id": "yourAppID", + "commission_percentage": 0.3, + "country_code": "US", + "currency": "USD", + "entitlement_id": "pro_cat", + "entitlement_ids": ["pro_cat"], + "environment": "PRODUCTION", + "event_timestamp_ms": 1591121855319, + "expiration_at_ms": 1591726653000, + "id": "UniqueIdentifierOfEvent", + "is_family_share": false, + "offer_code": "free_month", + "original_transaction_id": "1530648507000", + "period_type": "NORMAL", + "presented_offering_id": "OfferingID", + "price": 2.49, + "price_in_purchased_currency": 2.49, + "product_id": "onemonth_no_trial", + "purchased_at_ms": 1591121853000, + "store": "APP_STORE", + "subscriber_attributes": { + "$Favorite Cat": { + "updated_at_ms": 1581121853000, + "value": "Garfield" + } + }, + "takehome_percentage": 0.7, + "tax_percentage": 0.3, + "transaction_id": "170000869511114", + "type": "INITIAL_PURCHASE" + } + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "RevenueCat" + } + }, + "integrations": { + "RevenueCat": false + }, + "type": "track", + "properties": { + "aliases": ["yourCustomerAliasedID", "yourCustomerAliasedID"], + "appId": "yourAppID", + "commissionPercentage": 0.3, + "countryCode": "US", + "currency": "USD", + "entitlementId": "pro_cat", + "entitlementIds": ["pro_cat"], + "environment": "PRODUCTION", + "eventTimestampMs": 1591121855319, + "expirationAtMs": 1591726653000, + "id": "UniqueIdentifierOfEvent", + "isFamilyShare": false, + "offerCode": "free_month", + "originalTransactionId": "1530648507000", + "periodType": "NORMAL", + "presentedOfferingId": "OfferingID", + "price": 2.49, + "priceInPurchasedCurrency": 2.49, + "productId": "onemonth_no_trial", + "purchasedAtMs": 1591121853000, + "store": "APP_STORE", + "subscriberAttributes": { + "$Favorite Cat": { + "updated_at_ms": 1581121853000, + "value": "Garfield" + } + }, + "takehomePercentage": 0.7, + "taxPercentage": 0.3, + "transactionId": "170000869511114", + "type": "INITIAL_PURCHASE" + }, + "event": "INITIAL_PURCHASE", + "userId": "", + "anonymousId": "97fcd7b2-cc24-47d7-b776-057b7b199513", + "messageId": "UniqueIdentifierOfEvent", + "originalTimestamp": "2020-06-02T18:17:35.319Z", + "sentAt": "2020-06-02T18:17:35.319Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/revenuecat/simple_track_call.json b/go/webhook/testcases/testdata/testcases/revenuecat/simple_track_call.json new file mode 100644 index 0000000000..851537141b --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/revenuecat/simple_track_call.json @@ -0,0 +1,149 @@ +{ + "name": "revenuecat", + "description": "Simple track call", + "input": { + "request": { + "body": { + "api_version": "1.0", + "event": { + "aliases": [ + "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "389ad6dd-bb40-4c03-9471-1353da2d55ec" + ], + "app_user_id": "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "commission_percentage": null, + "country_code": "US", + "currency": null, + "entitlement_id": null, + "entitlement_ids": null, + "environment": "SANDBOX", + "event_timestamp_ms": 1698617217232, + "expiration_at_ms": 1698624417232, + "id": "8CF0CD6C-CAF3-41FB-968A-661938235AF0", + "is_family_share": null, + "offer_code": null, + "original_app_user_id": "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "original_transaction_id": null, + "period_type": "NORMAL", + "presented_offering_id": null, + "price": null, + "price_in_purchased_currency": null, + "product_id": "test_product", + "purchased_at_ms": 1698617217232, + "store": "APP_STORE", + "subscriber_attributes": { + "$displayName": { + "updated_at_ms": 1698617217232, + "value": "Mister Mistoffelees" + }, + "$email": { + "updated_at_ms": 1698617217232, + "value": "tuxedo@revenuecat.com" + }, + "$phoneNumber": { + "updated_at_ms": 1698617217232, + "value": "+19795551234" + }, + "my_custom_attribute_1": { + "updated_at_ms": 1698617217232, + "value": "catnip" + } + }, + "takehome_percentage": null, + "tax_percentage": null, + "transaction_id": null, + "type": "TEST" + } + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "RevenueCat" + }, + "externalId": [ + { + "type": "revenuecatAppUserId", + "id": "f8e14f51-0c76-49ba-8d67-c229f1875dd9" + } + ] + }, + "integrations": { + "RevenueCat": false + }, + "type": "track", + "properties": { + "aliases": [ + "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "389ad6dd-bb40-4c03-9471-1353da2d55ec" + ], + "appUserId": "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "commissionPercentage": null, + "countryCode": "US", + "currency": null, + "entitlementId": null, + "entitlementIds": null, + "environment": "SANDBOX", + "eventTimestampMs": 1698617217232, + "expirationAtMs": 1698624417232, + "id": "8CF0CD6C-CAF3-41FB-968A-661938235AF0", + "isFamilyShare": null, + "offerCode": null, + "originalAppUserId": "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "originalTransactionId": null, + "periodType": "NORMAL", + "presentedOfferingId": null, + "price": null, + "priceInPurchasedCurrency": null, + "productId": "test_product", + "purchasedAtMs": 1698617217232, + "store": "APP_STORE", + "subscriberAttributes": { + "$displayName": { + "updated_at_ms": 1698617217232, + "value": "Mister Mistoffelees" + }, + "$email": { + "updated_at_ms": 1698617217232, + "value": "tuxedo@revenuecat.com" + }, + "$phoneNumber": { + "updated_at_ms": 1698617217232, + "value": "+19795551234" + }, + "my_custom_attribute_1": { + "updated_at_ms": 1698617217232, + "value": "catnip" + } + }, + "takehomePercentage": null, + "taxPercentage": null, + "transactionId": null, + "type": "TEST" + }, + "event": "TEST", + "userId": "f8e14f51-0c76-49ba-8d67-c229f1875dd9", + "messageId": "8CF0CD6C-CAF3-41FB-968A-661938235AF0", + "originalTimestamp": "2023-10-29T22:06:57.232Z", + "sentAt": "2023-10-29T22:06:57.232Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/carts_create.json b/go/webhook/testcases/testdata/testcases/shopify/carts_create.json new file mode 100644 index 0000000000..6c37baa443 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/carts_create.json @@ -0,0 +1,16 @@ +{ + "name": "shopify", + "description": "Track Call -> carts_create ", + "input": { + "request": { + "query": "topic=carts_create" + } + }, + "output": { + "response": { + "status": 200, + "contentType": "text/plain", + "body": "OK" + } + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/fullfillments_updated_event.json b/go/webhook/testcases/testdata/testcases/shopify/fullfillments_updated_event.json new file mode 100644 index 0000000000..a7d9717c3d --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/fullfillments_updated_event.json @@ -0,0 +1,251 @@ +{ + "name": "shopify", + "description": "Fulfillment updated event", + "input": { + "request": { + "query": "signature=rudderstack&topic=fulfillments_update", + "body": { + "shipping_address": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "billing_address": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "admin_graphql_api_id": "gid://shopify/Fulfillment/4124667937024", + "created_at": "2022-01-05T18:13:02+05:30", + "destination": null, + "email": "test_person@email.com", + "id": 4124667937024, + "line_items": [ + { + "admin_graphql_api_id": "gid://shopify/LineItem/11896203149568", + "discount_allocations": [], + "duties": [], + "fulfillable_quantity": 0, + "fulfillment_service": "manual", + "fulfillment_status": "fulfilled", + "gift_card": false, + "grams": 0, + "id": 11896203149568, + "name": "p1", + "origin_location": { + "address1": "74 CC/7, Anupama Housing Estate - II", + "address2": "", + "city": "Kolkatta", + "country_code": "IN", + "id": 3373642219776, + "name": "74 CC/7, Anupama Housing Estate - II", + "province_code": "WB", + "zip": "700052" + }, + "price": "5000.00", + "price_set": { + "presentment_money": { + "amount": "5000.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "5000.00", + "currency_code": "INR" + } + }, + "product_exists": true, + "product_id": 7510929801472, + "properties": [], + "quantity": 1, + "requires_shipping": true, + "sku": "15", + "tax_lines": [ + { + "channel_liable": false, + "price": "900.00", + "price_set": { + "presentment_money": { + "amount": "900.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "900.00", + "currency_code": "INR" + } + }, + "rate": 0.18, + "title": "IGST" + } + ], + "taxable": true, + "title": "p1", + "total_discount": "0.00", + "total_discount_set": { + "presentment_money": { + "amount": "0.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "0.00", + "currency_code": "INR" + } + }, + "variant_id": 42211160228096, + "variant_inventory_management": "shopify", + "variant_title": "", + "vendor": "rudderstack-store" + } + ], + "location_id": 66855371008, + "name": "#1002.1", + "order_id": 4617255092480, + "origin_address": null, + "receipt": {}, + "service": "manual", + "shipment_status": null, + "status": "success", + "tracking_company": "Amazon Logistics UK", + "tracking_number": "Sample001test", + "tracking_numbers": ["Sample001test"], + "tracking_url": "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530", + "tracking_urls": [ + "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530" + ], + "updated_at": "2022-01-05T18:16:48+05:30" + } + } + }, + "output": { + "response": { + "status": 200, + "contentType": "text/plain", + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "RudderStack Shopify Cloud", + "version": "1.0.0" + }, + "integration": { + "name": "SHOPIFY" + }, + "topic": "fulfillments_update" + }, + "integrations": { + "SHOPIFY": true + }, + "type": "track", + "userId": "shopify-admin", + "event": "Fulfillments Update", + "properties": { + "admin_graphql_api_id": "gid://shopify/Fulfillment/4124667937024", + "created_at": "2022-01-05T18:13:02+05:30", + "destination": null, + "email": "test_person@email.com", + "id": 4124667937024, + "location_id": 66855371008, + "name": "#1002.1", + "order_id": 4617255092480, + "origin_address": null, + "receipt": {}, + "service": "manual", + "shipment_status": null, + "status": "success", + "tracking_company": "Amazon Logistics UK", + "tracking_number": "Sample001test", + "tracking_numbers": ["Sample001test"], + "tracking_url": "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530", + "tracking_urls": [ + "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530" + ], + "updated_at": "2022-01-05T18:16:48+05:30", + "products": [ + { + "product_id": 7510929801472, + "sku": "15", + "title": "p1", + "price": "5000.00", + "brand": "rudderstack-store", + "quantity": 1, + "admin_graphql_api_id": "gid://shopify/LineItem/11896203149568", + "discount_allocations": [], + "duties": [], + "fulfillable_quantity": 0, + "fulfillment_service": "manual", + "fulfillment_status": "fulfilled", + "gift_card": false, + "grams": 0, + "id": 11896203149568, + "origin_location": { + "address1": "74 CC/7, Anupama Housing Estate - II", + "address2": "", + "city": "Kolkatta", + "country_code": "IN", + "id": 3373642219776, + "name": "74 CC/7, Anupama Housing Estate - II", + "province_code": "WB", + "zip": "700052" + }, + "price_set": { + "presentment_money": { + "amount": "5000.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "5000.00", + "currency_code": "INR" + } + }, + "product_exists": true, + "properties": [], + "requires_shipping": true, + "tax_lines": [ + { + "channel_liable": false, + "price": "900.00", + "price_set": { + "presentment_money": { + "amount": "900.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "900.00", + "currency_code": "INR" + } + }, + "rate": 0.18, + "title": "IGST" + } + ], + "taxable": true, + "total_discount": "0.00", + "total_discount_set": { + "presentment_money": { + "amount": "0.00", + "currency_code": "INR" + }, + "shop_money": { + "amount": "0.00", + "currency_code": "INR" + } + }, + "variant_inventory_management": "shopify", + "variant": "42211160228096 " + } + ] + }, + "traits": { + "shippingAddress": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "billingAddress": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "email": "test_person@email.com" + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "rudderId": "f4ff065d-11d0-4411-b6be-1d0540687f04", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/identify_call.json b/go/webhook/testcases/testdata/testcases/shopify/identify_call.json new file mode 100644 index 0000000000..90c741862a --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/identify_call.json @@ -0,0 +1,174 @@ +{ + "name": "shopify", + "description": "Identify Call for customers create event", + "input": { + "request": { + "query": "topic=customers_create&signature=rudderstack", + "body": { + "id": 5747017285820, + "email": "anuraj@rudderstack.com", + "accepts_marketing": false, + "created_at": "2021-12-29T15:15:19+05:30", + "updated_at": "2021-12-29T15:15:20+05:30", + "first_name": "Anuraj", + "last_name": "Guha", + "orders_count": 0, + "state": "disabled", + "total_spent": "0.00", + "last_order_id": null, + "note": "", + "verified_email": true, + "multipass_identifier": null, + "tax_exempt": false, + "phone": "+919876543210", + "tags": "", + "last_order_name": null, + "currency": "INR", + "addresses": [ + { + "id": 6947581821116, + "customer_id": 5747017285820, + "first_name": "Anuraj", + "last_name": "Guha", + "company": "Rudderstack", + "address1": "Home", + "address2": "Apartment", + "city": "Kolkata", + "province": "West Bengal", + "country": "India", + "zip": "708091", + "phone": "+919876543210", + "name": "Anuraj Guha", + "province_code": "WB", + "country_code": "IN", + "country_name": "India", + "default": true + } + ], + "accepts_marketing_updated_at": "2021-12-29T15:15:20+05:30", + "marketing_opt_in_level": null, + "tax_exemptions": [], + "sms_marketing_consent": { + "state": "not_subscribed", + "opt_in_level": "single_opt_in", + "consent_updated_at": null, + "consent_collected_from": "SHOPIFY" + }, + "admin_graphql_api_id": "gid://shopify/Customer/5747017285820", + "default_address": { + "id": 6947581821116, + "customer_id": 5747017285820, + "first_name": "Anuraj", + "last_name": "Guha", + "company": "Rudderstack", + "address1": "Home", + "address2": "Apartment", + "city": "Kolkata", + "province": "West Bengal", + "country": "India", + "zip": "708091", + "phone": "+919876543210", + "name": "Anuraj Guha", + "province_code": "WB", + "country_code": "IN", + "country_name": "India", + "default": true + } + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "RudderStack Shopify Cloud", + "version": "1.0.0" + }, + "integration": { + "name": "SHOPIFY" + }, + "topic": "customers_create" + }, + "integrations": { + "SHOPIFY": true + }, + "type": "identify", + "userId": "5747017285820", + "traits": { + "email": "anuraj@rudderstack.com", + "firstName": "Anuraj", + "lastName": "Guha", + "phone": "+919876543210", + "addressList": [ + { + "id": 6947581821116, + "customer_id": 5747017285820, + "first_name": "Anuraj", + "last_name": "Guha", + "company": "Rudderstack", + "address1": "Home", + "address2": "Apartment", + "city": "Kolkata", + "province": "West Bengal", + "country": "India", + "zip": "708091", + "phone": "+919876543210", + "name": "Anuraj Guha", + "province_code": "WB", + "country_code": "IN", + "country_name": "India", + "default": true + } + ], + "address": { + "id": 6947581821116, + "customer_id": 5747017285820, + "first_name": "Anuraj", + "last_name": "Guha", + "company": "Rudderstack", + "address1": "Home", + "address2": "Apartment", + "city": "Kolkata", + "province": "West Bengal", + "country": "India", + "zip": "708091", + "phone": "+919876543210", + "name": "Anuraj Guha", + "province_code": "WB", + "country_code": "IN", + "country_name": "India", + "default": true + }, + "acceptsMarketing": false, + "orderCount": 0, + "state": "disabled", + "totalSpent": "0.00", + "note": "", + "verifiedEmail": true, + "taxExempt": false, + "tags": "", + "currency": "INR", + "taxExemptions": [], + "smsMarketingConsent": { + "state": "not_subscribed", + "opt_in_level": "single_opt_in", + "consent_updated_at": null, + "consent_collected_from": "SHOPIFY" + }, + "adminGraphqlApiId": "gid://shopify/Customer/5747017285820", + "acceptsMarketingUpdatedAt": "2021-12-29T15:15:20+05:30" + }, + "timestamp": "2021-12-29T09:45:20.000Z", + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "rudderId": "56ad0483-e7e8-438d-958f-676fcbf3ed49", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/invalid_topic.json b/go/webhook/testcases/testdata/testcases/shopify/invalid_topic.json new file mode 100644 index 0000000000..f4048a0783 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/invalid_topic.json @@ -0,0 +1,24 @@ +{ + "name": "shopify", + "description": "Invalid topic", + "input": { + "request": { + "query": "signature=rudderstack" + } + }, + "output": { + "response": { + "status": 400, + "contentType": "text/plain", + "body": "Invalid topic in query_parameters\n" + }, + "err_queue": [ + { + "query_parameters": { + "writeKey": ["{{.WriteKey}}"], + "signature": ["rudderstack"] + } + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/no_query_params.json b/go/webhook/testcases/testdata/testcases/shopify/no_query_params.json new file mode 100644 index 0000000000..c9eda9924f --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/no_query_params.json @@ -0,0 +1,19 @@ +{ + "name": "shopify", + "description": "No Query Parameters", + "input": {}, + "output": { + "response": { + "status": 400, + "contentType": "text/plain", + "body": "Invalid topic in query_parameters\n" + }, + "err_queue": [ + { + "query_parameters": { + "writeKey": ["{{.WriteKey}}"] + } + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/unsupported_checkout_event.json b/go/webhook/testcases/testdata/testcases/shopify/unsupported_checkout_event.json new file mode 100644 index 0000000000..2a6f6c6642 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/unsupported_checkout_event.json @@ -0,0 +1,50 @@ +{ + "name": "shopify", + "description": "Unsupported checkout event", + "input": { + "request": { + "query": "signature=rudderstack&topic=checkout_delete", + "body": { + "admin_graphql_api_id": "gid://shopify/Fulfillment/4124667937024", + "created_at": "2022-01-05T18:13:02+05:30", + "destination": null, + "id": 4124667937024, + "line_items": [], + "customer": { + "email": "test_person@email.com", + "first_name": "Test", + "last_name": "Person" + }, + "billing_address": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "shipping_address": { + "address1": "11 Rani Sankari Lane Patuapara Bhowanipore" + }, + "location_id": 66855371008, + "name": "#1002.1", + "order_id": 4617255092480, + "origin_address": null, + "receipt": {}, + "service": "manual", + "shipment_status": null, + "status": "success", + "tracking_company": "Amazon Logistics UK", + "tracking_number": "Sample001test", + "tracking_numbers": ["Sample001test"], + "tracking_url": "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530", + "tracking_urls": [ + "https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=201910530" + ], + "updated_at": "2022-01-05T18:16:48+05:30" + } + } + }, + "output": { + "response": { + "status": 200, + "contentType": "text/plain", + "body": "OK" + } + } +} diff --git a/go/webhook/testcases/testdata/testcases/shopify/unsupported_event_type.json b/go/webhook/testcases/testdata/testcases/shopify/unsupported_event_type.json new file mode 100644 index 0000000000..26c08e9c4f --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/shopify/unsupported_event_type.json @@ -0,0 +1,16 @@ +{ + "name": "shopify", + "description": "Unsupported event type", + "input": { + "request": { + "query": "signature=rudderstack&topic=random_event" + } + }, + "output": { + "response": { + "status": 200, + "contentType": "text/plain", + "body": "OK" + } + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/message_event.json b/go/webhook/testcases/testdata/testcases/slack/message_event.json new file mode 100644 index 0000000000..744170beec --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/message_event.json @@ -0,0 +1,145 @@ +{ + "name": "slack", + "description": "Message event", + "input": { + "request": { + "body": { + "event": { + "user": "U04G7H550", + "type": "message", + "ts": "1709441309.308399", + "client_msg_id": "834r664e-ec75-445d-t5c6-b873a07y9c81", + "text": "What is the pricing of product X", + "team": "T0GFJL5J7", + "thread_ts": "1709407304.839329", + "parent_user_id": "U06P6LQTPV", + "blocks": [ + { + "type": "rich_text", + "block_id": "xGKJl", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "What is the pricing of product X" + }, + { + "type": "channel", + "channel_id": "C03CDQTPI65" + }, + { + "type": "text", + "text": " to do this" + } + ] + } + ] + } + ], + "channel": "C03CDQTPI65", + "event_ts": "1709441309.308399", + "channel_type": "channel" + }, + "type": "event_callback", + "event_id": "EvY5JTJ0NG5", + "event_time": 1709441309, + "token": "REm2987dqtpi72Lq", + "team_id": "T0GFJL5J7", + "context_team_id": "T01gqtPIL5J7", + "context_enterprise_id": null, + "api_app_id": "A04QTPIHRR", + "authorizations": [ + { + "enterprise_id": null, + "team_id": "T0GFJL5J7", + "user_id": "W012CDE", + "is_bot": true, + "is_enterprise_install": false + } + ], + "is_ext_shared_channel": false, + "event_context": "4-wd6joiQfdgTRQTpIzdfifQ" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "SLACK" + }, + "externalId": [ + { + "type": "slackUserId", + "id": "U04G7H550" + } + ] + }, + "integrations": { + "SLACK": false + }, + "type": "track", + "event": "Message", + "anonymousId": "7509c04f547b05afb6838aa742f4910263d6", + "originalTimestamp": "2024-03-03T04:48:29.308Z", + "sentAt": "2024-03-03T04:48:29.000Z", + "properties": { + "user": "U04G7H550", + "type": "message", + "ts": "1709441309.308399", + "client_msg_id": "834r664e-ec75-445d-t5c6-b873a07y9c81", + "text": "What is the pricing of product X", + "team": "T0GFJL5J7", + "thread_ts": "1709407304.839329", + "parent_user_id": "U06P6LQTPV", + "blocks": [ + { + "type": "rich_text", + "block_id": "xGKJl", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "What is the pricing of product X" + }, + { + "type": "channel", + "channel_id": "C03CDQTPI65" + }, + { + "type": "text", + "text": " to do this" + } + ] + } + ] + } + ], + "channel": "C03CDQTPI65", + "event_ts": "1709441309.308399", + "channel_type": "channel" + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/msg_event.json b/go/webhook/testcases/testdata/testcases/slack/msg_event.json new file mode 100644 index 0000000000..9ca194858c --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/msg_event.json @@ -0,0 +1,149 @@ +{ + "name": "slack", + "description": "Message event", + "module": "source", + "version": "v0", + "input": { + "request": { + "body": { + "event": { + "user": "U04G7H550", + "type": "message", + "ts": "1709441309.308399", + "client_msg_id": "834r664e-ec75-445d-t5c6-b873a07y9c81", + "text": "What is the pricing of product X", + "team": "T0GFJL5J7", + "thread_ts": "1709407304.839329", + "parent_user_id": "U06P6LQTPV", + "blocks": [ + { + "type": "rich_text", + "block_id": "xGKJl", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "What is the pricing of product X" + }, + { + "type": "channel", + "channel_id": "C03CDQTPI65" + }, + { + "type": "text", + "text": " to do this" + } + ] + } + ] + } + ], + "channel": "C03CDQTPI65", + "event_ts": "1709441309.308399", + "channel_type": "channel" + }, + "type": "event_callback", + "event_id": "EvY5JTJ0NG5", + "event_time": 1709441309, + "token": "REm2987dqtpi72Lq", + "team_id": "T0GFJL5J7", + "context_team_id": "T01gqtPIL5J7", + "context_enterprise_id": null, + "api_app_id": "A04QTPIHRR", + "authorizations": [ + { + "enterprise_id": null, + "team_id": "T0GFJL5J7", + "user_id": "W012CDE", + "is_bot": true, + "is_enterprise_install": false + } + ], + "is_ext_shared_channel": false, + "event_context": "4-wd6joiQfdgTRQTpIzdfifQ" + }, + "method": "POST", + "headers": { + "Content-Type": "application/json" + } + }, + "pathSuffix": "" + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "SLACK" + }, + "externalId": [ + { + "type": "slackUserId", + "id": "U04G7H550" + } + ] + }, + "integrations": { + "SLACK": false + }, + "type": "track", + "event": "Message", + "anonymousId": "7509c04f547b05afb6838aa742f4910263d6", + "originalTimestamp": "2024-03-03T04:48:29.308Z", + "sentAt": "2024-03-03T04:48:29.000Z", + "properties": { + "user": "U04G7H550", + "type": "message", + "ts": "1709441309.308399", + "client_msg_id": "834r664e-ec75-445d-t5c6-b873a07y9c81", + "text": "What is the pricing of product X", + "team": "T0GFJL5J7", + "thread_ts": "1709407304.839329", + "parent_user_id": "U06P6LQTPV", + "blocks": [ + { + "type": "rich_text", + "block_id": "xGKJl", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "What is the pricing of product X" + }, + { + "type": "channel", + "channel_id": "C03CDQTPI65" + }, + { + "type": "text", + "text": " to do this" + } + ] + } + ] + } + ], + "channel": "C03CDQTPI65", + "event_ts": "1709441309.308399", + "channel_type": "channel" + }, + "request_ip": "192.0.2.30", + "receivedAt": "2024-03-03T04:48:29.000Z", + "rudderId": "5540ba39-3df8-4970-8b50-b329182c9bd5", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/team_joined.json b/go/webhook/testcases/testdata/testcases/slack/team_joined.json new file mode 100644 index 0000000000..114872a76a --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/team_joined.json @@ -0,0 +1,89 @@ +{ + "name": "slack", + "description": "Team joined event", + "module": "source", + "version": "v0", + "input": { + "request": { + "body": { + "event": { + "type": "team_join", + "user": { + "id": "W012CDE", + "name": "johnd", + "real_name": "John Doe" + } + }, + "type": "event_callback", + "event_id": "Ev06TJ0NG5", + "event_time": 1709441309, + "token": "REm276ggfh72Lq", + "team_id": "T0GFJL5J7", + "context_team_id": "T0GFJL5J7", + "context_enterprise_id": null, + "api_app_id": "B02SJMHRR", + "authorizations": [ + { + "enterprise_id": null, + "team_id": "T0GFJL5J7", + "user_id": "U04G7H550", + "is_bot": true, + "is_enterprise_install": false + } + ], + "is_ext_shared_channel": false, + "event_context": "eJldCI65436EUEpMSFhgfhg76joiQzAxRTRQTEIxMzUifQ" + }, + "method": "POST", + "headers": { + "Content-Type": "application/json" + } + }, + "pathSuffix": "" + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "SLACK" + }, + "externalId": [ + { + "type": "slackUserId", + "id": "W012CDE" + } + ] + }, + "integrations": { + "SLACK": false + }, + "type": "identify", + "event": "Team Join", + "anonymousId": "2bc5ae2825a712d3d154cbdacb86ac16c278", + "originalTimestamp": "2024-03-03T04:48:29.000Z", + "sentAt": "2024-03-03T04:48:29.000Z", + "properties": { + "type": "team_join", + "user": { + "id": "W012CDE", + "name": "johnd", + "real_name": "John Doe" + } + }, + "request_ip": "192.0.2.30", + "receivedAt": "2024-03-03T04:48:29.000Z", + "rudderId": "669b7c62-3e8b-475c-8f0a-356b2a9518e2", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ] + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/team_joined_event.json b/go/webhook/testcases/testdata/testcases/slack/team_joined_event.json new file mode 100644 index 0000000000..8b0c547f69 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/team_joined_event.json @@ -0,0 +1,85 @@ +{ + "name": "slack", + "description": "Team joined event", + "input": { + "request": { + "body": { + "event": { + "type": "team_join", + "user": { + "id": "W012CDE", + "name": "johnd", + "real_name": "John Doe" + } + }, + "type": "event_callback", + "event_id": "Ev06TJ0NG5", + "event_time": 1709441309, + "token": "REm276ggfh72Lq", + "team_id": "T0GFJL5J7", + "context_team_id": "T0GFJL5J7", + "context_enterprise_id": null, + "api_app_id": "B02SJMHRR", + "authorizations": [ + { + "enterprise_id": null, + "team_id": "T0GFJL5J7", + "user_id": "U04G7H550", + "is_bot": true, + "is_enterprise_install": false + } + ], + "is_ext_shared_channel": false, + "event_context": "eJldCI65436EUEpMSFhgfhg76joiQzAxRTRQTEIxMzUifQ" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": "OK" + }, + "queue": [ + { + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "integration": { + "name": "SLACK" + }, + "externalId": [ + { + "type": "slackUserId", + "id": "W012CDE" + } + ] + }, + "integrations": { + "SLACK": false + }, + "type": "identify", + "event": "Team Join", + "anonymousId": "2bc5ae2825a712d3d154cbdacb86ac16c278", + "originalTimestamp": "2024-03-03T04:48:29.000Z", + "sentAt": "2024-03-03T04:48:29.000Z", + "properties": { + "type": "team_join", + "user": { + "id": "W012CDE", + "name": "johnd", + "real_name": "John Doe" + } + }, + "receivedAt": "2024-03-03T04:48:29.000Z", + "request_ip": "192.0.2.30", + "messageId": "00000000-0000-0000-0000-000000000000" + } + ], + "errQueue": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/verification.json b/go/webhook/testcases/testdata/testcases/slack/verification.json new file mode 100644 index 0000000000..94e072dd8f --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/verification.json @@ -0,0 +1,31 @@ +{ + "name": "slack", + "description": "Webhook url verification event", + "module": "source", + "version": "v0", + "input": { + "request": { + "body": { + "token": "Jhj5dZrVaK7ZwHHjRyZWjbDl", + "challenge": "3eZbrw1aB10FEMAGAZd4FyFQ", + "type": "url_verification" + }, + "method": "POST", + "headers": { + "Content-Type": "application/json" + } + }, + "pathSuffix": "" + }, + "output": { + "response": { + "status": 200, + "contentType": "application/json", + "body": { + "challenge": "3eZbrw1aB10FEMAGAZd4FyFQ" + } + }, + "queue": [], + "proc_err": [] + } +} diff --git a/go/webhook/testcases/testdata/testcases/slack/webhook_url_verificatin_event.json b/go/webhook/testcases/testdata/testcases/slack/webhook_url_verificatin_event.json new file mode 100644 index 0000000000..0be33d2c58 --- /dev/null +++ b/go/webhook/testcases/testdata/testcases/slack/webhook_url_verificatin_event.json @@ -0,0 +1,26 @@ +{ + "name": "slack", + "description": "Webhook url verificatin event", + "input": { + "request": { + "body": { + "token": "Jhj5dZrVaK7ZwHHjRyZWjbDl", + "challenge": "3eZbrw1aB10FEMAGAZd4FyFQ", + "type": "url_verification" + }, + "headers": { + "Content-Type": "application/json" + } + } + }, + "output": { + "response": { + "status": 200, + "body": { + "challenge": "3eZbrw1aB10FEMAGAZd4FyFQ" + } + }, + "queue": [], + "errQueue": [] + } +} diff --git a/test/integrations/sources/adjust/data.ts b/test/integrations/sources/adjust/data.ts index 975543fbec..733a1d6235 100644 --- a/test/integrations/sources/adjust/data.ts +++ b/test/integrations/sources/adjust/data.ts @@ -1,3 +1,4 @@ +import { skip } from 'node:test'; import utils from '../../../../src/v0/util'; const defaultMockFns = () => { @@ -10,6 +11,7 @@ export const data = [ description: 'Simple track call', module: 'source', version: 'v0', + skipGo: 'FIXME', input: { request: { body: [ @@ -85,6 +87,7 @@ export const data = [ description: 'Simple track call with no query parameters', module: 'source', version: 'v0', + skipGo: 'FIXME', input: { request: { body: [ diff --git a/test/integrations/sources/auth0/data.ts b/test/integrations/sources/auth0/data.ts index 44b511cad2..953888920b 100644 --- a/test/integrations/sources/auth0/data.ts +++ b/test/integrations/sources/auth0/data.ts @@ -10,6 +10,7 @@ export const data = [ description: 'successful signup', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [ @@ -532,6 +533,7 @@ export const data = [ description: 'add member to an organization', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [ @@ -671,6 +673,7 @@ export const data = [ description: 'update tenant settings', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [ @@ -1242,6 +1245,7 @@ export const data = [ description: 'missing userId', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [ @@ -1348,6 +1352,7 @@ export const data = [ description: 'missing userId for all the requests in a batch', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [ @@ -1503,6 +1508,7 @@ export const data = [ description: 'empty batch', module: 'source', version: 'v0', + skipGo: 'dynamic anonymousId', input: { request: { body: [], diff --git a/test/integrations/testTypes.ts b/test/integrations/testTypes.ts index 3df732d84f..77635f2198 100644 --- a/test/integrations/testTypes.ts +++ b/test/integrations/testTypes.ts @@ -18,6 +18,8 @@ export interface requestType { export interface responseType { status: number; + statusCode?: number; + error?: any; body?: any; headers?: Record; } @@ -40,6 +42,7 @@ export interface TestCaseData { id?: string; name: string; description: string; + skipGo?: string; scenario?: string; successCriteria?: string; comment?: string; diff --git a/test/integrations/testUtils.ts b/test/integrations/testUtils.ts index 5e0df874f8..4f5181e41e 100644 --- a/test/integrations/testUtils.ts +++ b/test/integrations/testUtils.ts @@ -24,8 +24,10 @@ const generateAlphanumericId = (size = 36) => export const getTestDataFilePaths = (dirPath: string, opts: OptionValues): string[] => { const globPattern = join(dirPath, '**', 'data.ts'); let testFilePaths = globSync(globPattern); - if (opts.destination) { - testFilePaths = testFilePaths.filter((testFile) => testFile.includes(opts.destination)); + if (opts.destination || opts.source) { + testFilePaths = testFilePaths.filter((testFile) => + testFile.includes(opts.destination || opts.source), + ); } if (opts.feature) { testFilePaths = testFilePaths.filter((testFile) => testFile.includes(opts.feature)); diff --git a/test/scripts/generateJson.ts b/test/scripts/generateJson.ts new file mode 100644 index 0000000000..7e4c3a3c0f --- /dev/null +++ b/test/scripts/generateJson.ts @@ -0,0 +1,141 @@ +import { Command, OptionValues } from 'commander'; +import path from 'path'; +import fs from 'fs'; +import { getTestData, getTestDataFilePaths, produceTestData } from '../integrations/testUtils'; +import { head } from 'lodash'; + +interface TestCaseData { + name: string; + description: string; + skip?: string; + input: Input; + output: Output; +} + +interface Input { + request: { + query: string; + body: any; + headers?: Record; + }; +} + +interface Output { + response: { + status: number; + body: any; + }; + queue: any[]; + errQueue: any[]; +} + +const jsonGenerator = new Command(); +jsonGenerator + .name('json-generator') + .description('CLI to some JavaScript string utilities') + .version('0.8.0'); + +jsonGenerator + .command('sources') + .description('generator JSON test cases for source') + .argument('', 'output path') + .option('-s, --source ', 'source', ',') + .action(generateSources); + +jsonGenerator.parse(); + +function generateSources(outputFolder: string, options: OptionValues) { + const rootDir = __dirname; + const resolvedpath = path.resolve(rootDir, '../integrations/sources'); + + const files = getTestDataFilePaths(resolvedpath, options); + + files.forEach((testDataPath) => { + let testData = getTestData(testDataPath); + testData.forEach((testCase) => { + let statusCode: number = + testCase.output.response?.statusCode || testCase.output.response?.status || 200; + + let responseBody: any = 'OK'; + if (statusCode == 200) { + if (testCase.output.response?.body[0]?.outputToSource?.body) { + responseBody = JSON.parse( + Buffer.from(testCase.output.response?.body[0]?.outputToSource?.body, 'base64').toString( + 'utf-8', + ), + ); + } + } else { + responseBody = testCase.output.response?.error; + } + + testCase.input.request.body.forEach((body) => { + delete body['receivedAt']; + delete body['request_ip']; + }); + + let goTest: TestCaseData = { + name: testCase.name, + description: testCase.description, + input: { + request: { + query: JSON.stringify(testCase.input.request.params), + body: + testCase.input.request.body.length === 1 + ? testCase.input.request.body[0] + : testCase.input.request.body, + headers: testCase.input.request.headers || { + 'Content-Type': 'application/json', + }, + }, + }, + output: { + response: { + status: statusCode, + body: responseBody, + }, + // TODO flatten nested array + queue: + statusCode == 200 + ? testCase.output.response?.body + .filter((i) => i.output) + .map((i) => i.output.batch) + .flat() + : [], + errQueue: statusCode != 200 ? [testCase.output.response?.body] : [], + }, + }; + const dirPath = path.join(outputFolder, goTest.name); + const filePath = path.join(dirPath, `${toSnakeCase(goTest.description)}.json`); + + if (testCase.skipGo) { + goTest.skip = testCase.skipGo; + } + + goTest.output.queue.forEach((queueItem) => { + queueItem['receivedAt'] = '2024-03-03T04:48:29.000Z'; + queueItem['request_ip'] = '192.0.2.30'; + if (!queueItem['messageId']) { + queueItem['messageId'] = '00000000-0000-0000-0000-000000000000'; + } + }); + + fs.mkdirSync(dirPath, { recursive: true }); + + fs.writeFileSync(filePath, JSON.stringify(goTest, null, 2)); + }); + }); +} + +function toSnakeCase(str: string): string { + return ( + str + // Replace spaces with underscores + .replace(/\s+/g, '_') + // Insert underscores before uppercase letters, handle acronyms correctly + .replace(/\.?([A-Z]+)/g, (x, y) => '_' + y.toLowerCase()) + // Remove leading underscores and handle consecutive underscores + .replace(/^_+/, '') + .replace(/_{2,}/g, '_') + ); +} diff --git a/tsconfig.json b/tsconfig.json index 926831b612..2c00e6482e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -102,6 +102,6 @@ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */, }, - "exclude": ["./src/**/*.test.js", "./src/**/*.test.ts", "./test"], + "exclude": ["./src/**/*.test.js", "./src/**/*.test.ts", "./test", "./go"], "include": ["./src", "./src/**/*.json"], }