/usr/lib/python3/dist-packages/gnocchi/tests/functional/gabbits/resource-type.yaml is in python3-gnocchi 4.2.0-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | #
# Test the resource type API to achieve coverage of just the
# ResourceTypesController and ResourceTypeController class code.
#
fixtures:
- ConfigFixture
defaults:
request_headers:
# User foobar
authorization: "basic Zm9vYmFyOg=="
content-type: application/json
tests:
- name: list resource type
desc: only legacy resource types are present
GET: /v1/resource_type
response_json_paths:
$.`len`: 1
# Some bad cases
- name: post resource type as non-admin
POST: $LAST_URL
data:
name: my_custom_resource
status: 403
- name: post resource type with existing name
POST: /v1/resource_type
request_headers:
# User admin
authorization: "basic YWRtaW46"
data:
name: my_custom_resource
attributes:
project_id:
type: string
status: 400
- name: post resource type bad string
POST: $LAST_URL
request_headers:
# User admin
authorization: "basic YWRtaW46"
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:"
- name: post resource type bad min_length value
POST: $LAST_URL
request_headers:
# User admin
authorization: "basic YWRtaW46"
data:
name: my_custom_resource
attributes:
name:
type: string
required: true
max_length: 2
min_length: 5
status: 400
- name: post resource type bad min value
POST: $LAST_URL
request_headers:
# User admin
authorization: "basic YWRtaW46"
data:
name: my_custom_resource
attributes:
int:
type: number
required: false
max: 3
min: 8
status: 400
# Create a type
- name: post resource type
POST: $LAST_URL
request_headers:
# User admin
authorization: "basic YWRtaW46"
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
intnomin:
type: number
required: false
max: 3
float:
type: number
required: false
min: -2.3
bool:
type: bool
required: false
datetime:
type: datetime
required: false
status: 201
response_json_paths:
$.name: my_custom_resource
$.state: active
$.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
intnomin:
type: number
required: False
min:
max: 3
float:
type: number
required: false
min: -2.3
max:
bool:
type: bool
required: false
datetime:
type: datetime
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
GET: $LAST_URL
response_json_paths:
$.`len`: 2
$.[1].name: my_custom_resource
$.[1].state: active
- name: get the custom resource type
GET: /v1/resource_type/my_custom_resource
response_json_paths:
$.name: my_custom_resource
$.state: active
$.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
intnomin:
type: number
required: False
min:
max: 3
float:
type: number
required: false
min: -2.3
max:
bool:
type: bool
required: false
datetime:
type: datetime
required: false
# Some bad case case on the type
- name: delete as non-admin
DELETE: $LAST_URL
status: 403
# Bad resources for this type
- name: post invalid resource
POST: /v1/resource/my_custom_resource
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
POST: $LAST_URL
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: badly formed hexadecimal UUID string for dictionary value @ data["
- "'uuid']"
# Good resources for this type
- name: post custom resource
POST: $LAST_URL
data:
id: d11edfca-4393-4fda-b94d-b05a3a1b3747
name: bar
foobar: what
uuid: e495ebad-be64-46c0-81d6-b079beb48df9
int: 1
datetime: "2017-05-02T11:11:11Z"
status: 201
response_json_paths:
$.id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$.name: bar
$.foobar: what
$.datetime: "2017-05-02T11:11:11+00:00"
- name: patch custom resource
PATCH: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
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
GET: $LAST_URL
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
POST: /v1/resource/my_custom_resource
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:
- name: list resource history
GET: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747/history?sort=revision_end:asc-nullslast
response_json_paths:
$.`len`: 2
$[0].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$[0].name: bar
$[0].foobar: what
$[0].datetime: "2017-05-02T11:11:11+00:00"
$[1].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$[1].name: foo
$[1].foobar: what
# CRUD resource type attributes
- name: post a new resource attribute
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: add
path: /attributes/new-optional-bool
value:
type: bool
required: False
- op: add
path: /attributes/new-optional-int
value:
type: number
required: False
min: 0
max: 255
- op: add
path: /attributes/new-optional-uuid
value:
type: uuid
required: False
- op: add
path: /attributes/new-optional-datetime
value:
type: datetime
required: False
- op: add
path: /attributes/newstuff
value:
type: string
required: False
min_length: 0
max_length: 255
- op: add
path: /attributes/newfilled
value:
type: string
required: False
min_length: 0
max_length: 255
options:
fill: "filled"
- op: add
path: /attributes/newbool
value:
type: bool
required: True
options:
fill: True
- op: add
path: /attributes/newint
value:
type: number
required: True
min: 0
max: 255
options:
fill: 15
- op: add
path: /attributes/newstring
value:
type: string
required: True
min_length: 0
max_length: 255
options:
fill: "foobar"
- op: add
path: /attributes/newuuid
value:
type: uuid
required: True
options:
fill: "00000000-0000-0000-0000-000000000000"
- op: add
path: /attributes/newdatetime
value:
type: datetime
required: True
options:
fill: "2017-10-10T10:10:10Z"
- op: remove
path: /attributes/foobar
status: 200
response_json_paths:
$.name: my_custom_resource
$.attributes:
name:
type: string
required: True
min_length: 2
max_length: 5
uuid:
type: uuid
required: True
int:
type: number
required: False
min: -2
max: 3
intnomin:
type: number
required: False
min:
max: 3
float:
type: number
required: false
min: -2.3
max:
bool:
type: bool
required: false
datetime:
type: datetime
required: False
new-optional-bool:
type: bool
required: False
new-optional-int:
type: number
required: False
min: 0
max: 255
new-optional-uuid:
type: uuid
required: False
new-optional-datetime:
type: datetime
required: False
newstuff:
type: string
required: False
min_length: 0
max_length: 255
newfilled:
type: string
required: False
min_length: 0
max_length: 255
newstring:
type: string
required: True
min_length: 0
max_length: 255
newbool:
type: bool
required: True
newint:
type: number
required: True
min: 0
max: 255
newuuid:
type: uuid
required: True
newdatetime:
type: datetime
required: True
- name: post a new resource attribute with missing fill
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: add
path: /attributes/missing
value:
type: bool
required: True
options: {}
status: 400
response_strings:
- "Invalid input: Option 'fill' of resource attribute missing is invalid: must not be empty if required=True"
- name: post a new resource attribute with incorrect fill
PATCH: /v1/resource_type/my_custom_resource
request_headers:
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: add
path: /attributes/incorrect
value:
type: number
required: True
options:
fill: "a-string"
status: 400
response_strings:
- "Invalid input: Option 'fill' of resource attribute incorrect is invalid: expected Real"
- name: get the new custom resource type
GET: /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
uuid:
type: uuid
required: True
int:
type: number
required: False
min: -2
max: 3
intnomin:
type: number
required: False
min:
max: 3
float:
type: number
required: false
min: -2.3
max:
bool:
type: bool
required: false
datetime:
type: datetime
required: False
new-optional-bool:
type: bool
required: False
new-optional-int:
type: number
required: False
min: 0
max: 255
new-optional-uuid:
type: uuid
required: False
new-optional-datetime:
type: datetime
required: False
newstuff:
type: string
required: False
min_length: 0
max_length: 255
newfilled:
type: string
required: False
min_length: 0
max_length: 255
newstring:
type: string
required: True
min_length: 0
max_length: 255
newbool:
type: bool
required: True
newint:
type: number
required: True
min: 0
max: 255
newuuid:
type: uuid
required: True
newdatetime:
type: datetime
required: True
- name: control new attributes of existing resource
GET: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
status: 200
response_json_paths:
$.id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$.name: foo
$.newstuff: null
$.newfilled: "filled"
$.newbool: true
$.newint: 15
$.newstring: foobar
$.newuuid: "00000000-0000-0000-0000-000000000000"
$.newdatetime: "2017-10-10T10:10:10+00:00"
$.new-optional-bool: null
$.new-optional-int: null
$.new-optional-uuid: null
$.new-optional-datetime: null
- name: control new attributes of existing resource history
GET: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747/history?sort=revision_end:asc-nullslast
response_json_paths:
$.`len`: 2
$[0].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$[0].name: bar
$[0].newstuff: null
$[0].newfilled: "filled"
$[0].newbool: true
$[0].newint: 15
$[0].newstring: foobar
$[0].newuuid: "00000000-0000-0000-0000-000000000000"
$[0].newdatetime: "2017-10-10T10:10:10+00:00"
$[0].new-optional-bool: null
$[0].new-optional-int: null
$[0].new-optional-uuid: null
$[0].new-optional-datetime: null
$[1].id: d11edfca-4393-4fda-b94d-b05a3a1b3747
$[1].name: foo
$[1].newstuff: null
$[1].newfilled: "filled"
$[1].newbool: true
$[1].newint: 15
$[1].newstring: foobar
$[1].newuuid: "00000000-0000-0000-0000-000000000000"
$[1].newdatetime: "2017-10-10T10:10:10+00:00"
$[1].new-optional-bool: null
$[1].new-optional-int: null
$[1].new-optional-uuid: null
$[1].new-optional-datetime: null
# Invalid patch
- name: add/delete the same resource attribute
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: add
path: /attributes/what
value:
type: string
required: False
min_length: 0
max_length: 255
- op: remove
path: /attributes/what
status: 200
response_json_paths:
$.name: my_custom_resource
$.attributes:
name:
type: string
required: True
min_length: 2
max_length: 5
uuid:
type: uuid
required: True
int:
type: number
required: False
min: -2
max: 3
intnomin:
type: number
required: False
min:
max: 3
float:
type: number
required: false
min: -2.3
max:
bool:
type: bool
required: false
datetime:
type: datetime
required: False
newstuff:
type: string
required: False
min_length: 0
max_length: 255
newfilled:
type: string
required: False
min_length: 0
max_length: 255
newstring:
type: string
required: True
min_length: 0
max_length: 255
newbool:
type: bool
required: True
newint:
type: number
required: True
min: 0
max: 255
newuuid:
type: uuid
required: True
newdatetime:
type: datetime
required: True
new-optional-bool:
type: bool
required: False
new-optional-int:
type: number
required: False
min: 0
max: 255
new-optional-uuid:
type: uuid
required: False
new-optional-datetime:
type: datetime
required: False
- name: delete/add the same resource attribute
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: remove
path: /attributes/what
- op: add
path: /attributes/what
value:
type: string
required: False
min_length: 0
max_length: 255
status: 400
response_strings:
- "can't remove non-existent object 'what'"
- name: patch a resource attribute replace
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: replace
path: /attributes/newstuff
value:
type: string
required: False
min_length: 0
max_length: 255
status: 400
response_strings:
- "Invalid input: not a valid value for dictionary value @ data[0]["
- "'op']"
- name: patch a resource attribute type not exist
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: add
path: /attributes/newstuff
value:
type: notexist
required: False
min_length: 0
max_length: 255
status: 400
- name: patch a resource attribute type unknown
PATCH: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
content-type: application/json-patch+json
data:
- op: remove
path: /attributes/unknown
status: 400
response_strings:
- "can't remove non-existent object 'unknown'"
# Ensure we can't delete the type
- name: delete in use resource_type
DELETE: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
status: 400
response_strings:
- Resource type my_custom_resource is still in use
# Delete associated resources
- name: delete the resource
DELETE: /v1/resource/my_custom_resource/d11edfca-4393-4fda-b94d-b05a3a1b3747
request_headers:
# User admin
authorization: "basic YWRtaW46"
status: 204
- name: delete the second resource
DELETE: /v1/resource/my_custom_resource/c4110aec-6e5c-43fa-b8c5-ffdfbca3ce59
request_headers:
# User admin
authorization: "basic YWRtaW46"
status: 204
# Now we can deleted the type
- name: delete the custom resource type
DELETE: /v1/resource_type/my_custom_resource
request_headers:
# User admin
authorization: "basic YWRtaW46"
status: 204
- name: delete non-existing custom resource type
DELETE: $LAST_URL
request_headers:
authorization: "basic YWRtaW46"
status: 404
- name: delete missing custom resource type utf8
DELETE: /v1/resource_type/%E2%9C%94%C3%A9%C3%B1%E2%98%83
request_headers:
authorization: "basic YWRtaW46"
status: 404
response_strings:
- Resource type ✔éñ☃ does not exist
# Can we readd and delete the same resource type again
- name: post resource type again
POST: /v1/resource_type
request_headers:
authorization: "basic YWRtaW46"
data:
name: my_custom_resource
status: 201
- name: delete the custom resource type again
DELETE: /v1/resource_type/my_custom_resource
request_headers:
authorization: "basic YWRtaW46"
status: 204
|