|
| 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 | + |
| 24 | +load 'utils/_helpers' |
| 25 | + |
| 26 | +@test "groups: Return group G1 from a userlist" { |
| 27 | + resource_get "$_GROUPS_BASE_PATH/G1" "userlist=first" |
| 28 | + assert_equal "$SC" 200 |
| 29 | + assert_equal "$(get_json_path "$BODY" ".data.name")" "G1" |
| 30 | + assert_equal "$(get_json_path "$BODY" ".data.users")" "tiger,scott" |
| 31 | +} |
| 32 | + |
| 33 | +@test "groups: Return group G2 from a userlist" { |
| 34 | + resource_get "$_GROUPS_BASE_PATH/G2" "userlist=first" |
| 35 | + assert_equal "$SC" 200 |
| 36 | + assert_equal "$(get_json_path "$BODY" ".data.name")" "G2" |
| 37 | + assert_equal "$(get_json_path "$BODY" ".data.users")" "scott" |
| 38 | +} |
| 39 | + |
| 40 | +@test "groups: Return a non existing group from a userlist" { |
| 41 | + resource_get "$_GROUPS_BASE_PATH/fake" "userlist=first" |
| 42 | + assert_equal "$SC" 404 |
| 43 | +} |
| 44 | + |
| 45 | +@test "groups: Return a non existing group from a non existing userlist" { |
| 46 | + resource_get "$_GROUPS_BASE_PATH/fake" "userlist=fake" |
| 47 | + assert_equal "$SC" 404 |
| 48 | +} |
| 49 | + |
| 50 | +@test "groups: Return group one from a userlist" { |
| 51 | + resource_get "$_GROUPS_BASE_PATH/one" "userlist=second" |
| 52 | + assert_equal "$SC" 200 |
| 53 | + assert_equal "$(get_json_path "$BODY" ".data.name")" "one" |
| 54 | + assert_equal "$(get_json_path "$BODY" ".data.users")" null |
| 55 | +} |
| 56 | + |
| 57 | +@test "groups: Return group two from a userlist" { |
| 58 | + resource_get "$_GROUPS_BASE_PATH/two" "userlist=second" |
| 59 | + assert_equal "$SC" 200 |
| 60 | + assert_equal "$(get_json_path "$BODY" ".data.name")" "two" |
| 61 | + assert_equal "$(get_json_path "$BODY" ".data.users")" null |
| 62 | +} |
| 63 | + |
| 64 | +@test "groups: Return group three from a userlist" { |
| 65 | + resource_get "$_GROUPS_BASE_PATH/three" "userlist=second" |
| 66 | + assert_equal "$SC" 200 |
| 67 | + assert_equal "$(get_json_path "$BODY" ".data.name")" "three" |
| 68 | + assert_equal "$(get_json_path "$BODY" ".data.users")" null |
| 69 | +} |
0 commit comments