Skip to content

Commit

Permalink
Merge pull request #221 from maxl2287/feature/update-reachability-sta…
Browse files Browse the repository at this point in the history
…tus-response

[device-reachability-status]: support for reachability with multiple connectivity-types
  • Loading branch information
eric-murray authored Nov 8, 2024
2 parents a115a00 + 1b3075b commit 3fb862d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 53 deletions.
48 changes: 29 additions & 19 deletions code/API_definitions/device-reachability-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ info:
* **Device**: A device refers to any physical entity that can connect to a network and participate in network communication.
At least one identifier for the device (user equipment) out of four options: IPv4 address, IPv6 address, Phone number, or Network Access Identifier (not supported for this API version) assigned by the mobile network operator for the device.
* **Reachability** : Reachability status.
- `CONNECTED_SMS`, if device is connected to the network only via SMS usage
- `CONNECTED_DATA`, if device is connected to the network via data usage (regardless of the SMS reachability)
- `NOT_CONNECTED`, if device is not connected to the network
* **Reachable:** Indicates, if the device is reachable from the network or not.
* **Connectivity:** Indicates the connectivity types (DATA, SMS or both) through which the device is reachable from the network.
* **LastStatusTime** : This property specifies the time when the status was last updated. Its presence in the response indicates the freshness of the information, while its absence implies the information may be outdated or its freshness is uncertain.
Expand Down Expand Up @@ -76,7 +75,7 @@ externalDocs:
url: https://github.com/camaraproject/DeviceStatus

servers:
- url: "{apiRoot}/device-reachability-status/v0.6"
- url: "{apiRoot}/device-reachability-status/vwip"
variables:
apiRoot:
default: http://localhost:9091
Expand Down Expand Up @@ -117,15 +116,23 @@ paths:
Connected-With-SMS:
value:
lastStatusTime: "2024-02-20T10:41:38.657Z"
reachabilityStatus: CONNECTED_SMS
reachable: true
connectivity: ["SMS"]
Connected-With-DATA:
value:
lastStatusTime: "2024-02-20T10:41:38.657Z"
reachabilityStatus: CONNECTED_DATA
Not-Connected:
reachable: true
connectivity: ["DATA"]

Connected-With-DATA-And-SMS:
value:
lastStatusTime: "2024-02-20T10:41:38.657Z"
reachable: true
connectivity: ["DATA", "SMS"]
Not-Reachable:
value:
lastStatusTime: "2024-02-20T10:41:38.657Z"
reachabilityStatus: NOT_CONNECTED
reachable: false
"400":
$ref: "#/components/responses/Generic400"
"401":
Expand Down Expand Up @@ -178,24 +185,27 @@ components:
ReachabilityStatusResponse:
type: object
required:
- reachabilityStatus
- reachable
properties:
lastStatusTime:
$ref: "#/components/schemas/LastStatusTime"
reachabilityStatus:
$ref: "#/components/schemas/ReachabilityStatus"
ReachabilityStatus:
reachable:
description: Indicates overall device reachability
type: boolean
connectivity:
type: array
items:
$ref: "#/components/schemas/ConnectivityType"
ConnectivityType:
description: |
CONNECTED_DATA: The device is connected to the network for Data usage (regardless of the SMS reachability)
DATA: The device is connected to the network for Data usage (regardless of the SMS reachability)
CONNECTED_SMS: The device is connected to the network only for SMS usage
SMS: The device is connected to the network only for SMS usage
NOT_CONNECTED: The device is not connected
type: string
enum:
- CONNECTED_DATA
- CONNECTED_SMS
- NOT_CONNECTED
- DATA
- SMS
Device:
description: |
End-user equipment able to connect to a mobile network. Examples of devices include smartphones or IoT sensors/actuators.
Expand Down
76 changes: 42 additions & 34 deletions code/Test_definitions/device-reachability-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,57 @@ Feature: CAMARA Device reachability status API, v0.6.0 - Operations for reachabi

############# Happy Path Scenarios ##################

@device_reachability_status_01_reachabilityStatusConnectedSms
@device_reachability_status_01_reachableAndConnectedSms
Scenario: Check the reachability status if device is connected with SMS
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" is set to a valid testing device which is connected with sms and supported by the service
When the request "getReachabilityStatus" is sent
Then the response code is 200
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"
And the response body complies with the OAS schema at "/components/schemas/ReachabilityStatusResponse"
And the response property "$.status" is 200
And the response property "$.code" is "OK"
And the response property "$.message" contains a user friendly text
And the response property "$.reachabilityStatus" is "CONNECTED_SMS"
And the response property "$.reachable" is true
And the response property "$.connectivity" includes "SMS"

@device_reachability_status_02_reachabilityStatusConnectedData
@device_reachability_status_02_reachableAndConnectedData
Scenario: Check the reachability status if device is connected with DATA
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" is set to a valid testing device which is connected with data and supported by the service
When the request "getReachabilityStatus" is sent
Then the response code is 200
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"
And the response body complies with the OAS schema at "/components/schemas/ReachabilityStatusResponse"
And the response property "$.status" is 200
And the response property "$.code" is "OK"
And the response property "$.reachabilityStatus" is "CONNECTED_DATA"
And the response property "$.reachable" is true
And the response property "$.connectivity" includes "DATA"

@device_reachability_status_03_reachableAndConnectedDataAndSms
Scenario: Check the reachability status if device is connected with DATA and SMS
Given a valid device reachability status request body
And the request body property "$.device" is set to a valid testing device which is connected with both data and sms, and supported by the service
When the request "getReachabilityStatus" is sent
Then the response code is 200
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"
And the response body complies with the OAS schema at "/components/schemas/ReachabilityStatusResponse"
And the response property "$.reachable" is true
And the response property "$.connectivity" includes both "DATA" and "SMS"

@device_reachability_status_03_reachabilityStatusDeviceNotConnected
Scenario: Check the reachability status for DeviceNotConnected
Given a valid devicestatus request body
@device_reachability_status_04_notReachable
Scenario: Check the reachability status for an unreachable device
Given a valid device reachability status request body
And the request body property "$.device" is set to a valid testing device which is not connected and supported by the service
When the request "getReachabilityStatus" is sent
Then the response code is 200
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"
And the response body complies with the OAS schema at "/components/schemas/ReachabilityStatusResponse"
And the response property "$.status" is 200
And the response property "$.code" is "OK"
And the response property "$.reachabilityStatus" is "NOT_CONNECTED"
And the response property "$.reachable" is false
And the response property "$.connectivity" is not returned

#############Error Response Scenarios##################

@device_reachability_status_04_deviceStatus_with_invalid_parameter
@device_reachability_status_05_deviceStatus_with_invalid_parameter
Scenario: Device reachability status request with invalid parameter
Given the request body is not compliant with the schema "/components/schemas/RequestReachabilityStatus"
When the request "getReachabilityStatus" is sent
Expand All @@ -64,29 +72,29 @@ Feature: CAMARA Device reachability status API, v0.6.0 - Operations for reachabi
And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text

@device_reachability_status_05_expired_access_token
@device_reachability_status_06_expired_access_token
Scenario: Expired access token
Given a valid devicestatus request body
Given a valid device reachability status request body
And header "Authorization" is set to expired token
When the request "getReachabilityStatus" is sent
Then the response status code is 401
And the response property "$.status" is 401
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text

@device_reachability_status_06_no_authorization_header
@device_reachability_status_07_no_authorization_header
Scenario: No Authorization header
Given a valid devicestatus request body
Given a valid device reachability status request body
And header "Authorization" is not available
When the request "getReachabilityStatus" is sent
Then the response status code is 401
And the response property "$.status" is 401
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text

@device_reachability_status_07_invalid_access_token
@device_reachability_status_08_invalid_access_token
Scenario: Invalid access token
Given a valid devicestatus request body
Given a valid device reachability status request body
And header "Authorization" set to an invalid access token
When the request "getReachabilityStatus" is sent
Then the response status code is 401
Expand All @@ -95,10 +103,10 @@ Feature: CAMARA Device reachability status API, v0.6.0 - Operations for reachabi
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text

@device_reachability_status_08_deviceStatus_inconsistent_access_token
@device_reachability_status_09_deviceStatus_inconsistent_access_token
Scenario: Inconsistent access token context for the device
# To test this, a token has to be obtained for a different device
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" is set to a valid testing device supported by the service
And header "Authorization" set to access token referring different device
When the request "getReachabilityStatus" is sent
Expand All @@ -107,40 +115,40 @@ Feature: CAMARA Device reachability status API, v0.6.0 - Operations for reachabi
And the response property "$.code" is "INVALID_TOKEN_CONTEXT"
And the response property "$.message" contains a user friendly text

@device_reachability_status_09_deviceStatusWithIdentifiersMismatch
@device_reachability_status_10_deviceStatusWithIdentifiersMismatch
Scenario: Device reachabilityidentifiers mismatch
# To test this, at least 2 types of identifiers have to be provided, e.g. a phoneNumber and the IP address of a Device reachability associated to a different phoneNumber
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" includes several identifiers, each of them identifying a valid but different device
When the request "getReachabilityStatus" is sent
Then the response status code is 422
And the response property "$.status" is 422
And the response property "$.code" is "DEVICE_IDENTIFIERS_MISMATCH"
And the response property "$.message" contains a user friendly text

@device_reachability_status_10_deviceStatus_NotApplicable
@device_reachability_status_11_deviceStatus_NotApplicable
Scenario: Device reachability not applicable
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" refers to an unknown device
When the request "getReachabilityStatus" is sent
Then the response status code is 422
And the response property "$.status" is 422
And the response property "$.code" is "DEVICE_NOT_APPLICABLE"
And the response property "$.message" contains a user friendly text

@device_reachability_status_11_unable_to_provide_reachability_status
@device_reachability_status_12_unable_to_provide_reachability_status
Scenario: Unable to provide reachability status for a device
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" refers to a device having network issue
When the request "getReachabilityStatus" is sent
Then the response status code is 422
And the response property "$.status" is 422
And the response property "$.code" is "UNABLE_TO_PROVIDE_REACHABILITY_STATUS"
And the response property "$.message" contains a user friendly text

@device_reachability_status_12_unsupported_device_identifiers
@device_reachability_status_13_unsupported_device_identifiers
Scenario: Unsupported device identifiers
Given a valid devicestatus request body
Given a valid device reachability status request body
And the request body property "$.device" set to unsupported identifiers value for the service
When the request "getReachabilityStatus" is sent
Then the response status code is 422
Expand Down

0 comments on commit 3fb862d

Please sign in to comment.