Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,29 @@ demo-cli:

.PHONY: demo-ci
demo-ci:
@./scripts/demo-ci.sh
@./scripts/demo-ci.sh

ROOT_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
ACCOUNT_DIR := $(ROOT_PATH)account/bin
ACCOUNT_BINARY := $(ACCOUNT_DIR)/account
PAYMENT_API_DIR := $(ROOT_PATH)payment-api/bin
PAYMENT_API_BINARY := $(PAYMENT_API_DIR)/payment-api

.PHONY: account-service
account-service:
@echo "Building account service..."
mkdir -p $(ACCOUNT_DIR)
go build -o $(ACCOUNT_BINARY) account/cmd/main.go
echo "Starting account service..."
$(ACCOUNT_BINARY)

.PHONY: payment-api-service
payment-api-service:
@echo "Building payment API service..."
mkdir -p $(PAYMENT_API_DIR)
go build -o $(PAYMENT_API_BINARY) payment-api/cmd/main.go
echo "Starting payment API service..."
ACCOUNT_SERVICE_ADDR=localhost:8082 \
NOTIFICATION_SERVICE_ADDR=localhost:8083 \
FRAUD_SERVICE_URL=http://localhost:8081 \
$(PAYMENT_API_BINARY)
18 changes: 10 additions & 8 deletions e2engine/account-rejection.docker.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,31 @@ spec:
headers:
Content-Type:
- application/json
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'

expect:
http:
status: 422
body: '{"error":"payment rejected"}'
status_code: 422
body_json: '{"error":"payment rejected"}'
calls:
- service_id: fraud
count: 1
http:
method: POST
path: /check
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'

- service_id: account
count: 1
grpc:
service: account.v1.AccountService
method: Debit
message:
account_id: acc-002
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-002",
"amount": 12500,
"currency": "EUR"
}

- service_id: notification
count: 0
Expand Down
18 changes: 10 additions & 8 deletions e2engine/account-rejection.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,31 @@ spec:
headers:
Content-Type:
- application/json
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'

expect:
http:
status: 422
body: '{"error":"payment rejected"}'
status_code: 422
body_json: '{"error":"payment rejected"}'
calls:
- service_id: fraud
count: 1
http:
method: POST
path: /check
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'

- service_id: account
count: 1
grpc:
service: account.v1.AccountService
method: Debit
message:
account_id: acc-002
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-002",
"amount": 12500,
"currency": "EUR"
}

- service_id: notification
count: 0
Expand Down
8 changes: 4 additions & 4 deletions e2engine/fraud-rejection.docker.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ spec:
headers:
Content-Type:
- application/json
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'

expect:
http:
status: 422
body: '{"error":"payment rejected"}'
status_code: 422
body_json: '{"error":"payment rejected"}'
calls:
- service_id: fraud
count: 1
http:
method: POST
path: /check
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'

- service_id: account
count: 0
Expand Down
8 changes: 4 additions & 4 deletions e2engine/fraud-rejection.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ spec:
headers:
Content-Type:
- application/json
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'

expect:
http:
status: 422
body: '{"error":"payment rejected"}'
status_code: 422
body_json: '{"error":"payment rejected"}'
calls:
- service_id: fraud
count: 1
http:
method: POST
path: /check
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'

- service_id: account
count: 0
Expand Down
34 changes: 18 additions & 16 deletions e2engine/payment-demo.docker.env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ spec:
http:
method: POST
path: /check
body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":true}'
body_json: '{"approved":true}'

- when:
http:
method: POST
path: /check
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":true}'
body_json: '{"approved":true}'

- when:
http:
method: POST
path: /check
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":false}'
body_json: '{"approved":false}'

- id: account
kind: grpc
Expand Down Expand Up @@ -84,13 +84,15 @@ spec:
fixtures:
- when:
grpc:
service: notification.v1.NotificationService
method: Send
message:
account_id: acc-001
payment_id: payment-1
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-001",
"payment_id": "payment-1",
"amount": 12500,
"currency": "EUR"
}
then:
grpc:
status: OK
message: {}
status: OK
34 changes: 18 additions & 16 deletions e2engine/payment-demo.env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ spec:
http:
method: POST
path: /check
body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":true}'
body_json: '{"approved":true}'

- when:
http:
method: POST
path: /check
body: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-002","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":true}'
body_json: '{"approved":true}'

- when:
http:
method: POST
path: /check
body: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-003","amount":12500,"currency":"EUR"}'
then:
http:
status: 200
status_code: 200
headers:
Content-Type:
- application/json
body: '{"approved":false}'
body_json: '{"approved":false}'

- id: account
kind: grpc
Expand Down Expand Up @@ -84,13 +84,15 @@ spec:
fixtures:
- when:
grpc:
service: notification.v1.NotificationService
method: Send
message:
account_id: acc-001
payment_id: payment-1
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-001",
"payment_id": "payment-1",
"amount": 12500,
"currency": "EUR"
}
then:
grpc:
status: OK
message: {}
status: OK
37 changes: 24 additions & 13 deletions e2engine/successful-payment.docker.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,48 @@ spec:
headers:
Content-Type:
- application/json
body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'

expect:
http:
status: 201
body: '{"paymentId":"payment-1","accountId":"acc-001","amount":12500,"currency":"EUR","status":"completed"}'
status_code: 201
body_json: >-
{
"paymentId":"payment-1",
"accountId":"acc-001",
"amount":12500,
"currency":"EUR",
"status":"completed"
}
calls:
- service_id: fraud
count: 1
http:
method: POST
path: /check
body: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'
body_json: '{"accountId":"acc-001","amount":12500,"currency":"EUR"}'

- service_id: account
count: 1
grpc:
service: account.v1.AccountService
method: Debit
message:
account_id: acc-001
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-001",
"amount": 12500,
"currency": "EUR"
}

- service_id: notification
count: 1
grpc:
service: notification.v1.NotificationService
method: Send
message:
account_id: acc-001
payment_id: payment-1
amount: 12500
currency: EUR
message: >-
{
"account_id": "acc-001",
"payment_id": "payment-1",
"amount": 12500,
"currency": "EUR"
}
Loading
Loading