Change response code from phrase to code and 'phrase' by 'reason phrase'

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-08-20 09:54:18 +02:00
parent 5352322ad5
commit 5e253c9814
7 changed files with 73 additions and 24 deletions
@@ -12,8 +12,8 @@ Feature: Kapow! server reject responses with semantic errors.
When I append the route: When I append the route:
| entrypoint | command | | entrypoint | command |
| /bin/sh -c | ls -la / \| response /body | | /bin/sh -c | ls -la / \| response /body |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Missing Mandatory Field" as response phrase And I get "Missing Mandatory Field" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| missing_mandatory_fields | | missing_mandatory_fields |
| "url_pattern", "method" | | "url_pattern", "method" |
@@ -26,8 +26,8 @@ Feature: Kapow! server reject responses with semantic errors.
When I append the route: When I append the route:
| method | url_pattern | entrypoint | command | | method | url_pattern | entrypoint | command |
| GET | +123-- | /bin/sh -c | ls -la / \| response /body | | GET | +123-- | /bin/sh -c | ls -la / \| response /body |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Invalid Route Spec" as response phrase And I get "Invalid Route Spec" as response reason phrase
And I get an empty response body And I get an empty response body
Scenario: Error because of wrong method value. Scenario: Error because of wrong method value.
@@ -38,6 +38,6 @@ Feature: Kapow! server reject responses with semantic errors.
When I append the route: When I append the route:
| method | url_pattern | entrypoint | command | | method | url_pattern | entrypoint | command |
| AVECES | +123-- | /bin/sh -c | ls -la / \| response /body | | AVECES | +123-- | /bin/sh -c | ls -la / \| response /body |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Invalid Data Type" as response phrase And I get "Invalid Data Type" as response reason phrase
And I get an empty response body And I get an empty response body
@@ -11,8 +11,8 @@ Feature: Append new routes in Kapow! server.
When I append the route: When I append the route:
| method | url_pattern | entrypoint | command | | method | url_pattern | entrypoint | command |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body |
Then I get created as response code Then I get 201 as response code
And I get "Created" as response phrase And I get "Created" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id | | method | url_pattern | entrypoint | command | index | id |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * |
@@ -28,8 +28,8 @@ Feature: Append new routes in Kapow! server.
When I append the route: When I append the route:
| method | url_pattern | entrypoint | command | | method | url_pattern | entrypoint | command |
| GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | | GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body |
Then I get created as response code Then I get 201 as response code
And I get "Created" as response phrase And I get "Created" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id | | method | url_pattern | entrypoint | command | index | id |
| GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 2 | * | | GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 2 | * |
@@ -8,6 +8,6 @@ Feature: Fail to delete a route in Kapow! server.
Given I have a just started Kapow! server Given I have a just started Kapow! server
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get not found as response code Then I get 404 as response code
And I get "Not Found" as response phrase And I get "Not Found" as response reason phrase
And I get an empty response body And I get an empty response body
@@ -8,6 +8,6 @@ Feature: Delete routes in Kapow! server.
Given I have a running Kapow! server Given I have a running Kapow! server
And It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" And It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get ok as response code Then I get 200 as response code
And I get "OK" as response phrase And I get "OK" as response reason phrase
And I get an empty response body And I get an empty response body
@@ -11,8 +11,8 @@ Feature: Kapow! server reject insert responses with semantic errors.
When I insert the route: When I insert the route:
| entrypoint | command | | entrypoint | command |
| /bin/sh -c | ls -la / \| response /body | | /bin/sh -c | ls -la / \| response /body |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Missing Mandatory Field" as response phrase And I get "Missing Mandatory Field" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| missing_mandatory_fields | | missing_mandatory_fields |
| "url_pattern", "method" | | "url_pattern", "method" |
@@ -25,8 +25,8 @@ Feature: Kapow! server reject insert responses with semantic errors.
When I insert the route: When I insert the route:
| method | url_pattern | entrypoint | command | index | | method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Invalid Route Spec" as response phrase And I get "Invalid Route Spec" as response reason phrase
And I get an empty response body And I get an empty response body
Scenario: Error because of wrong method value. Scenario: Error because of wrong method value.
@@ -37,6 +37,6 @@ Feature: Kapow! server reject insert responses with semantic errors.
When I insert the route: When I insert the route:
| method | url_pattern | entrypoint | command | index | | method | url_pattern | entrypoint | command | index |
| AVECES | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | | AVECES | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get unprocessable entity as response code Then I get 422 as response code
And I get "Invalid Data Type" as response phrase And I get "Invalid Data Type" as response reason phrase
And I get an empty response body And I get an empty response body
@@ -16,8 +16,8 @@ Feature: Insert new routes in Kapow! server.
When I insert the route: When I insert the route:
| method | url_pattern | entrypoint | command | index | | method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get ok as response code Then I get 200 as response code
And I get "OK" as response phrase And I get "OK" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id | | method | url_pattern | entrypoint | command | index | id |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * |
@@ -30,8 +30,8 @@ Feature: Insert new routes in Kapow! server.
When I insert the route: When I insert the route:
| method | url_pattern | entrypoint | command | index | | method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 |
Then I get ok as response code Then I get 200 as response code
And I get "OK" as response phrase And I get "OK" as response reason phrase
And I get the following entity as response body: And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id | | method | url_pattern | entrypoint | command | index | id |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | * | | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | * |
+49
View File
@@ -17,6 +17,7 @@ class Env(EnvironConfig):
@given('I have a just started Kapow! server') @given('I have a just started Kapow! server')
@given('I have a running Kapow! server')
def step_impl(context): def step_impl(context):
context.server = subprocess.Popen( context.server = subprocess.Popen(
Env.KAPOW_SERVER_CMD, Env.KAPOW_SERVER_CMD,
@@ -69,3 +70,51 @@ def step_impl(context):
assert header in entry, f"Response does not contain the key {header}" assert header in entry, f"Response does not contain the key {header}"
if row[header] != '*': if row[header] != '*':
assert entry[header] == row[header], f"Values mismatch" assert entry[header] == row[header], f"Values mismatch"
#
#
#
@when('I append the route')
def step_impl(context):
if not hasattr(context, 'table'):
raise RuntimeError("A table must be set for this step.")
for row in context.table:
response = requests.post(f"{Env.KAPOW_CONTROLAPI_URL}/routes",
json={h: row[h] for h in row.headings})
response.raise_for_status()
@then('I get {code} as response code')
def step_impl(context, code):
raise NotImplementedError('STEP: Then I get unprocessable entity as response code')
@then('I get "{reason}" as response reason phrase')
def step_impl(context, reason):
raise NotImplementedError('STEP: Then I get "Missing Mandatory Field" as response phrase')
@then('I get the following entity as response body')
def step_impl(context):
raise NotImplementedError('STEP: Then I get the following entity as response body')
@then('I get an empty response body')
def step_impl(context):
raise NotImplementedError('STEP: Then I get an empty response body')
@when('I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"')
def step_impl(context):
raise NotImplementedError('STEP: When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"')
@given('It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"')
def step_impl(context):
raise NotImplementedError('STEP: Given It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"')
@when('I insert the route')
def step_impl(context):
raise NotImplementedError('STEP: When I insert the route')