first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
const baseUrl = 'https://api.stripe.com/v1';
|
||||
|
||||
const meterEventResponse = {
|
||||
id: 'evt_test_123',
|
||||
object: 'billing.meter_event',
|
||||
event_name: 'api_request',
|
||||
created: 1705320600,
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: 100,
|
||||
},
|
||||
livemode: false,
|
||||
};
|
||||
|
||||
describe('Stripe - Meter Event Workflows', () => {
|
||||
const credentials = {
|
||||
stripeApi: {
|
||||
secretKey: 'sk_test_fake_key',
|
||||
},
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
// Basic meter event creation
|
||||
nock(baseUrl)
|
||||
.persist()
|
||||
.post('/billing/meter_events', {
|
||||
event_name: 'api_request',
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: 100,
|
||||
},
|
||||
})
|
||||
.reply(200, meterEventResponse);
|
||||
|
||||
// Meter event with identifier
|
||||
nock(baseUrl)
|
||||
.persist()
|
||||
.post('/billing/meter_events', {
|
||||
event_name: 'api_request',
|
||||
identifier: 'unique_event_id_123',
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: 100,
|
||||
},
|
||||
})
|
||||
.reply(200, {
|
||||
...meterEventResponse,
|
||||
identifier: 'unique_event_id_123',
|
||||
});
|
||||
|
||||
// Meter event with custom payload properties
|
||||
nock(baseUrl)
|
||||
.persist()
|
||||
.post('/billing/meter_events', {
|
||||
event_name: 'api_request',
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: 100,
|
||||
endpoint: '/api/v1/users',
|
||||
method: 'GET',
|
||||
},
|
||||
})
|
||||
.reply(200, {
|
||||
...meterEventResponse,
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: 100,
|
||||
endpoint: '/api/v1/users',
|
||||
method: 'GET',
|
||||
},
|
||||
});
|
||||
|
||||
// Negative value support
|
||||
nock(baseUrl)
|
||||
.persist()
|
||||
.post('/billing/meter_events', {
|
||||
event_name: 'api_request',
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: -50,
|
||||
},
|
||||
})
|
||||
.reply(200, {
|
||||
...meterEventResponse,
|
||||
payload: {
|
||||
stripe_customer_id: 'cus_test123',
|
||||
value: -50,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// NodeTestHarness will discover and run all workflow JSON files in this directory
|
||||
new NodeTestHarness().setupTests({ credentials });
|
||||
});
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - Basic Create",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": 100
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": 100
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - With Custom Payload",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": 100,
|
||||
"additionalFields": {
|
||||
"customPayload": {
|
||||
"properties": [
|
||||
{
|
||||
"key": "endpoint",
|
||||
"value": "/api/v1/users"
|
||||
},
|
||||
{
|
||||
"key": "method",
|
||||
"value": "GET"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": 100,
|
||||
"endpoint": "/api/v1/users",
|
||||
"method": "GET"
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - Guard Customer ID",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": 100,
|
||||
"additionalFields": {
|
||||
"customPayload": {
|
||||
"properties": [
|
||||
{
|
||||
"key": "stripe_customer_id",
|
||||
"value": "cus_malicious_override"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": 100
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - Guard Value",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": 100,
|
||||
"additionalFields": {
|
||||
"customPayload": {
|
||||
"properties": [
|
||||
{
|
||||
"key": "value",
|
||||
"value": "999"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": 100
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - With Identifier",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": 100,
|
||||
"additionalFields": {
|
||||
"identifier": "unique_event_id_123"
|
||||
}
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"identifier": "unique_event_id_123",
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": 100
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "Stripe Meter Event - Negative Value",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "manual-trigger",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "meterEvent",
|
||||
"operation": "create",
|
||||
"eventName": "api_request",
|
||||
"customerId": "cus_test123",
|
||||
"value": -50
|
||||
},
|
||||
"id": "stripe-meter-event",
|
||||
"name": "Stripe",
|
||||
"type": "n8n-nodes-base.stripe",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"credentials": {
|
||||
"stripeApi": {
|
||||
"id": "1",
|
||||
"name": "Stripe API"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Stripe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Stripe": [
|
||||
{
|
||||
"json": {
|
||||
"id": "evt_test_123",
|
||||
"object": "billing.meter_event",
|
||||
"event_name": "api_request",
|
||||
"created": 1705320600,
|
||||
"payload": {
|
||||
"stripe_customer_id": "cus_test123",
|
||||
"value": -50
|
||||
},
|
||||
"livemode": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user