Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test Definition for OTPValidationAPI #61

Merged
merged 10 commits into from
Jul 25, 2024
Merged

Add Test Definition for OTPValidationAPI #61

merged 10 commits into from
Jul 25, 2024

Conversation

bigludo7
Copy link
Collaborator

Add Test Definition for OTPValidationAPI

What type of PR is this?

Add one of the following kinds:

  • enhancement/feature

What this PR does / why we need it:

Add Test Definition for OTPValidationAPI

Which issue(s) this PR fixes:

Fixes #57

Special notes for reviewers:

Need agreement on camaraproject/Commonalities#203 before to be fully validated
Adding @jlurien as reviewer to check alignement with the guideline.

Changelog input

 release-note

Additional documentation

This section can be blank.

docs

Add Test Definition for OTPValidationAPI
Copy link

github-actions bot commented May 31, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 2 0 0.03s
✅ OPENAPI spectral 1 0 1.66s
✅ REPOSITORY git_diff yes no 0.01s
✅ REPOSITORY secretlint yes no 0.7s
✅ YAML yamllint 1 0 0.3s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@bigludo7 bigludo7 added the Fall24 Fall 24 Meta release label Jun 19, 2024
Copy link
Collaborator

@fernandopradocabrillo fernandopradocabrillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigludo7
I think the scenarios that are included are fine. I kind of like it more separated in 2 different feature files one for each operation but I can live with it being in only one 😄

I leave you a list with a few scenarios that I think are missing and if we target for an stable version we should include them.

/send-code:

  1. Reached max number of codes that can be requested for a phone number -> ONE_TIME_PASSWORD_SMS.MAX_OTP_CODES_EXCEEDED
  2. The phone number specified is not allowed to receive messages -> ONE_TIME_PASSWORD_SMS.PHONE_NUMBER_NOT_ALLOWED
  3. The phone number specified does not belong to the operator -> ONE_TIME_PASSWORD_SMS.PHONE_NUMBER_NOT_ALLOWED
  4. The phone number specified is a landline -> ONE_TIME_PASSWORD_SMS.PHONE_NUMBER_NOT_ALLOWED
  5. The phone number specified is blocked for any business reason -> ONE_TIME_PASSWORD_SMS.PHONE_NUMBER_BLOCKED
  6. The property message is missing -> INVALID_ARGUMENT
  7. The property phone number is missing -> INVALID_ARGUMENT
  8. The message specified reached a max length stablished by the operator -> INVALID_ARGUMENT

/validate-code:

  1. Verification expired because a new one has been requested for the same phone number -> ONE_TIME_PASSWORD_SMS.VERIFICATION_EXPIRED
  2. The authenticationId is invalid (i.e because the client sends invalid characters) -> ONE_TIME_PASSWORD_SMS.INVALID_OTP
  3. The authenticationId is no longer valid because it has already been used -> ONE_TIME_PASSWORD_SMS.VERIFICATION_EXPIRED
  4. Missing authenticationId in the request -> INVALID_ARGUMENT

code/Test_Definitions/OTPvalidationAPI.feature Outdated Show resolved Hide resolved
code/Test_Definitions/OTPvalidationAPI.feature Outdated Show resolved Hide resolved
bigludo7 and others added 3 commits July 8, 2024 16:56
Co-authored-by: Fernando Prado Cabrillo <fernando.pradocabrillo@telefonica.com>
Co-authored-by: Fernando Prado Cabrillo <fernando.pradocabrillo@telefonica.com>
@bigludo7
Copy link
Collaborator Author

bigludo7 commented Jul 8, 2024

Thanks @fernandopradocabrillo for the review.

I've added these scenarios but also I've reorganized the file to make it easier to read.
I have one point point: 403 did not seems to be relevant for validate-code operation. wdyt?

Given the header "Authorization" is removed
And the resource "/one-time-password-sms/v0/send-code"
When the HTTP "POST" request is sent
Then the response property "$.status" is 403

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a 401 instead of a 403?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! fixed.

# 404 errors for send_code
###########################

@OTPvalidationAPI_404.1_send_code_resource_not_found
Copy link

@trehman-gsma trehman-gsma Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bigludo7 - I think this might be challenging for some Operators to implement. Are there wider guidelines that state that sub-paths should be treated with CAMARA error handling?

I think some implementations will expose only specific paths/routes in their API Gateway e.g. only /one-time-password-sms/v0/send-code is explicitly exposed as a CAMARA API, and anything else is considered an arbitrary URL. In this test case, /one-time-password-sms/send-code might be considered an arbitrary URL and therefore CAMARA error handling is not applied.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes make sense. I've added a comment that this Test Case could be considered as optional.
As for this API we target stable maturity level I tend to prefer to keep it as the testing guideline indicates: Any public release must include a full test plan, covering both sunny and rainy day scenarios, to be considered stable. This may include unusual or not explicitly specified error scenarios, semantic validations, and corner cases.
We're in a corner case here probably

And the response property "$.message" contains a user friendly text
And the response header "x-correlator" has same value as the request header "x-correlator"

@OTPvalidationAPI_400.3_validate_code_missing_authenticationId

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a duplicate title. Should it be named @OTPvalidationAPI_400.3_validate_code_missing_code instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! :)

And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text
And the response header "x-correlator" has same value as the request header "x-correlator"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about an additional case to test compliance with the maxLength of the code field?
Example:

 @OTPvalidationAPI_400.4_validate_code_exceed_code_max_length
  Scenario: exceed the maxLength for code
    Given request body property "$.authenticationId" is set to the value from send-code request
    And the request body property "$.code" is set to "thisCodeExceedsTenCharacters"
    And the resource "/one-time-password-sms/v0/validate-code"
    When the HTTP "POST" request is sent
    Then the response status code is 400
    And the response property "$.status" is 400
    And the response property "$.code" is "INVALID_ARGUMENT"
    And the response property "$.message" contains a user friendly text
    And the response header "x-correlator" has same value as the request header "x-correlator"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes !
Added

And the response header "x-correlator" has same value as the request header "x-correlator"

###########################
# 401 errors for send_code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an observation about the 401 test cases. There is no x-correlator validation in the 401 test cases whereas the other test cases in the document do check for x-correlator.

On the same topic. Should there be happy path test cases that do not input an x-correlator? This would be to ensure that x-correlator is treated an optional header in the implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the x-correlator for 401

Adding testing without x-correlator could be added as this is not mandatory. I've added them. I did not test it in response as it is optional to provide one if not provided in the request.

# *For additional test scenarios, operator could provide phone number for line that cannot receive SMS, line that blocked SMS reception, not belonging to the operator, designing a landline number.
# * message: Message template used to compose the content of the SMS sent to the phone number. It must include the following label indicating where to include the short code {{code}}. Operator could specified a max_lenght for the message.
# * authentication_id: identifier of a a send-code request. Identifier retrieved in send-code response.
# * max_sent: Maximum allowed request to send code for a given device
Copy link

@trehman-gsma trehman-gsma Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a silly question. Is it theoretically possible for an implementation to not have max_sent and max_try functionality?

If max_sent and max_try are mandatory, should the yaml documentation state so?

From GSMA experience, I think there will be some operator developers who will not code this unless it's explicitly stated :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me globally the functionality to burn a code is mandatory but we should probably not enforce a way to do it. Here we have max try but another rule stating that you have 5 minutes to send back the code before expiration is fine as well. So I'm not sure we have to enter in this details.

Took into Toyeeb comments !
Thanks !!
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trehman-gsma !!
This is very helpful.
I took into consideration all your comments.

# *For additional test scenarios, operator could provide phone number for line that cannot receive SMS, line that blocked SMS reception, not belonging to the operator, designing a landline number.
# * message: Message template used to compose the content of the SMS sent to the phone number. It must include the following label indicating where to include the short code {{code}}. Operator could specified a max_lenght for the message.
# * authentication_id: identifier of a a send-code request. Identifier retrieved in send-code response.
# * max_sent: Maximum allowed request to send code for a given device
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me globally the functionality to burn a code is mandatory but we should probably not enforce a way to do it. Here we have max try but another rule stating that you have 5 minutes to send back the code before expiration is fine as well. So I'm not sure we have to enter in this details.

And the response header "x-correlator" has same value as the request header "x-correlator"

###########################
# 401 errors for send_code
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the x-correlator for 401

Adding testing without x-correlator could be added as this is not mandatory. I've added them. I did not test it in response as it is optional to provide one if not provided in the request.

Given the header "Authorization" is removed
And the resource "/one-time-password-sms/v0/send-code"
When the HTTP "POST" request is sent
Then the response property "$.status" is 403
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! fixed.

And the response property "$.message" contains a user friendly text
And the response header "x-correlator" has same value as the request header "x-correlator"

@OTPvalidationAPI_400.3_validate_code_missing_authenticationId
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! :)

And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text
And the response header "x-correlator" has same value as the request header "x-correlator"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes !
Added

# 404 errors for send_code
###########################

@OTPvalidationAPI_404.1_send_code_resource_not_found
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes make sense. I've added a comment that this Test Case could be considered as optional.
As for this API we target stable maturity level I tend to prefer to keep it as the testing guideline indicates: Any public release must include a full test plan, covering both sunny and rainy day scenarios, to be considered stable. This may include unusual or not explicitly specified error scenarios, semantic validations, and corner cases.
We're in a corner case here probably

Shift 403 to 404 when phoneNumber did not belong to the operator
For test case @OTPvalidationAPI_404.1_send_code_phone_number_not_belong_to_operator
bigludo7 and others added 2 commits July 24, 2024 18:05
Co-authored-by: Fernando Prado Cabrillo <fernando.pradocabrillo@telefonica.com>
Co-authored-by: Fernando Prado Cabrillo <fernando.pradocabrillo@telefonica.com>
Copy link
Collaborator

@fernandopradocabrillo fernandopradocabrillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @bigludo7 @trehman-gsma !

@bigludo7 bigludo7 merged commit c98627b into main Jul 25, 2024
1 check passed
@bigludo7 bigludo7 deleted the Test-Defintion branch July 25, 2024 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fall24 Fall 24 Meta release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide test definition artefacts
3 participants