aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-07-21 12:34:38 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-07-21 12:34:38 -0700
commitd0c1e50ea91b9c4aefc7357a21daeae689d7bb48 (patch)
treecc334f1fa1c90dbb7e66a437d3d994ff9b15e3b8 /test
parentc62ce80b805837dc2246b453a4a8b76c886cb6a3 (diff)
Changing a few variable names and adding few safety conditions
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/fixtures/h2_http_proxy.c6
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.c15
2 files changed, 11 insertions, 10 deletions
diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c
index fdc8d749c6..6145892365 100644
--- a/test/core/end2end/fixtures/h2_http_proxy.c
+++ b/test/core/end2end/fixtures/h2_http_proxy.c
@@ -68,13 +68,13 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
char *proxy_uri;
/* If testing for proxy auth, add credentials to proxy uri */
- const grpc_arg *proxy_auth =
+ const grpc_arg *proxy_auth_arg =
grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
- if (proxy_auth == NULL) {
+ if (proxy_auth_arg == NULL || proxy_auth_arg->type != GRPC_ARG_STRING) {
gpr_asprintf(&proxy_uri, "http://%s",
grpc_end2end_http_proxy_get_proxy_name(ffd->proxy));
} else {
- gpr_asprintf(&proxy_uri, "http://%s@%s", proxy_auth->value.string,
+ gpr_asprintf(&proxy_uri, "http://%s@%s", proxy_auth_arg->value.string,
grpc_end2end_http_proxy_get_proxy_name(ffd->proxy));
}
gpr_setenv("http_proxy", proxy_uri);
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.c
index 266351d181..a4cfc77bcb 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.c
+++ b/test/core/end2end/fixtures/http_proxy_fixture.c
@@ -315,7 +315,8 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
char* proxy_auth_header_val,
char* expected_cred) {
- GPR_ASSERT(proxy_auth_header_val != NULL && expected_cred != NULL);
+ GPR_ASSERT(proxy_auth_header_val != NULL);
+ GPR_ASSERT(expected_cred != NULL);
if (strncmp(proxy_auth_header_val, "Basic ", 6) != 0) {
return false;
}
@@ -377,19 +378,19 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
return;
}
// If proxy auth is being used, check if the header is present and as expected
- const grpc_arg* proxy_auth = grpc_channel_args_find(
+ const grpc_arg* proxy_auth_arg = grpc_channel_args_find(
conn->proxy->channel_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
- if (proxy_auth != NULL) {
- bool auth_header_found = false;
+ if (proxy_auth_arg != NULL && proxy_auth_arg->type == GRPC_ARG_STRING) {
+ bool client_authenticated = false;
for (size_t i = 0; i < conn->http_request.hdr_count; i++) {
if (strcmp(conn->http_request.hdrs[i].key, "Proxy-Authorization") == 0) {
- auth_header_found = proxy_auth_header_matches(
+ client_authenticated = proxy_auth_header_matches(
exec_ctx, conn->http_request.hdrs[i].value,
- proxy_auth->value.string);
+ proxy_auth_arg->value.string);
break;
}
}
- if (!auth_header_found) {
+ if (!client_authenticated) {
const char* msg = "HTTP Connect could not verify authentication";
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(msg);
proxy_connection_failed(exec_ctx, conn, true /* is_client */,