|
| 1 | +#!/usr/bin/env bats |
| 2 | +# |
| 3 | +# Copyright 2021 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/haproxy_config_setup' |
| 20 | +load '../../libs/resource_client' |
| 21 | +load '../../libs/version' |
| 22 | +load '../../libs/haproxy_version' |
| 23 | + |
| 24 | +load 'utils/_helpers' |
| 25 | + |
| 26 | +@test "tcp_checks: Add a new connect TCP check to a backend" { |
| 27 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/connect.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 28 | + assert_equal "$SC" 201 |
| 29 | +} |
| 30 | + |
| 31 | +@test "tcp_checks: Add a new send TCP check to a backend" { |
| 32 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/send.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 33 | + assert_equal "$SC" 201 |
| 34 | +} |
| 35 | + |
| 36 | +@test "tcp_checks: Add a new expect TCP check to a backend" { |
| 37 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/expect.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 38 | + assert_equal "$SC" 201 |
| 39 | +} |
| 40 | + |
| 41 | +@test "tcp_checks: Add a new send-binary TCP check to a backend" { |
| 42 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/send_binary.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 43 | + assert_equal "$SC" 201 |
| 44 | +} |
| 45 | + |
| 46 | +@test "tcp_checks: Add a new comment TCP check to a backend" { |
| 47 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/comment.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 48 | + if haproxy_version_ge "2.2" |
| 49 | + then |
| 50 | + assert_equal "$SC" 201 |
| 51 | + else |
| 52 | + assert_equal "$SC" 400 |
| 53 | + fi |
| 54 | +} |
| 55 | + |
| 56 | +@test "tcp_checks: Add a new send-lf TCP check to a backend" { |
| 57 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/send_lf.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 58 | + if haproxy_version_ge "2.2" |
| 59 | + then |
| 60 | + assert_equal "$SC" 201 |
| 61 | + else |
| 62 | + assert_equal "$SC" 400 |
| 63 | + fi |
| 64 | +} |
| 65 | + |
| 66 | +@test "tcp_checks: Add a new send-binary-lf TCP check to a backend" { |
| 67 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/send_binary_lf.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 68 | + if haproxy_version_ge "2.2" |
| 69 | + then |
| 70 | + assert_equal "$SC" 201 |
| 71 | + else |
| 72 | + assert_equal "$SC" 400 |
| 73 | + fi |
| 74 | +} |
| 75 | + |
| 76 | +# @test "tcp_checks: Add a new set-var and uset-var TCP check to a backend" { |
| 77 | +# resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/set_var.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 78 | +# if haproxy_version_ge "2.2" |
| 79 | +# then |
| 80 | +# assert_equal "$SC" 201 |
| 81 | +# else |
| 82 | +# assert_equal "$SC" 400 |
| 83 | +# fi |
| 84 | +# resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/unset_var.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 85 | +# if haproxy_version_ge "2.2" |
| 86 | +# then |
| 87 | +# assert_equal "$SC" 201 |
| 88 | +# else |
| 89 | +# assert_equal "$SC" 400 |
| 90 | +# fi |
| 91 | +# } |
| 92 | + |
| 93 | +@test "tcp_checks: Add an empty TCP check to a backend" { |
| 94 | + resource_post "$_TCP_CHECKS_CERTS_BASE_PATH" "data/empty.json" "parent_type=backend&parent_name=test_backend_add&force_reload=true" |
| 95 | + if haproxy_version_ge "2.2" |
| 96 | + then |
| 97 | + assert_equal "$SC" 422 |
| 98 | + else |
| 99 | + assert_equal "$SC" 422 |
| 100 | + fi |
| 101 | +} |
0 commit comments