aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--build.json6
-rw-r--r--include/grpc++/support/auth_context.h7
-rw-r--r--src/cpp/common/auth_property_iterator.cc6
-rw-r--r--src/cpp/common/secure_auth_context.cc17
-rw-r--r--src/cpp/common/secure_auth_context.h6
-rw-r--r--test/cpp/common/auth_property_iterator_test.cc15
-rw-r--r--test/cpp/common/secure_auth_context_test.cc25
-rw-r--r--test/cpp/end2end/end2end_test.cc15
-rw-r--r--tools/run_tests/sources_and_headers.json10
-rw-r--r--vsprojects/Grpc.mak8
11 files changed, 74 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index 77cb62086b..e872da981b 100644
--- a/Makefile
+++ b/Makefile
@@ -8945,16 +8945,16 @@ $(BINDIR)/$(CONFIG)/auth_property_iterator_test: protobuf_dep_error
else
-$(BINDIR)/$(CONFIG)/auth_property_iterator_test: $(PROTOBUF_DEP) $(AUTH_PROPERTY_ITERATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/auth_property_iterator_test: $(PROTOBUF_DEP) $(AUTH_PROPERTY_ITERATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LDXX) $(LDFLAGS) $(AUTH_PROPERTY_ITERATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/auth_property_iterator_test
+ $(Q) $(LDXX) $(LDFLAGS) $(AUTH_PROPERTY_ITERATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/auth_property_iterator_test
endif
endif
-$(OBJDIR)/$(CONFIG)/test/cpp/common/auth_property_iterator_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/cpp/common/auth_property_iterator_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_auth_property_iterator_test: $(AUTH_PROPERTY_ITERATOR_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
@@ -10155,16 +10155,16 @@ $(BINDIR)/$(CONFIG)/secure_auth_context_test: protobuf_dep_error
else
-$(BINDIR)/$(CONFIG)/secure_auth_context_test: $(PROTOBUF_DEP) $(SECURE_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/secure_auth_context_test: $(PROTOBUF_DEP) $(SECURE_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LDXX) $(LDFLAGS) $(SECURE_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/secure_auth_context_test
+ $(Q) $(LDXX) $(LDFLAGS) $(SECURE_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/secure_auth_context_test
endif
endif
-$(OBJDIR)/$(CONFIG)/test/cpp/common/secure_auth_context_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/cpp/common/secure_auth_context_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_secure_auth_context_test: $(SECURE_AUTH_CONTEXT_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
diff --git a/build.json b/build.json
index c974250d7c..56f14c6590 100644
--- a/build.json
+++ b/build.json
@@ -2020,8 +2020,11 @@
"test/cpp/common/auth_property_iterator_test.cc"
],
"deps": [
+ "grpc++_test_util",
+ "grpc_test_util",
"grpc++",
"grpc",
+ "gpr_test_util",
"gpr"
]
},
@@ -2572,8 +2575,11 @@
"test/cpp/common/secure_auth_context_test.cc"
],
"deps": [
+ "grpc++_test_util",
+ "grpc_test_util",
"grpc++",
"grpc",
+ "gpr_test_util",
"gpr"
]
},
diff --git a/include/grpc++/support/auth_context.h b/include/grpc++/support/auth_context.h
index f4f2dcf5bb..67e3e66c05 100644
--- a/include/grpc++/support/auth_context.h
+++ b/include/grpc++/support/auth_context.h
@@ -38,6 +38,7 @@
#include <vector>
#include <grpc++/support/config.h>
+#include <grpc++/support/string_ref.h>
struct grpc_auth_context;
struct grpc_auth_property;
@@ -46,7 +47,7 @@ struct grpc_auth_property_iterator;
namespace grpc {
class SecureAuthContext;
-typedef std::pair<grpc::string, grpc::string> AuthProperty;
+typedef std::pair<grpc::string_ref, grpc::string_ref> AuthProperty;
class AuthPropertyIterator
: public std::iterator<std::input_iterator_tag, const AuthProperty> {
@@ -78,11 +79,11 @@ class AuthContext {
// A peer identity, in general is one or more properties (in which case they
// have the same name).
- virtual std::vector<grpc::string> GetPeerIdentity() const = 0;
+ virtual std::vector<grpc::string_ref> GetPeerIdentity() const = 0;
virtual grpc::string GetPeerIdentityPropertyName() const = 0;
// Returns all the property values with the given name.
- virtual std::vector<grpc::string> FindPropertyValues(
+ virtual std::vector<grpc::string_ref> FindPropertyValues(
const grpc::string& name) const = 0;
// Iteration over all the properties.
diff --git a/src/cpp/common/auth_property_iterator.cc b/src/cpp/common/auth_property_iterator.cc
index 5ccf8cf72c..fa6da9d7a8 100644
--- a/src/cpp/common/auth_property_iterator.cc
+++ b/src/cpp/common/auth_property_iterator.cc
@@ -77,9 +77,9 @@ bool AuthPropertyIterator::operator!=(const AuthPropertyIterator& rhs) const {
}
const AuthProperty AuthPropertyIterator::operator*() {
- return std::make_pair<grpc::string, grpc::string>(
- grpc::string(property_->name),
- grpc::string(property_->value, property_->value_length));
+ return std::pair<grpc::string_ref, grpc::string_ref>(
+ property_->name,
+ grpc::string_ref(property_->value, property_->value_length));
}
} // namespace grpc
diff --git a/src/cpp/common/secure_auth_context.cc b/src/cpp/common/secure_auth_context.cc
index 87d7bab75c..b18a8537c9 100644
--- a/src/cpp/common/secure_auth_context.cc
+++ b/src/cpp/common/secure_auth_context.cc
@@ -41,15 +41,16 @@ SecureAuthContext::SecureAuthContext(grpc_auth_context* ctx) : ctx_(ctx) {}
SecureAuthContext::~SecureAuthContext() { grpc_auth_context_release(ctx_); }
-std::vector<grpc::string> SecureAuthContext::GetPeerIdentity() const {
+std::vector<grpc::string_ref> SecureAuthContext::GetPeerIdentity() const {
if (!ctx_) {
- return std::vector<grpc::string>();
+ return std::vector<grpc::string_ref>();
}
grpc_auth_property_iterator iter = grpc_auth_context_peer_identity(ctx_);
- std::vector<grpc::string> identity;
+ std::vector<grpc::string_ref> identity;
const grpc_auth_property* property = nullptr;
while ((property = grpc_auth_property_iterator_next(&iter))) {
- identity.push_back(grpc::string(property->value, property->value_length));
+ identity.push_back(
+ grpc::string_ref(property->value, property->value_length));
}
return identity;
}
@@ -62,17 +63,17 @@ grpc::string SecureAuthContext::GetPeerIdentityPropertyName() const {
return name == nullptr ? "" : name;
}
-std::vector<grpc::string> SecureAuthContext::FindPropertyValues(
+std::vector<grpc::string_ref> SecureAuthContext::FindPropertyValues(
const grpc::string& name) const {
if (!ctx_) {
- return std::vector<grpc::string>();
+ return std::vector<grpc::string_ref>();
}
grpc_auth_property_iterator iter =
grpc_auth_context_find_properties_by_name(ctx_, name.c_str());
const grpc_auth_property* property = nullptr;
- std::vector<grpc::string> values;
+ std::vector<grpc::string_ref> values;
while ((property = grpc_auth_property_iterator_next(&iter))) {
- values.push_back(grpc::string(property->value, property->value_length));
+ values.push_back(grpc::string_ref(property->value, property->value_length));
}
return values;
}
diff --git a/src/cpp/common/secure_auth_context.h b/src/cpp/common/secure_auth_context.h
index 01b7126189..7f622b890b 100644
--- a/src/cpp/common/secure_auth_context.h
+++ b/src/cpp/common/secure_auth_context.h
@@ -46,12 +46,12 @@ class SecureAuthContext GRPC_FINAL : public AuthContext {
~SecureAuthContext() GRPC_OVERRIDE;
- std::vector<grpc::string> GetPeerIdentity() const GRPC_OVERRIDE;
+ std::vector<grpc::string_ref> GetPeerIdentity() const GRPC_OVERRIDE;
grpc::string GetPeerIdentityPropertyName() const GRPC_OVERRIDE;
- std::vector<grpc::string> FindPropertyValues(const grpc::string& name) const
- GRPC_OVERRIDE;
+ std::vector<grpc::string_ref> FindPropertyValues(
+ const grpc::string& name) const GRPC_OVERRIDE;
AuthPropertyIterator begin() const GRPC_OVERRIDE;
diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc
index 630c38c7f6..e6226d6a09 100644
--- a/test/cpp/common/auth_property_iterator_test.cc
+++ b/test/cpp/common/auth_property_iterator_test.cc
@@ -35,11 +35,14 @@
#include <grpc++/support/auth_context.h>
#include <gtest/gtest.h>
#include "src/cpp/common/secure_auth_context.h"
+#include "test/cpp/util/string_ref_helper.h"
extern "C" {
#include "src/core/security/security_context.h"
}
+using ::grpc::testing::ToString;
+
namespace grpc {
namespace {
@@ -84,12 +87,12 @@ TEST_F(AuthPropertyIteratorTest, GeneralTest) {
AuthProperty p1 = *iter;
iter++;
AuthProperty p2 = *iter;
- EXPECT_EQ("name", p0.first);
- EXPECT_EQ("chapi", p0.second);
- EXPECT_EQ("name", p1.first);
- EXPECT_EQ("chapo", p1.second);
- EXPECT_EQ("foo", p2.first);
- EXPECT_EQ("bar", p2.second);
+ EXPECT_EQ("name", ToString(p0.first));
+ EXPECT_EQ("chapi", ToString(p0.second));
+ EXPECT_EQ("name", ToString(p1.first));
+ EXPECT_EQ("chapo", ToString(p1.second));
+ EXPECT_EQ("foo", ToString(p2.first));
+ EXPECT_EQ("bar", ToString(p2.second));
++iter;
EXPECT_EQ(empty_iter, iter);
}
diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc
index c71ef58023..25538c1853 100644
--- a/test/cpp/common/secure_auth_context_test.cc
+++ b/test/cpp/common/secure_auth_context_test.cc
@@ -35,11 +35,14 @@
#include <grpc++/support/auth_context.h>
#include <gtest/gtest.h>
#include "src/cpp/common/secure_auth_context.h"
+#include "test/cpp/util/string_ref_helper.h"
extern "C" {
#include "src/core/security/security_context.h"
}
+using grpc::testing::ToString;
+
namespace grpc {
namespace {
@@ -63,14 +66,14 @@ TEST_F(SecureAuthContextTest, Properties) {
EXPECT_EQ(1, grpc_auth_context_set_peer_identity_property_name(ctx, "name"));
SecureAuthContext context(ctx);
- std::vector<grpc::string> peer_identity = context.GetPeerIdentity();
+ std::vector<grpc::string_ref> peer_identity = context.GetPeerIdentity();
EXPECT_EQ(2u, peer_identity.size());
- EXPECT_EQ("chapi", peer_identity[0]);
- EXPECT_EQ("chapo", peer_identity[1]);
+ EXPECT_EQ("chapi", ToString(peer_identity[0]));
+ EXPECT_EQ("chapo", ToString(peer_identity[1]));
EXPECT_EQ("name", context.GetPeerIdentityPropertyName());
- std::vector<grpc::string> bar = context.FindPropertyValues("foo");
+ std::vector<grpc::string_ref> bar = context.FindPropertyValues("foo");
EXPECT_EQ(1u, bar.size());
- EXPECT_EQ("bar", bar[0]);
+ EXPECT_EQ("bar", ToString(bar[0]));
}
TEST_F(SecureAuthContextTest, Iterators) {
@@ -88,12 +91,12 @@ TEST_F(SecureAuthContextTest, Iterators) {
AuthProperty p1 = *iter;
iter++;
AuthProperty p2 = *iter;
- EXPECT_EQ("name", p0.first);
- EXPECT_EQ("chapi", p0.second);
- EXPECT_EQ("name", p1.first);
- EXPECT_EQ("chapo", p1.second);
- EXPECT_EQ("foo", p2.first);
- EXPECT_EQ("bar", p2.second);
+ EXPECT_EQ("name", ToString(p0.first));
+ EXPECT_EQ("chapi", ToString(p0.second));
+ EXPECT_EQ("name", ToString(p1.first));
+ EXPECT_EQ("chapo", ToString(p1.second));
+ EXPECT_EQ("foo", ToString(p2.first));
+ EXPECT_EQ("bar", ToString(p2.second));
++iter;
EXPECT_EQ(context.end(), iter);
}
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 0d5bf36df7..9826837c60 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -81,10 +81,10 @@ void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
void CheckServerAuthContext(const ServerContext* context) {
std::shared_ptr<const AuthContext> auth_ctx = context->auth_context();
- std::vector<grpc::string> ssl =
+ std::vector<grpc::string_ref> ssl =
auth_ctx->FindPropertyValues("transport_security_type");
EXPECT_EQ(1u, ssl.size());
- EXPECT_EQ("ssl", ssl[0]);
+ EXPECT_EQ("ssl", ToString(ssl[0]));
EXPECT_TRUE(auth_ctx->GetPeerIdentityPropertyName().empty());
EXPECT_TRUE(auth_ctx->GetPeerIdentity().empty());
}
@@ -840,16 +840,17 @@ TEST_F(End2endTest, ClientAuthContext) {
EXPECT_TRUE(s.ok());
std::shared_ptr<const AuthContext> auth_ctx = context.auth_context();
- std::vector<grpc::string> ssl =
+ std::vector<grpc::string_ref> ssl =
auth_ctx->FindPropertyValues("transport_security_type");
EXPECT_EQ(1u, ssl.size());
- EXPECT_EQ("ssl", ssl[0]);
+ EXPECT_EQ("ssl", ToString(ssl[0]));
EXPECT_EQ("x509_subject_alternative_name",
auth_ctx->GetPeerIdentityPropertyName());
EXPECT_EQ(3u, auth_ctx->GetPeerIdentity().size());
- EXPECT_EQ("*.test.google.fr", auth_ctx->GetPeerIdentity()[0]);
- EXPECT_EQ("waterzooi.test.google.be", auth_ctx->GetPeerIdentity()[1]);
- EXPECT_EQ("*.test.youtube.com", auth_ctx->GetPeerIdentity()[2]);
+ EXPECT_EQ("*.test.google.fr", ToString(auth_ctx->GetPeerIdentity()[0]));
+ EXPECT_EQ("waterzooi.test.google.be",
+ ToString(auth_ctx->GetPeerIdentity()[1]));
+ EXPECT_EQ("*.test.youtube.com", ToString(auth_ctx->GetPeerIdentity()[2]));
}
// Make the response larger than the flow control window.
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index a89e5340ed..5facf582ce 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -1068,8 +1068,11 @@
{
"deps": [
"gpr",
+ "gpr_test_util",
"grpc",
- "grpc++"
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
],
"headers": [],
"language": "c++",
@@ -1573,8 +1576,11 @@
{
"deps": [
"gpr",
+ "gpr_test_util",
"grpc",
- "grpc++"
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
],
"headers": [],
"language": "c++",
diff --git a/vsprojects/Grpc.mak b/vsprojects/Grpc.mak
index 19cb39741e..ad390e7cda 100644
--- a/vsprojects/Grpc.mak
+++ b/vsprojects/Grpc.mak
@@ -615,10 +615,10 @@ async_end2end_test: async_end2end_test.exe
echo Running async_end2end_test
$(OUT_DIR)\async_end2end_test.exe
-auth_property_iterator_test.exe: build_grpc++ build_grpc build_gpr $(OUT_DIR)
+auth_property_iterator_test.exe: Debug\grpc++_test_util.lib build_grpc_test_util build_grpc++ build_grpc build_gpr_test_util build_gpr $(OUT_DIR)
echo Building auth_property_iterator_test
$(CC) $(CXXFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\test\cpp\common\auth_property_iterator_test.cc
- $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\auth_property_iterator_test.exe" Debug\grpc++.lib Debug\grpc.lib Debug\gpr.lib $(CXX_LIBS) $(LIBS) $(OUT_DIR)\auth_property_iterator_test.obj
+ $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\auth_property_iterator_test.exe" Debug\grpc++_test_util.lib Debug\grpc_test_util.lib Debug\grpc++.lib Debug\grpc.lib Debug\gpr_test_util.lib Debug\gpr.lib $(CXX_LIBS) $(LIBS) $(OUT_DIR)\auth_property_iterator_test.obj
auth_property_iterator_test: auth_property_iterator_test.exe
echo Running auth_property_iterator_test
$(OUT_DIR)\auth_property_iterator_test.exe
@@ -751,10 +751,10 @@ reconnect_interop_server: reconnect_interop_server.exe
echo Running reconnect_interop_server
$(OUT_DIR)\reconnect_interop_server.exe
-secure_auth_context_test.exe: build_grpc++ build_grpc build_gpr $(OUT_DIR)
+secure_auth_context_test.exe: Debug\grpc++_test_util.lib build_grpc_test_util build_grpc++ build_grpc build_gpr_test_util build_gpr $(OUT_DIR)
echo Building secure_auth_context_test
$(CC) $(CXXFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\test\cpp\common\secure_auth_context_test.cc
- $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\secure_auth_context_test.exe" Debug\grpc++.lib Debug\grpc.lib Debug\gpr.lib $(CXX_LIBS) $(LIBS) $(OUT_DIR)\secure_auth_context_test.obj
+ $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\secure_auth_context_test.exe" Debug\grpc++_test_util.lib Debug\grpc_test_util.lib Debug\grpc++.lib Debug\grpc.lib Debug\gpr_test_util.lib Debug\gpr.lib $(CXX_LIBS) $(LIBS) $(OUT_DIR)\secure_auth_context_test.obj
secure_auth_context_test: secure_auth_context_test.exe
echo Running secure_auth_context_test
$(OUT_DIR)\secure_auth_context_test.exe