|
| 1 | +#!/usr/bin/env bats |
| 2 | +# |
| 3 | +# Copyright 2022 HAProxy Technologies |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http:#www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +load '../../libs/dataplaneapi' |
| 19 | +load '../../libs/get_json_path' |
| 20 | +load '../../libs/haproxy_config_setup' |
| 21 | +load '../../libs/resource_client' |
| 22 | +load '../../libs/version' |
| 23 | +load '../../libs/debug' |
| 24 | +load '../../libs/haproxy_version' |
| 25 | + |
| 26 | +load 'utils/_helpers' |
| 27 | + |
| 28 | +@test "defaults: Create a named defaults configuration" { |
| 29 | + resource_post "$_NAMED_DEFAULTS_BASE_PATH" "data/post.json" "" |
| 30 | + assert_equal "$SC" 202 |
| 31 | + |
| 32 | + resource_get "$_NAMED_DEFAULTS_BASE_PATH/created" |
| 33 | + assert_equal "$SC" 200 |
| 34 | + |
| 35 | + assert_equal "$(get_json_path "$BODY" '.data.name')" "created" |
| 36 | + assert_equal "$(get_json_path "$BODY" '.data.server_timeout')" "20000" |
| 37 | + assert_equal "$(get_json_path "$BODY" '.data.client_timeout')" "20000" |
| 38 | + assert_equal "$(get_json_path "$BODY" '.data.mode')" "http" |
| 39 | +} |
| 40 | + |
| 41 | +@test "defaults: Create a named defaults configuration that already exists" { |
| 42 | + resource_post "$_NAMED_DEFAULTS_BASE_PATH" "data/post_existing.json" "" |
| 43 | + assert_equal "$SC" 409 |
| 44 | +} |
| 45 | + |
| 46 | +@test "defaults: Create a named defaults configuration with from" { |
| 47 | + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" |
| 48 | + |
| 49 | + resource_post "$_NAMED_DEFAULTS_BASE_PATH" "data/post.json" "" |
| 50 | + assert_equal "$SC" 202 |
| 51 | + |
| 52 | + resource_get "$_NAMED_DEFAULTS_BASE_PATH/created" |
| 53 | + assert_equal "$SC" 200 |
| 54 | + |
| 55 | + resource_post "$_NAMED_DEFAULTS_BASE_PATH" "data/post_with_from.json" "" |
| 56 | + assert_equal "$SC" 202 |
| 57 | + |
| 58 | + resource_get "$_NAMED_DEFAULTS_BASE_PATH/created_with_from" |
| 59 | + assert_equal "$SC" 200 |
| 60 | + |
| 61 | + assert_equal "$(get_json_path "$BODY" '.data.name')" "created_with_from" |
| 62 | + assert_equal "$(get_json_path "$BODY" '.data.from')" "created" |
| 63 | + assert_equal "$(get_json_path "$BODY" '.data.server_timeout')" "20000" |
| 64 | + assert_equal "$(get_json_path "$BODY" '.data.client_timeout')" "20000" |
| 65 | + assert_equal "$(get_json_path "$BODY" '.data.mode')" "http" |
| 66 | +} |
0 commit comments