@@ -110,7 +110,6 @@ function assert_proxy_presents_cert_uri {
110
110
local DC=${3:- primary}
111
111
local NS=${4:- default}
112
112
113
-
114
113
CERT=$( retry_default get_cert $HOSTPORT )
115
114
116
115
echo " WANT SERVICE: ${NS} /${SERVICENAME} "
@@ -153,36 +152,48 @@ function assert_envoy_version {
153
152
echo $VERSION | grep " /$ENVOY_VERSION /"
154
153
}
155
154
155
+ function assert_envoy_http_rbac_policy_count {
156
+ local HOSTPORT=$1
157
+ local EXPECT_COUNT=$2
158
+
159
+ GOT_COUNT=$( get_envoy_http_rbac_once $HOSTPORT | jq ' .rules.policies | length' )
160
+ [ " ${GOT_COUNT:- 0} " -eq $EXPECT_COUNT ]
161
+ }
162
+
163
+ function get_envoy_http_rbac_once {
164
+ local HOSTPORT=$1
165
+ run curl -s -f $HOSTPORT /config_dump
166
+ [ " $status " -eq 0 ]
167
+ echo " $output " | jq --raw-output ' .configs[2].dynamic_listeners[].active_state.listener.filter_chains[0].filters[0].config.http_filters[] | select(.name == "envoy.filters.http.rbac") | .config'
168
+ }
169
+
170
+ function assert_envoy_network_rbac_policy_count {
171
+ local HOSTPORT=$1
172
+ local EXPECT_COUNT=$2
173
+
174
+ GOT_COUNT=$( get_envoy_network_rbac_once $HOSTPORT | jq ' .rules.policies | length' )
175
+ [ " ${GOT_COUNT:- 0} " -eq $EXPECT_COUNT ]
176
+ }
177
+
178
+ function get_envoy_network_rbac_once {
179
+ local HOSTPORT=$1
180
+ run curl -s -f $HOSTPORT /config_dump
181
+ [ " $status " -eq 0 ]
182
+ echo " $output " | jq --raw-output ' .configs[2].dynamic_listeners[].active_state.listener.filter_chains[0].filters[] | select(.name == "envoy.filters.network.rbac") | .config'
183
+ }
184
+
156
185
function get_envoy_listener_filters {
157
186
local HOSTPORT=$1
158
187
run retry_default curl -s -f $HOSTPORT /config_dump
159
188
[ " $status " -eq 0 ]
160
- local ENVOY_VERSION=$( echo $output | jq --raw-output ' .configs[0].bootstrap.node.metadata.envoy_version' )
161
- local QUERY=' '
162
- # from 1.13.0 on the config json looks slightly different
163
- # 1.10.x, 1.11.x, 1.12.x are not affected
164
- if [[ " $ENVOY_VERSION " =~ ^1\. 1[012]\. ]]; then
165
- QUERY=' .configs[2].dynamic_active_listeners[].listener | "\(.name) \( .filter_chains[0].filters | map(.name) | join(","))"'
166
- else
167
- QUERY=' .configs[2].dynamic_listeners[].active_state.listener | "\(.name) \( .filter_chains[0].filters | map(.name) | join(","))"'
168
- fi
169
- echo " $output " | jq --raw-output " $QUERY "
189
+ echo " $output " | jq --raw-output ' .configs[2].dynamic_listeners[].active_state.listener | "\(.name) \( .filter_chains[0].filters | map(.name) | join(","))"'
170
190
}
171
191
172
192
function get_envoy_http_filters {
173
193
local HOSTPORT=$1
174
194
run retry_default curl -s -f $HOSTPORT /config_dump
175
195
[ " $status " -eq 0 ]
176
- local ENVOY_VERSION=$( echo $output | jq --raw-output ' .configs[0].bootstrap.node.metadata.envoy_version' )
177
- local QUERY=' '
178
- # from 1.13.0 on the config json looks slightly different
179
- # 1.10.x, 1.11.x, 1.12.x are not affected
180
- if [[ " $ENVOY_VERSION " =~ ^1\. 1[012]\. ]]; then
181
- QUERY=' .configs[2].dynamic_active_listeners[].listener | "\(.name) \( .filter_chains[0].filters[] | select(.name == "envoy.http_connection_manager") | .config.http_filters | map(.name) | join(","))"'
182
- else
183
- QUERY=' .configs[2].dynamic_listeners[].active_state.listener | "\(.name) \( .filter_chains[0].filters[] | select(.name == "envoy.http_connection_manager") | .config.http_filters | map(.name) | join(","))"'
184
- fi
185
- echo " $output " | jq --raw-output " $QUERY "
196
+ echo " $output " | jq --raw-output ' .configs[2].dynamic_listeners[].active_state.listener | "\(.name) \( .filter_chains[0].filters[] | select(.name == "envoy.http_connection_manager") | .config.http_filters | map(.name) | join(","))"'
186
197
}
187
198
188
199
function get_envoy_cluster_config {
@@ -241,7 +252,7 @@ function get_upstream_endpoint_in_status_count {
241
252
local HOSTPORT=$1
242
253
local CLUSTER_NAME=$2
243
254
local HEALTH_STATUS=$3
244
- run retry_default curl -s -f " http://${HOSTPORT} /clusters?format=json"
255
+ run curl -s -f " http://${HOSTPORT} /clusters?format=json"
245
256
[ " $status " -eq 0 ]
246
257
# echo "$output" >&3
247
258
echo " $output " | jq --raw-output "
@@ -364,7 +375,7 @@ function get_healthy_service_count {
364
375
local DC=$2
365
376
local NS=$3
366
377
367
- run retry_default curl -s -f ${HEADERS} " 127.0.0.1:8500/v1/health/connect/${SERVICE_NAME} ?dc=${DC} &passing&ns=${NS} "
378
+ run curl -s -f ${HEADERS} " 127.0.0.1:8500/v1/health/connect/${SERVICE_NAME} ?dc=${DC} &passing&ns=${NS} "
368
379
[ " $status " -eq 0 ]
369
380
echo " $output " | jq --raw-output ' . | length'
370
381
}
@@ -549,6 +560,8 @@ function must_fail_http_connection {
549
560
550
561
echo " OUTPUT $output "
551
562
563
+ [ " $status " == " 0" ]
564
+
552
565
local expect_response=" ${2:- 403 Forbidden} "
553
566
# Should fail request with 503
554
567
echo " $output " | grep " ${expect_response} "
0 commit comments