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

Enable Gherkin Linting #191

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
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
74 changes: 74 additions & 0 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"no-files-without-scenarios" : "on",
"no-unnamed-features": "on",
"no-unnamed-scenarios": "on",
"no-dupe-scenario-names": ["on", "in-feature"],
"no-dupe-feature-names": "on",
"no-partially-commented-tag-lines": "on",
"indentation" : [
"on", {
"Feature": 0,
"Background": 2, //CHANGED: From "0" to "2". Should BE of level "2"
"Scenario": 2,
"Step": 2,
"Examples": 4,
"example": 6, //CHANGED: From "4" to "6". Should BE of level "6" to have more indentation than the "Examples" umbrella
"given": 4,
"when": 4,
"then": 4,
"and": 4,
"but": 4,
"feature tag": 2,
"scenario tag": 2
}
],
"no-trailing-spaces": "on",
"new-line-at-eof": ["on", "no"],
"no-multiple-empty-lines": "on",
"no-empty-file": "on",
"no-scenario-outlines-without-examples": "on",
"name-length": ["on", {"Feature": 90, "Step": 190, "Scenario": 190}],
"no-restricted-tags": ["on", {"tags": ["@watch", "@wip"]}],
"use-and": "on",
"keywords-in-logical-order": "on",
"no-duplicate-tags": "on",
"no-superfluous-tags": "on",
"no-homogenous-tags": "on",
"one-space-between-tags": "on",
"no-unused-variables": "on",
"no-background-only-scenario": "on",
"no-empty-background": "on",
"scenario-size": ["on", { "steps-length": {"Background": 15, "Scenario": 15}}],
"only-one-when": "off",
"allowed-tags": ["on", {
"patterns": [
"^@watch$",
"^@wip$",
"^@.*$"
]
}],
"file-name": ["off", {"style": "kebab-case"}], //DISABLED ("on" -> "off"): As per ATP testing guidelines, the `operationId` can be part of the test file and `operationId` follow lowerCamelCase format
"max-scenarios-per-file": ["on", {"maxScenarios": 50, "countOutlineExamples": true}],
"no-restricted-patterns": ["on", {
"Global": [
"^globally restricted pattern"
],
"Feature": [
"poor description",
// "validate", //DISABLED: Specifically for Carrier Billing as there is an operation named validatePayment
"verify"
],
"Background": [
"show last response",
"a debugging step"
],
"Scenario": [
"show last response",
"a debugging step"
]
}],
"required-tags": ["on", {
"tags": ["^@.*$"], // Allow any tag starting with '@'
"ignoreUntagged": false // Enforce tagging
}]
}
4 changes: 4 additions & 0 deletions .github/workflows/megalinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
run: npm install -g @stoplight/spectral
- name: Install Spectral functions
run: npm install -g @stoplight/spectral-functions
- name: Install Gherkin Linter
run: npm install -g gherkin-lint
- name: Run Gherkin Linting
run: gherkin-lint code/Test_definitions/*.feature
# - name: Run spectral:oas Spectral Linting
# run: spectral lint code/API_definitions/*.yaml --verbose --ruleset .spectral.yml
# Replace openapi.yaml file with your API specification file
Expand Down
23 changes: 4 additions & 19 deletions code/Test_definitions/carrier-billing-cancelPayment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
# References to OAS spec schemas refer to schemas specifies in carrier-billing.yaml, version 0.3.0

Background: Common cancelPayment setup
Given the resource "/carrier-billing/v0.3/payments/{paymentId}/cancel" |
Given the resource "/carrier-billing/v0.3/payments/{paymentId}/cancel"
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" is set to a UUID value
Expand All @@ -21,7 +21,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
# Happy path scenarios
##############################


@cancel_payment_01_generic_success_scenario
Scenario: Common validations for any success scenario
# Valid default request body compliant with the schema
Expand All @@ -31,27 +30,24 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


@cancel_payment_02_phoneNumber_three_legged
# Case using a 3-legged Access Token
Scenario: Request cancel payment indicating phoneNumber
Scenario: Request cancel payment indicating phoneNumber in 3-legged access mode
Given the request body property "$.phonenumber" is set to a valid value which is the same as associated to access token
When the HTTP "POST" request is sent
Then the response status code is 202
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


@cancel_payment_03_phoneNumber_two_legged
# Case using a 2-legged Access Token. Only applicable for Countries and Telco Operators whose regulation allows for it
Scenario: Request cancel payment indicating phoneNumber
Scenario: Request cancel payment indicating phoneNumber in 2-legged access mode
Given the request body property "$.phonenumber" is set to a valid value which is the same as associated to access token
When the HTTP "POST" request is sent
Then the response status code is 202
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


##############################
# Error scenarios
##############################
Expand All @@ -67,7 +63,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text


@cancel_payment_400.02_empty_request_body
Scenario: Empty object as request body
Given the request body is set to "{}"
Expand All @@ -77,7 +72,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text


# Error 401 scenarios

@cancel_payment_401.01_no_authorization_header
Expand All @@ -90,7 +84,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


@cancel_payment_401.02_expired_access_token
Scenario: Expired access token
Given the header "Authorization" is set to an expired access token
Expand All @@ -101,7 +94,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


@cancel_payment_401.03_invalid_access_token
Scenario: Invalid access token
Given the header "Authorization" is set to an invalid access token
Expand All @@ -113,7 +105,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


# Error 403 scenarios

@cancel_payment_403.01_invalid_token_permissions
Expand All @@ -127,7 +118,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "PERMISSION_DENIED"
And the response property "$.message" contains a user friendly text


@cancel_payment_403.02_phoneNumber_token_mismatch
Scenario: Inconsistent access token context for the phoneNumber
# To test this, a 3-legged access token has to be obtained for a different phoneNumber
Expand All @@ -139,7 +129,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "INVALID_TOKEN_CONTEXT"
And the response property "$.message" contains a user friendly text


# Error 409 scenarios

@cancel_payment_409.01_payment_confirmed
Expand All @@ -153,7 +142,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "CARRIER_BILLING.PAYMENT_CONFIRMED"
And the response property "$.message" contains a user friendly text


@cancel_payment_409.02_payment_cancelled
Scenario: Payment already cancelled
Given the request body is set to a valid request body
Expand All @@ -165,7 +153,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "CARRIER_BILLING.PAYMENT_CANCELLED"
And the response property "$.message" contains a user friendly text


# Error 422 scenarios

@cancel_payment_422.01_phoneNumber_required
Expand All @@ -179,8 +166,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation cancelPayment
And the response property "$.code" is "CARRIER_BILLING.PHONE_NUMBER_REQUIRED"
And the response property "$.message" contains a user friendly text


##############################
##END
##############################

##############################
24 changes: 4 additions & 20 deletions code/Test_definitions/carrier-billing-confirmPayment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
# References to OAS spec schemas refer to schemas specifies in carrier-billing.yaml, version 0.3.0

Background: Common confirmPayment setup
Given the resource "/carrier-billing/v0.3/payments/{paymentId}/confirm" |
Given the resource "/carrier-billing/v0.3/payments/{paymentId}/confirm"
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" is set to a UUID value
Expand All @@ -22,7 +22,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
# Happy path scenarios
##############################


@confirm_payment_01_generic_success_scenario
Scenario: Common validations for any success scenario
# Valid default request body compliant with the schema
Expand All @@ -32,27 +31,24 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


@confirm_payment_02_phoneNumber_three_legged
# Case using a 3-legged Access Token
Scenario: Request confirm payment indicating phoneNumber
Scenario: Request confirm payment indicating phoneNumber in 3-legged access mode
Given the request body property "$.phonenumber" is set to a valid value which is the same as associated to access token
When the HTTP "POST" request is sent
Then the response status code is 202
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


@confirm_payment_03_phoneNumber_two_legged
# Case using a 2-legged Access Token. Only applicable for Countries and Telco Operators whose regulation allows for it
Scenario: Request confirm payment indicating phoneNumber
Scenario: Request confirm payment indicating phoneNumber in 2-legged access mode
Given the request body property "$.phonenumber" is set to a valid value which is the same as associated to access token
When the HTTP "POST" request is sent
Then the response status code is 202
And the response header "Content-Type" is "application/json"
And the response header "x-correlator" has same value as the request header "x-correlator"


##############################
# Error scenarios
##############################
Expand All @@ -68,7 +64,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text


@confirm_payment_400.02_empty_request_body
Scenario: Empty object as request body
Given the request body is set to "{}"
Expand All @@ -78,7 +73,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "INVALID_ARGUMENT"
And the response property "$.message" contains a user friendly text


# Error 401 scenarios

@confirm_payment_401.01_no_authorization_header
Expand All @@ -91,7 +85,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


@confirm_payment_401.02_expired_access_token
Scenario: Expired access token
Given the header "Authorization" is set to an expired access token
Expand All @@ -102,7 +95,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


@confirm_payment_401.03_invalid_access_token
Scenario: Invalid access token
Given the header "Authorization" is set to an invalid access token
Expand All @@ -114,7 +106,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "UNAUTHENTICATED"
And the response property "$.message" contains a user friendly text


# Error 403 scenarios

@confirm_payment_403.01_invalid_token_permissions
Expand All @@ -128,7 +119,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "PERMISSION_DENIED"
And the response property "$.message" contains a user friendly text


@confirm_payment_403.02_phoneNumber_token_mismatch
Scenario: Inconsistent access token context for the phoneNumber
# To test this, a 3-legged access token has to be obtained for a different phoneNumber
Expand All @@ -140,7 +130,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "INVALID_TOKEN_CONTEXT"
And the response property "$.message" contains a user friendly text


@confirm_payment_403.02_payment_denied
Scenario: Payment denied by business
# To test this, a business context exists in the Telco Operator to deny the payment
Expand All @@ -152,7 +141,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "CARRIER_BILLING.PAYMENT_DENIED"
And the response property "$.message" contains a user friendly text


# Error 409 scenarios

@confirm_payment_409.01_payment_confirmed
Expand All @@ -166,7 +154,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "CARRIER_BILLING.PAYMENT_CONFIRMED"
And the response property "$.message" contains a user friendly text


@confirm_payment_409.02_payment_cancelled
Scenario: Payment already cancelled
Given the request body is set to a valid request body
Expand All @@ -178,7 +165,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "CARRIER_BILLING.PAYMENT_CANCELLED"
And the response property "$.message" contains a user friendly text


# Error 422 scenarios

@confirm_payment_422.01_phoneNumber_required
Expand All @@ -192,8 +178,6 @@ Feature: CAMARA Carrier Billing API, v0.3 - Operation confirmPayment
And the response property "$.code" is "CARRIER_BILLING.PHONE_NUMBER_REQUIRED"
And the response property "$.message" contains a user friendly text


##############################
##END
##############################

##############################
Loading