Skip to content

Commit 0226e75

Browse files
committed
REORG/MAJOR: returning flat object in response
1 parent 3524234 commit 0226e75

File tree

357 files changed

+2247
-12815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

357 files changed

+2247
-12815
lines changed

e2e/libs/resource_client.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
# limitations under the License.
1616
#
1717

18+
1819
function resource_post() {
1920
local endpoint; endpoint="$1"; shift
2021
local data; data="$1"; shift
2122
local qs_params; qs_params="$1"
22-
23-
run dpa_curl POST "$endpoint?$qs_params&version=$(version)" "$data"
23+
get_version
24+
run dpa_curl POST "$endpoint?$qs_params&version=${VERSION}" "$data"
2425
assert_success
2526
dpa_curl_status_body '$output'
2627
}
@@ -29,25 +30,24 @@ function resource_put() {
2930
local endpoint; endpoint="$1"; shift
3031
local data; data="$1"; shift
3132
local qs_params; qs_params="$1"
32-
33-
run dpa_curl PUT "$endpoint?$qs_params&version=$(version)" "$data"
33+
get_version
34+
run dpa_curl PUT "$endpoint?$qs_params&version=${VERSION}" "$data"
3435
assert_success
3536
dpa_curl_status_body '$output'
3637
}
3738

3839
function resource_delete() {
3940
local endpoint; endpoint="$1"; shift
4041
local qs_params; qs_params="$1"
41-
42-
run dpa_curl DELETE "$endpoint?$qs_params&version=$(version)" "$data"
42+
get_version
43+
run dpa_curl DELETE "$endpoint?$qs_params&version=${VERSION}" "$data"
4344
assert_success
4445
dpa_curl_status_body '$output'
4546
}
4647

4748
function resource_get() {
4849
local endpoint; endpoint="$1"; shift
4950
local qs_params; qs_params="$1"
50-
5151
run dpa_curl GET "$endpoint?$qs_params"
5252
assert_success
5353
dpa_curl_status_body '$output'

e2e/libs/version.bash

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,8 @@ function deprecated_auth_curl() {
3636
echo "$status_code $response"
3737
}
3838

39-
# version return the current HAProxy configuration file version, useful to
40-
# avoid keeping track of it at each POST/PUT call.
41-
#
42-
# Any argument is required.
43-
#
44-
# Example:
45-
# version
46-
# >>> 10
47-
function version() {
48-
read -r SC RES < <(deprecated_auth_curl GET "/v3/services/haproxy/configuration/global")
49-
V="$(RES=${RES} jq -n 'env.RES | fromjson | ._version')"
50-
echo "$V"
39+
40+
function get_version() {
41+
resource_get "/services/haproxy/configuration/version"
42+
eval VERSION="'$BODY'"
5143
}

e2e/libs/version_spoe.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function deprecated_auth_curl() {
3636
echo "$status_code $response"
3737
}
3838

39-
function version() {
40-
read -r SC RES < <(deprecated_auth_curl GET "/v3/services/haproxy/spoe/version?spoe=$SPOE_FILE")
41-
echo "$RES"
39+
function get_version() {
40+
resource_get "/services/haproxy/spoe/version" "spoe=$SPOE_FILE"
41+
eval VERSION="'$BODY'"
4242
}

e2e/tests/acl_files/acl_file.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ load '../../libs/dataplaneapi'
1919
load "../../libs/get_json_path"
2020
load '../../libs/haproxy_config_setup'
2121
load '../../libs/resource_client'
22+
load '../../libs/version'
23+
2224

2325
load 'utils/_helpers'
2426

e2e/tests/acl_files/acl_file_entries.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ load "../../libs/get_json_path"
2020
load '../../libs/haproxy_config_setup'
2121
load '../../libs/resource_client'
2222
load '../../libs/haproxy_version'
23+
load '../../libs/version'
2324

2425
load 'utils/_helpers'
2526

e2e/tests/acls/add.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ load 'utils/_helpers'
3232
resource_get "$_ACL_BASE_PATH/2" "parent_name=fe_acl&parent_type=frontend"
3333
assert_equal "$SC" 200
3434

35-
assert_equal "$(get_json_path "${BODY}" ".data")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)"
35+
assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)"
3636
}

e2e/tests/acls/get.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ load 'utils/_helpers'
2727
resource_get "$_ACL_BASE_PATH/2" "parent_name=fe_acl&parent_type=frontend"
2828
assert_equal "$SC" 200
2929

30-
assert_equal "$(get_json_path "$BODY" " .data.acl_name")" "local_dst"
31-
assert_equal "$(get_json_path "$BODY" " .data.criterion")" "hdr(host)"
32-
assert_equal "$(get_json_path "$BODY" " .data.index")" "2"
33-
assert_equal "$(get_json_path "$BODY" " .data.value")" "-i localhost"
30+
assert_equal "$(get_json_path "$BODY" " .acl_name")" "local_dst"
31+
assert_equal "$(get_json_path "$BODY" " .criterion")" "hdr(host)"
32+
assert_equal "$(get_json_path "$BODY" " .index")" "2"
33+
assert_equal "$(get_json_path "$BODY" " .value")" "-i localhost"
3434
}
3535

3636
@test "acls: Return an error when ACL doesn't exists at a given index" {

e2e/tests/acls/list.bats

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ load 'utils/_helpers'
2626
resource_get "$_ACL_BASE_PATH" "parent_name=fe_acl&parent_type=frontend"
2727
assert_equal $SC "200"
2828

29-
assert_equal "$(get_json_path "$BODY" " .data | .[2].acl_name" )" "local_dst"
30-
assert_equal "$(get_json_path "$BODY" " .data | .[2].criterion" )" "hdr(host)"
31-
assert_equal "$(get_json_path "$BODY" " .data | .[2].index" )" "2"
32-
assert_equal "$(get_json_path "$BODY" " .data | .[2].value" )" "-i localhost"
29+
assert_equal "$(get_json_path "$BODY" " . | .[2].acl_name" )" "local_dst"
30+
assert_equal "$(get_json_path "$BODY" " . | .[2].criterion" )" "hdr(host)"
31+
assert_equal "$(get_json_path "$BODY" " . | .[2].index" )" "2"
32+
assert_equal "$(get_json_path "$BODY" " . | .[2].value" )" "-i localhost"
3333
}
3434

3535
@test "acls: Return ACL list by its name" {
3636
resource_get "$_ACL_BASE_PATH" "parent_name=fe_acl&parent_type=frontend&acl_name=invalid_src"
3737
assert_equal "$SC" 200
3838

39-
assert_equal "$(get_json_path "$BODY" " .data | .[1].acl_name" )" "invalid_src"
40-
assert_equal "$(get_json_path "$BODY" " .data | .[1].criterion" )" "src_port"
41-
assert_equal "$(get_json_path "$BODY" " .data | .[1].index" )" "1"
42-
assert_equal "$(get_json_path "$BODY" " .data | .[1].value" )" "0:1023"
39+
assert_equal "$(get_json_path "$BODY" " . | .[1].acl_name" )" "invalid_src"
40+
assert_equal "$(get_json_path "$BODY" " . | .[1].criterion" )" "src_port"
41+
assert_equal "$(get_json_path "$BODY" " . | .[1].index" )" "1"
42+
assert_equal "$(get_json_path "$BODY" " . | .[1].value" )" "0:1023"
4343
}

e2e/tests/acls/replace.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ load 'utils/_helpers'
3232
resource_get "$_ACL_BASE_PATH/2" "parent_name=fe_acl&parent_type=frontend"
3333
assert_equal "$SC" 200
3434

35-
assert_equal "$(get_json_path "$BODY" " .data" )" "$(cat "$BATS_TEST_DIRNAME/data/put.json")"
35+
assert_equal "$(get_json_path "$BODY" " ." )" "$(cat "$BATS_TEST_DIRNAME/data/put.json")"
3636
}
3737

3838
@test "acls: Return an error when trying to replace non existing ACL" {

e2e/tests/backend_switching_rules/add.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ load 'utils/_helpers'
3030
# Checking the presence of applied backend switching rule
3131
#
3232
resource_get "$_BSR_BASE_PATH/0" "frontend=test_frontend"
33-
assert_equal "$(get_json_path "$BODY" ".data")" "$(get_json_path "$(cat $BATS_TEST_DIRNAME/data/post.json)" ".")"
33+
assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat $BATS_TEST_DIRNAME/data/post.json)" ".")"
3434
}

0 commit comments

Comments
 (0)