|
| 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/get_json_path' |
| 20 | +load '../../libs/haproxy_config_setup' |
| 21 | +load '../../libs/resource_client' |
| 22 | +load '../../libs/version' |
| 23 | +load '../../libs/haproxy_version' |
| 24 | + |
| 25 | +load 'utils/_helpers' |
| 26 | + |
| 27 | +@test "http_request_rules: Return one track-sc HTTP Request Rule from frontend" { |
| 28 | + if haproxy_version_ge "2.8" |
| 29 | + then |
| 30 | + resource_get "$_REQ_RULES_BASE_PATH/0" "parent_type=frontend&parent_name=test_sticksc" |
| 31 | + assert_equal "$SC" 200 |
| 32 | + assert_equal "$(get_json_path "$BODY" ".data.type")" "track-sc" |
| 33 | + assert_equal "$(get_json_path "$BODY" ".data.cond")" "if" |
| 34 | + assert_equal "$(get_json_path "$BODY" ".data.cond_test")" "TRUE" |
| 35 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_key")" "src" |
| 36 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_table")" "test_sticksc" |
| 37 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_stick_counter")" 0 |
| 38 | + |
| 39 | + resource_get "$_REQ_RULES_BASE_PATH/1" "parent_type=frontend&parent_name=test_sticksc" |
| 40 | + assert_equal "$SC" 200 |
| 41 | + assert_equal "$(get_json_path "$BODY" ".data.type")" "track-sc" |
| 42 | + assert_equal "$(get_json_path "$BODY" ".data.cond")" "if" |
| 43 | + assert_equal "$(get_json_path "$BODY" ".data.cond_test")" "TRUE" |
| 44 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_key")" "src" |
| 45 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_table")" "test_sticksc" |
| 46 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_stick_counter")" 5 |
| 47 | + fi |
| 48 | +} |
| 49 | + |
| 50 | +@test "http_request_rules: Return one track-sc HTTP Request Rule from backend" { |
| 51 | + if haproxy_version_ge "2.8" |
| 52 | + then |
| 53 | + resource_get "$_REQ_RULES_BASE_PATH/0" "parent_type=backend&parent_name=test_sticksc" |
| 54 | + assert_equal "$SC" 200 |
| 55 | + assert_equal "$(get_json_path "$BODY" ".data.type")" "track-sc" |
| 56 | + assert_equal "$(get_json_path "$BODY" ".data.cond")" "if" |
| 57 | + assert_equal "$(get_json_path "$BODY" ".data.cond_test")" "TRUE" |
| 58 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_key")" "src" |
| 59 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_table")" "test_sticksc" |
| 60 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_stick_counter")" 0 |
| 61 | + |
| 62 | + resource_get "$_REQ_RULES_BASE_PATH/1" "parent_type=backend&parent_name=test_sticksc" |
| 63 | + assert_equal "$SC" 200 |
| 64 | + assert_equal "$(get_json_path "$BODY" ".data.type")" "track-sc" |
| 65 | + assert_equal "$(get_json_path "$BODY" ".data.cond")" "if" |
| 66 | + assert_equal "$(get_json_path "$BODY" ".data.cond_test")" "TRUE" |
| 67 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_key")" "src" |
| 68 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_table")" "test_sticksc" |
| 69 | + assert_equal "$(get_json_path "$BODY" ".data.track_sc_stick_counter")" 5 |
| 70 | + fi |
| 71 | +} |
0 commit comments