|
| 1 | +#!/usr/bin/env bats |
| 2 | +# |
| 3 | +# Copyright 2025 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/debug' |
| 20 | +load '../../libs/get_json_path' |
| 21 | +load '../../libs/haproxy_version' |
| 22 | +load '../../libs/resource_client' |
| 23 | +load '../../libs/version' |
| 24 | + |
| 25 | +load 'utils/_helpers' |
| 26 | + |
| 27 | +@test "log_profile: all tests (>=3.1)" { |
| 28 | + haproxy_version_ge "3.1" || skip |
| 29 | + |
| 30 | + debug "log_profile: create a new section" |
| 31 | + resource_post "$_LOG_PROFILE_PATH" "data/new_profile.json" "force_reload=true" |
| 32 | + assert_equal "$SC" "201" |
| 33 | + |
| 34 | + debug "log_profile: get a section" |
| 35 | + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" |
| 36 | + assert_equal "$SC" "200" |
| 37 | + assert_equal "$_PROFILE_NAME" "$(get_json_path "$BODY" .name)" |
| 38 | + assert_equal "tag1" "$(get_json_path "$BODY" .log_tag)" |
| 39 | + assert_equal "enabled" "$(get_json_path "$BODY" .steps.[0].drop)" |
| 40 | + assert_equal "any" "$(get_json_path "$BODY" .steps.[2].step)" |
| 41 | + |
| 42 | + debug "log_profile: edit a section" |
| 43 | + resource_put "$_LOG_PROFILE_PATH/$_PROFILE_NAME" "data/edit_profile.json" "force_reload=true" |
| 44 | + assert_equal "$SC" "200" |
| 45 | + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" |
| 46 | + assert_equal "tag2" "$(get_json_path "$BODY" .log_tag)" |
| 47 | + assert_equal "disabled" "$(get_json_path "$BODY" .steps.[0].drop)" |
| 48 | + assert_equal 2 "$(get_json_path "$BODY" '.steps|length')" |
| 49 | + |
| 50 | + debug "log_profile: get a list of sections" |
| 51 | + resource_get "$_LOG_PROFILE_PATH" |
| 52 | + assert_equal "$SC" "200" |
| 53 | + assert_equal "$_PROFILE_NAME" "$(get_json_path "$BODY" .[0].name)" |
| 54 | + |
| 55 | + debug "log_profile: delete a section" |
| 56 | + resource_delete "$_LOG_PROFILE_PATH/$_PROFILE_NAME" "force_reload=true" |
| 57 | + assert_equal "$SC" "204" |
| 58 | + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" |
| 59 | + assert_equal "$SC" "404" |
| 60 | +} |
0 commit comments