Skip to content
Open
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
40 changes: 40 additions & 0 deletions code/Test_definitions/create_subscription.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Create SMS Delivery Notification Subscription

Background: Common setup
Given an environment at "apiRoot"
And the resource "/subscriptions"
And the header "Content-Type" is set to "application/json"
And the header "Authorization" is set to a valid access token
And the header "x-correlator" complies with the schema at "#/components/parameters/x-correlator"
And the request body is set to a valid "#/components/schemas/CreateSubscription" schema

@sms_subscribe_create_01_success
Scenario: Successfully create a subscription
Given the request body property "$.subscriptionDetail.senderId" is set to a valid senderId
And the request body property "$.subscriptionDetail.type" is set to "org.camaraproject.sms.v0.sms-delivery-status"
And the request body property "$.webhook.notificationUrl" is set to a valid callback URL
When the request "CreateSMSDeliverySubscription" is sent
Then the response status code is 201
And the response body complies with the OAS schema at "/components/schemas/SubscriptionInfo"
And the response property "$.subscriptionId" exists

@sms_subscribe_create_02_no_auth
Scenario: Missing authentication
Given the header "Authorization" is not sent
When the request "CreateSMSDeliverySubscription" is sent
Then the response status code is 401
And the response property "$.code" is "UNAUTHENTICATED"

@sms_subscribe_create_03_invalid_sender
Scenario: Invalid senderId
Given the request body property "$.subscriptionDetail.senderId" is set to "invalid_sender"
When the request "CreateSMSDeliverySubscription" is sent
Then the response status code is 400
And the response property "$.code" is "INVALID_ARGUMENT"

@sms_subscribe_create_04_conflict
Scenario: Create duplicate subscription
Given a subscription already exists for the same senderId and webhook
When the request "CreateSMSDeliverySubscription" is sent again
Then the response status code is 409
And the response property "$.code" is "CONFLICT"
20 changes: 20 additions & 0 deletions code/Test_definitions/delete_subscription.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Delete SMS Delivery Notification Subscription

Background: Common setup
Given an environment at "apiRoot"
And the resource "/subscriptions/{subscriptionId}"
And the header "Authorization" is set to a valid access token
And the header "x-correlator" complies with the schema at "#/components/parameters/x-correlator"

@sms_subscribe_delete_01_success
Scenario: Delete an existing subscription
Given a valid subscriptionId exists
When the request "DeleteSubscription" is sent with that subscriptionId
Then the response status code is 204

@sms_subscribe_delete_02_invalid
Scenario: Delete non-existent subscription
Given a non-existent subscriptionId
When the request "DeleteSubscription" is sent with that subscriptionId
Then the response status code is 404
And the response property "$.code" is "NOT_FOUND"
19 changes: 19 additions & 0 deletions code/Test_definitions/notification.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: SMS Delivery Notification Callbacks

Background: Setup for callback testing
Given a subscription exists with a valid senderId and callback URL

@sms_notification_01_delivery
Scenario: Receive delivery status notification
When an SMS delivery event is triggered for the subscribed senderId
Then a notification is received at the callback URL
And the notification body complies with the OAS schema at "/components/schemas/CloudEvent"
And the notification property "$.type" is "org.camaraproject.sms.v0.sms-delivery-status"

@sms_notification_02_subscription_end
Scenario: Receive subscription end notification
Given the subscription is configured with a limited expiration or max events
When the limit or expiration is reached
Then a "subscription-ends" notification is received
And the notification body complies with the OAS schema at "/components/schemas/CloudEvent"
And subsequent queries return 404 for the subscriptionId
28 changes: 28 additions & 0 deletions code/Test_definitions/retrieve_subscription.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Retrieve SMS Delivery Notification Subscriptions

Background: Common setup
Given an environment at "apiRoot"
And the resource "/subscriptions"
And the header "Authorization" is set to a valid access token
And the header "x-correlator" complies with the schema at "#/components/parameters/x-correlator"

@sms_subscribe_retrieve_01_list
Scenario: Retrieve all subscriptions
When the request "RetrieveSubscriptionList" is sent
Then the response status code is 200
And the response body complies with the OAS schema at "/components/schemas/SubscriptionInfo"
And the response is an array

@sms_subscribe_retrieve_02_one
Scenario: Retrieve a specific subscription by ID
Given a valid subscriptionId exists
When the request "RetrieveSubscription" is sent with that subscriptionId
Then the response status code is 200
And the response body complies with the OAS schema at "/components/schemas/SubscriptionInfo"

@sms_subscribe_retrieve_03_invalid
Scenario: Retrieve non-existent subscription
Given a non-existent subscriptionId
When the request "RetrieveSubscription" is sent with that subscriptionId
Then the response status code is 404
And the response property "$.code" is "NOT_FOUND"
114 changes: 114 additions & 0 deletions code/Test_definitions/send_sms.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Feature: Send SMS

# Implementation indications:
# * apiRoot: API root of the server URL
# * Base path: /sms/v0alpha1/short-message
# * Uses openId token with appropriate scopes: send-sms:short-message
#
# Test assets:
# * Valid recipient phone numbers
# * Valid sender IDs
# * Various message categories (PROMOTION, SERVICE, TRANSACTION)
# * Valid 2-legged and 3-legged tokens as needed

Background: Common setup
Given an environment at "apiRoot"
And the resource "/short-message"
And the header "Content-Type" is set to "application/json"
And the header "Authorization" is set to a valid access token
And the header "x-correlator" complies with the schema at "#/components/parameters/x-correlator"
And the request body is set by default to a valid "MessageRequest" schema

# Success scenarios
@sms_send_01_success_promotion
Scenario: Send a promotional SMS to a single recipient
Given the request body property "$.to" is set to ["+910123456789"]
And the request body property "$.from" is set to "+919876543210"
And the request body property "$.category" is set to "PROMOTION"
And the request body property "$.message" is set to "Promotional message content"
When the request "send-sms" is sent
Then the response status code is 200
And the response body complies with the OAS schema at "/components/schemas/MessageResponse"
And the response property "$.msgId" exists
And the response property "$.timestamp" matches RFC 3339 format

@sms_send_02_success_service
Scenario: Send a service SMS
Given the request body property "$.category" is set to "SERVICE"
And valid "to", "from", and "message" fields
When the request "send-sms" is sent
Then the response status code is 200

@sms_send_03_success_transaction
Scenario: Send a transaction SMS without specifying category
Given the request body property "$.category" is set to "TRANSACTION"
And valid "to", "from", and "message" fields
When the request "send-sms" is sent
Then the response status code is 200

# Error scenarios - Authentication and authorization
@sms_send_401.1_no_auth
Scenario: Missing authentication
Given the header "Authorization" is not sent
When the request "send-sms" is sent
Then the response status code is 401
And the response property "$.code" is "UNAUTHENTICATED"

@sms_send_403.1_permission_denied
Scenario: Insufficient permission
Given the header "Authorization" is set to an access token without "send-sms:short-message" scope
When the request "send-sms" is sent
Then the response status code is 403
And the response property "$.code" is "PERMISSION_DENIED"

# Error scenarios - Invalid inputs
@sms_send_400.1_missing_to
Scenario: Missing recipient address
Given the request body property "$.to" is removed
When the request "send-sms" is sent
Then the response status code is 400
And the response property "$.code" is "INVALID_ARGUMENT"

@sms_send_400.2_missing_from
Scenario: Missing sender ID
Given the request body property "$.from" is removed
When the request "send-sms" is sent
Then the response status code is 400
And the response property "$.code" is "INVALID_ARGUMENT"

@sms_send_400.3_missing_message
Scenario: Missing message body
Given the request body property "$.message" is removed
When the request "send-sms" is sent
Then the response status code is 400
And the response property "$.code" is "INVALID_ARGUMENT"

@sms_send_400.4_invalid_category
Scenario: Invalid category value
Given the request body property "$.category" is set to "INVALID_CATEGORY"
When the request "send-sms" is sent
Then the response status code is 400
And the response property "$.code" is "INVALID_ARGUMENT"

# Error scenarios - Resource not found
@sms_send_404.1_not_found
Scenario: Endpoint not found
Given the resource "/short-message-invalid" instead of "/short-message"
When the request "send-sms" is sent
Then the response status code is 404
And the response property "$.code" is "NOT_FOUND"

# Error scenarios - Server issues
@sms_send_500.1_internal_server
Scenario: Server internal error
Given the server is configured to simulate an internal error
When the request "send-sms" is sent
Then the response status code is 500
And the response property "$.code" is "INTERNAL"

@sms_send_503.1_service_unavailable
Scenario: Service unavailable
Given the server is configured to simulate a maintenance window
When the request "send-sms" is sent
Then the response status code is 503
And the response property "$.code" is "UNAVAILABLE"