|
| 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/version' |
| 21 | +load '../../libs/haproxy_config_setup' |
| 22 | + |
| 23 | +@test "Refuse to delete still used ssl certificate file" { |
| 24 | + run docker cp "${BATS_TEST_DIRNAME}/mapfile_example.map" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/maps/" |
| 25 | + assert_success |
| 26 | + |
| 27 | + run dpa_curl DELETE "/services/haproxy/storage/maps/mapfile_example.map" |
| 28 | + assert_success |
| 29 | + |
| 30 | + dpa_curl_status_body_safe '$output' |
| 31 | + echo -e "$output" |
| 32 | + assert_equal $SC 409 |
| 33 | + |
| 34 | + assert dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example.map' |
| 35 | + |
| 36 | + # clean up this test |
| 37 | + assert dpa_docker_exec 'rm /etc/haproxy/maps/mapfile_example.map' |
| 38 | +} |
| 39 | + |
| 40 | +@test "Allow to delete ssl certificate file referenced in comments" { |
| 41 | + run docker cp "${BATS_TEST_DIRNAME}/mapfile_example2.map" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/maps/" |
| 42 | + assert_success |
| 43 | + |
| 44 | + run dpa_curl DELETE "/services/haproxy/storage/maps/mapfile_example2.map" |
| 45 | + assert_success |
| 46 | + |
| 47 | + dpa_curl_status_body_safe '$output' |
| 48 | + echo -e "$output" |
| 49 | + assert_equal $SC 204 |
| 50 | + |
| 51 | + refute dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example2.map' |
| 52 | + |
| 53 | + # clean up this test |
| 54 | + run dpa_docker_exec 'rm /etc/haproxy/maps/mapfile_example2.map' |
| 55 | +} |
0 commit comments