summaryrefslogtreecommitdiff
path: root/test/tracetesting/payment
diff options
context:
space:
mode:
Diffstat (limited to 'test/tracetesting/payment')
-rw-r--r--test/tracetesting/payment/all.yaml13
-rw-r--r--test/tracetesting/payment/amex-credit-card-not-allowed.yaml37
-rw-r--r--test/tracetesting/payment/expired-credit-card.yaml37
-rw-r--r--test/tracetesting/payment/invalid-credit-card.yaml37
-rw-r--r--test/tracetesting/payment/valid-credit-card.yaml39
5 files changed, 163 insertions, 0 deletions
diff --git a/test/tracetesting/payment/all.yaml b/test/tracetesting/payment/all.yaml
new file mode 100644
index 0000000..c7d08d8
--- /dev/null
+++ b/test/tracetesting/payment/all.yaml
@@ -0,0 +1,13 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: payment-all
+ name: 'Payment'
+ description: Run all Payment tests enabled in sequence
+ steps:
+ - ./valid-credit-card.yaml
+ - ./invalid-credit-card.yaml
+ - ./amex-credit-card-not-allowed.yaml
+ - ./expired-credit-card.yaml
diff --git a/test/tracetesting/payment/amex-credit-card-not-allowed.yaml b/test/tracetesting/payment/amex-credit-card-not-allowed.yaml
new file mode 100644
index 0000000..6ad88e7
--- /dev/null
+++ b/test/tracetesting/payment/amex-credit-card-not-allowed.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-amex-credit-card-not-allowed
+ name: 'Payment: Amex credit card not allowed'
+ description: Charge customer with an Amex credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "3714 496353 98431",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "Sorry, we cannot process amex credit cards. Only VISA or MasterCard is accepted."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/expired-credit-card.yaml b/test/tracetesting/payment/expired-credit-card.yaml
new file mode 100644
index 0000000..c2f9d5d
--- /dev/null
+++ b/test/tracetesting/payment/expired-credit-card.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-expired-credit-card
+ name: 'Payment: expired credit card'
+ description: Charge customer with an expired credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "4432-8015-6152-0454",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2021,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "The credit card (ending 0454) expired on 1/2021."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/invalid-credit-card.yaml b/test/tracetesting/payment/invalid-credit-card.yaml
new file mode 100644
index 0000000..6ab64de
--- /dev/null
+++ b/test/tracetesting/payment/invalid-credit-card.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-invalid-credit-card
+ name: 'Payment: invalid credit card'
+ description: Charge customer with an invalid credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "0000-0000-0000-0000",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "Credit card info is invalid."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/valid-credit-card.yaml b/test/tracetesting/payment/valid-credit-card.yaml
new file mode 100644
index 0000000..3bc7a65
--- /dev/null
+++ b/test/tracetesting/payment/valid-credit-card.yaml
@@ -0,0 +1,39 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-valid-credit-card
+ name: "Payment: valid credit card"
+ description: Charge customer with a valid credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "4432-8015-6152-0454",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method successfully
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ # instead of returning status_code 0, this service can return 1 depending on timing, but it works as intended
+ assertions:
+ # updating assertion to match 0 and 1
+ - attr:rpc.grpc.status_code <= 1
+ - name: It should return a transaction ID
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.transactionId' != ""