microversion-parse/microversion_parse/tests/gabbits/middleware.yaml
Chris Dent b5359fcd80 Add MicroversionMiddleware
This change imports (with slight modification) the
MicroversionMiddleware created for the placement service.

For the time being the middleware relies on WebOb as that is
what it originally relied on. If there are requirements to do
otherwise, later, we can make adjustments then.

The README is updated with limited usage instructions.

Gabbi tests are added, requiring adjustments to the test configuration,
so the opportunity was taken to switch to using stestr instead of testr.

Though arguably "functional" tests because they are not strictly unit
tests, no distinction is made in the tests directory, for now, as it
is all nice and fast and we'd like to keep it that way.

Change-Id: I9d27b6fad35f7aea0085f08c0353f8e8acdb8b73
2018-03-20 17:24:56 +00:00

76 lines
1.7 KiB
YAML

# Tests that the middleware does microversioning as we expect
# The min version of the service is 1.0, the max is 1.2,
# the service type is "cats" (because the internet is for cats).
defaults:
request_headers:
# We must guard against webob requiring an accept header.
# We don't want to do this in the middleware itself as
# we don't know what the application would prefer as a
# default.
accept: application/json
tests:
- name: min default
GET: /good
response_headers:
openstack-api-version: cats 1.0
- name: max latest
GET: /good
request_headers:
openstack-api-version: cats latest
response_headers:
openstack-api-version: cats 1.2
- name: explict
GET: /good
request_headers:
openstack-api-version: cats 1.1
response_headers:
openstack-api-version: cats 1.1
- name: out of range
GET: /good
request_headers:
openstack-api-version: cats 1.9
status: 406
response_strings:
- Unacceptable version header
- name: invalid format
GET: /good
request_headers:
openstack-api-version: cats 1.9.5
status: 400
response_strings:
- invalid literal
- name: different service
desc: end up with default microversion
GET: /good
request_headers:
openstack-api-version: dogs 1.9
response_headers:
openstack-api-version: cats 1.0
- name: multiple services
GET: /good
request_headers:
openstack-api-version: dogs 1.9, cats 1.1
response_headers:
openstack-api-version: cats 1.1
- name: header present on exception
GET: /bad
request_headers:
openstack-api-version: dogs 1.9, cats 1.1
response_headers:
openstack-api-version: cats 1.1
status: 404
response_strings:
- /bad not found