aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/http
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-02-02 09:12:11 -0800
committerGravatar GitHub <noreply@github.com>2018-02-02 09:12:11 -0800
commit4c0640ebd65f2661664f882c673707c1c5807ccd (patch)
tree4a002106829115e970939568154ed0175e337572 /test/core/http
parent0dbb00eef0e53c87dcd6958839ec0d532cdf858c (diff)
parente5b0a504167fbc6277d034709aa29ea07fa09a00 (diff)
Merge branch 'master' into gpr_review3
Diffstat (limited to 'test/core/http')
-rw-r--r--test/core/http/BUILD15
-rw-r--r--test/core/http/httpcli_test.cc17
-rw-r--r--test/core/http/httpscli_test.cc25
l---------test/core/http/python_wrapper.sh1
4 files changed, 46 insertions, 12 deletions
diff --git a/test/core/http/BUILD b/test/core/http/BUILD
index a5ae6272db..03b8f4edfe 100644
--- a/test/core/http/BUILD
+++ b/test/core/http/BUILD
@@ -66,7 +66,12 @@ grpc_cc_test(
name = "httpcli_test",
srcs = ["httpcli_test.cc"],
language = "C++",
- data = ["test_server.py"],
+ data = [
+ "python_wrapper.sh",
+ "test_server.py",
+ "//src/core/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:server1.key"
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -80,7 +85,13 @@ grpc_cc_test(
name = "httpscli_test",
srcs = ["httpscli_test.cc"],
language = "C++",
- data = ["test_server.py"],
+ data = [
+ "python_wrapper.sh",
+ "test_server.py",
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:server1.key"
+ ],
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index aa9416c3dd..3d892b939c 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -155,10 +155,17 @@ int main(int argc, char** argv) {
int arg_shift = 0;
/* figure out where we are */
char* root;
- if (lslash) {
- root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1)));
+ if (lslash != nullptr) {
+ /* Hack for bazel target */
+ if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
+ sizeof("http") - 1) == 0) {
+ lslash = me + (lslash - me) - sizeof("http");
+ }
+ root = static_cast<char*>(
+ gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
memcpy(root, me, (size_t)(lslash - me));
- root[lslash - me] = 0;
+ memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
} else {
root = gpr_strdup(".");
}
@@ -168,8 +175,8 @@ int main(int argc, char** argv) {
args[0] = gpr_strdup(argv[1]);
} else {
arg_shift = 1;
- gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
- gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
+ gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root);
+ gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root);
}
/* start the server */
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index ed2016e643..7e99ad4249 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -21,11 +21,13 @@
#include <string.h>
#include <grpc/grpc.h>
+#include <grpc/grpc_security_constants.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/port.h"
#include "test/core/util/subprocess.h"
@@ -153,10 +155,17 @@ int main(int argc, char** argv) {
int arg_shift = 0;
/* figure out where we are */
char* root;
- if (lslash) {
- root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1)));
+ if (lslash != nullptr) {
+ /* Hack for bazel target */
+ if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
+ sizeof("http") - 1) == 0) {
+ lslash = me + (lslash - me) - sizeof("http");
+ }
+ root = static_cast<char*>(
+ gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
memcpy(root, me, (size_t)(lslash - me));
- root[lslash - me] = 0;
+ memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
} else {
root = gpr_strdup(".");
}
@@ -166,10 +175,16 @@ int main(int argc, char** argv) {
args[0] = gpr_strdup(argv[1]);
} else {
arg_shift = 1;
- gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
- gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
+ gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root);
+ gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root);
}
+ /* Set the environment variable for the SSL certificate file */
+ char* pem_file;
+ gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root);
+ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file);
+ gpr_free(pem_file);
+
/* start the server */
args[1 + arg_shift] = const_cast<char*>("--port");
gpr_asprintf(&args[2 + arg_shift], "%d", port);
diff --git a/test/core/http/python_wrapper.sh b/test/core/http/python_wrapper.sh
new file mode 120000
index 0000000000..9ed6e3293f
--- /dev/null
+++ b/test/core/http/python_wrapper.sh
@@ -0,0 +1 @@
+../../../tools/distrib/python_wrapper.sh \ No newline at end of file