367 lines
10 KiB
YAML
367 lines
10 KiB
YAML
#
|
|
# Test the resource type API to achieve coverage of just the
|
|
# ResourceTypesController and ResourceTypeController class code.
|
|
#
|
|
|
|
fixtures:
|
|
- ConfigFixture
|
|
|
|
tests:
|
|
|
|
- name: list resource type
|
|
desc: only legacy resource types are present
|
|
url: /v1/resource_type
|
|
response_json_paths:
|
|
$.`len`: 15
|
|
|
|
# Some bad cases
|
|
|
|
- name: post resource type as non-admin
|
|
url: /v1/resource_type
|
|
method: post
|
|
data:
|
|
name: my_custom_resource
|
|
request_headers:
|
|
content-type: application/json
|
|
status: 403
|
|
|
|
- name: post resource type with existing name
|
|
url: /v1/resource_type
|
|
method: post
|
|
request_headers:
|
|
x-roles: admin
|
|
content-type: application/json
|
|
data:
|
|
name: my_custom_resource
|
|
attributes:
|
|
project_id:
|
|
type: string
|
|
status: 400
|
|
|
|
- name: post resource type bad string
|
|
url: /v1/resource_type
|
|
method: post
|
|
request_headers:
|
|
x-roles: admin
|
|
content-type: application/json
|
|
data:
|
|
name: my_custom_resource
|
|
attributes:
|
|
foo:
|
|
type: string
|
|
max_length: 32
|
|
min_length: 5
|
|
noexist: foo
|
|
status: 400
|
|
response_strings:
|
|
# NOTE(sileht): We would prefer to have a better message but voluptuous seems a bit lost when
|
|
# an Any have many dict with the same key, here "type"
|
|
# - "Invalid input: extra keys not allowed @ data[u'attributes'][u'foo'][u'noexist']"
|
|
# - "Invalid input: not a valid value for dictionary value @ data[u'attributes'][u'foo'][u'type']"
|
|
- "Invalid input:"
|
|
|
|
# Create a type
|
|
|
|
- name: post resource type
|
|
url: /v1/resource_type
|
|
method: post
|
|
request_headers:
|
|
x-roles: admin
|
|
content-type: application/json
|
|
data:
|
|
name: my_custom_resource
|
|
attributes:
|
|
name:
|
|
type: string
|
|
required: true
|
|
max_length: 5
|
|
min_length: 2
|
|
foobar:
|
|
type: string
|
|
required: false
|
|
uuid:
|
|
type: uuid
|
|
int:
|
|
type: number
|
|
required: false
|
|
min: -2
|
|
max: 3
|
|
float:
|
|
type: number
|
|
required: false
|
|
min: -2.3
|
|
bool:
|
|
type: bool
|
|
required: false
|
|
status: 201
|
|
response_json_paths:
|
|
$.name: my_custom_resource
|
|
$.attributes:
|
|
name:
|
|
type: string
|
|
required: True
|
|
max_length: 5
|
|
min_length: 2
|
|
foobar:
|
|
type: string
|
|
required: False
|
|
max_length: 255
|
|
min_length: 0
|
|
uuid:
|
|
type: uuid
|
|
required: True
|
|
int:
|
|
type: number
|
|
required: False
|
|
min: -2
|
|
max: 3
|
|
float:
|
|
type: number
|
|
required: false
|
|
min: -2.3
|
|
max:
|
|
bool:
|
|
type: bool
|
|
required: false
|
|
|
|
response_headers:
|
|
location: $SCHEME://$NETLOC/v1/resource_type/my_custom_resource
|
|
|
|
# Control the created type
|
|
|
|
- name: relist resource types
|
|
desc: we have a resource type now
|
|
url: /v1/resource_type
|
|
response_json_paths:
|
|
$.`len`: 16
|
|
$.[11].name: my_custom_resource
|
|
|
|
- name: get the custom resource type
|
|
url: /v1/resource_type/my_custom_resource
|
|
response_json_paths:
|
|
$.name: my_custom_resource
|
|
$.attributes:
|
|
name:
|
|
type: string
|
|
required: True
|
|
min_length: 2
|
|
max_length: 5
|
|
foobar:
|
|
type: string
|
|
required: False
|
|
min_length: 0
|
|
max_length: 255
|
|
uuid:
|
|
type: uuid
|
|
required: True
|
|
int:
|
|
type: number
|
|
required: False
|
|
min: -2
|
|
max: 3
|
|
float:
|
|
type: number
|
|
required: false
|
|
min: -2.3
|
|
max:
|
|
bool:
|
|
type: bool
|
|
required: false
|
|
|
|
# Some bad case case on the type
|
|
|
|
- name: delete as non-admin
|
|
url: /v1/resource_type/my_custom_resource
|
|
method: DELETE
|
|
status: 403
|
|
|
|
# Bad resources for this type
|
|
|
|
- name: post invalid resource
|
|
url: /v1/resource/my_custom_resource
|
|
method: post
|
|
request_headers:
|
|
x-user-id: 0fbb2314-8461-4b1a-8013-1fc22f6afc9c
|
|
x-project-id: f3d41b77-0cc1-4f0b-b94a-1d5be9c0e3ea
|
|
content-type: application/json
|
|
data:
|
|
id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
name: toolong!!!
|
|
foobar: what
|
|
uuid: 07eb339e-23c0-4be2-be43-cd8247afae3b
|
|
status: 400
|
|
response_strings:
|
|
# split to not match the u' in py2
|
|
- "Invalid input: length of value must be at most 5 for dictionary value @ data["
|
|
- "'name']"
|
|
|
|
- name: post invalid resource uuid
|
|
url: /v1/resource/my_custom_resource
|
|
method: post
|
|
request_headers:
|
|
x-user-id: 0fbb2314-8461-4b1a-8013-1fc22f6afc9c
|
|
x-project-id: f3d41b77-0cc1-4f0b-b94a-1d5be9c0e3ea
|
|
content-type: application/json
|
|
data:
|
|
id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
name: too
|
|
foobar: what
|
|
uuid: really!
|
|
status: 400
|
|
response_strings:
|
|
# split to not match the u' in py2
|
|
- "Invalid input: not a valid value for dictionary value @ data["
|
|
- "'uuid']"
|
|
|
|
# Good resources for this type
|
|
|
|
- name: post custom resource
|
|
url: /v1/resource/my_custom_resource
|
|
method: post
|
|
request_headers:
|
|
x-user-id: 0fbb2314-8461-4b1a-8013-1fc22f6afc9c
|
|
x-project-id: f3d41b77-0cc1-4f0b-b94a-1d5be9c0e3ea
|
|
content-type: application/json
|
|
data:
|
|
id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
name: bar
|
|
foobar: what
|
|
uuid: e495ebad-be64-46c0-81d6-b079beb48df9
|
|
int: 1
|
|
status: 201
|
|
response_json_paths:
|
|
$.id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
$.name: bar
|
|
$.foobar: what
|
|
|
|
- name: patch custom resource
|
|
url: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
method: patch
|
|
request_headers:
|
|
x-user-id: 0fbb2314-8461-4b1a-8013-1fc22f6afc9c
|
|
x-project-id: f3d41b77-0cc1-4f0b-b94a-1d5be9c0e3ea
|
|
content-type: application/json
|
|
data:
|
|
name: foo
|
|
status: 200
|
|
response_json_paths:
|
|
$.id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
$.name: foo
|
|
$.foobar: what
|
|
$.uuid: e495ebad-be64-46c0-81d6-b079beb48df9
|
|
$.int: 1
|
|
|
|
- name: get resource
|
|
url: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
request_headers:
|
|
content-type: application/json
|
|
response_json_paths:
|
|
$.id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
$.name: foo
|
|
$.foobar: what
|
|
$.uuid: e495ebad-be64-46c0-81d6-b079beb48df9
|
|
$.int: 1
|
|
|
|
- name: post resource with default
|
|
url: /v1/resource/my_custom_resource
|
|
method: post
|
|
request_headers:
|
|
x-user-id: 0fbb2314-8461-4b1a-8013-1fc22f6afc9c
|
|
x-project-id: f3d41b77-0cc1-4f0b-b94a-1d5be9c0e3ea
|
|
content-type: application/json
|
|
data:
|
|
id: c4110aec-6e5c-43fa-b8c5-ffdfbca3ce59
|
|
name: foo
|
|
uuid: e495ebad-be64-46c0-81d6-b079beb48df9
|
|
status: 201
|
|
response_json_paths:
|
|
$.id: c4110aec-6e5c-43fa-b8c5-ffdfbca3ce59
|
|
$.name: foo
|
|
$.foobar:
|
|
$.uuid: e495ebad-be64-46c0-81d6-b079beb48df9
|
|
$.int:
|
|
|
|
# Ensure we can't delete the type
|
|
|
|
- name: list resource history
|
|
url: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747/history?sort=revision_end:asc-nullslast
|
|
request_headers:
|
|
content-type: application/json
|
|
response_json_paths:
|
|
$.`len`: 2
|
|
$[0].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
$[0].name: bar
|
|
$[0].foobar: what
|
|
$[1].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
$[1].name: foo
|
|
$[1].foobar: what
|
|
|
|
- name: delete in use resource_type
|
|
url: /v1/resource_type/my_custom_resource
|
|
method: delete
|
|
request_headers:
|
|
x-roles: admin
|
|
status: 400
|
|
response_strings:
|
|
- Resource type my_custom_resource is still in use
|
|
|
|
# Delete associated resources
|
|
|
|
- name: delete the resource
|
|
url: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
|
|
request_headers:
|
|
x-roles: admin
|
|
method: DELETE
|
|
status: 204
|
|
|
|
- name: delete the second resource
|
|
url: /v1/resource/my_custom_resource/c4110aec-6e5c-43fa-b8c5-ffdfbca3ce59
|
|
request_headers:
|
|
x-roles: admin
|
|
method: DELETE
|
|
status: 204
|
|
|
|
# Now we can deleted the type
|
|
|
|
- name: delete the custom resource type
|
|
method: delete
|
|
request_headers:
|
|
x-roles: admin
|
|
url: /v1/resource_type/my_custom_resource
|
|
status: 204
|
|
|
|
- name: delete non-existing custom resource type
|
|
method: delete
|
|
request_headers:
|
|
x-roles: admin
|
|
url: /v1/resource_type/my_custom_resource
|
|
status: 404
|
|
|
|
- name: delete missing custom resource type utf8
|
|
url: /v1/resource_type/%E2%9C%94%C3%A9%C3%B1%E2%98%83
|
|
method: DELETE
|
|
request_headers:
|
|
x-roles: admin
|
|
status: 404
|
|
response_strings:
|
|
- Resource type ✔éñ☃ does not exist
|
|
|
|
# Can we readd and delete the same resource type again
|
|
|
|
- name: post resource type again
|
|
url: /v1/resource_type
|
|
method: post
|
|
request_headers:
|
|
x-roles: admin
|
|
content-type: application/json
|
|
data:
|
|
name: my_custom_resource
|
|
status: 201
|
|
|
|
- name: delete the custom resource type again
|
|
method: delete
|
|
request_headers:
|
|
x-roles: admin
|
|
url: /v1/resource_type/my_custom_resource
|
|
status: 204
|