aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-08-25 16:53:07 -0700
committerGravatar yang-g <yangg@google.com>2015-08-25 16:53:07 -0700
commitd090fe1379932d7d785fa805339110e70b96bd87 (patch)
tree12b5a0672159568f70fe68aaad711949d0c35a9b /test/cpp
parent9f8c100ea86aa439e1200d2111d22354f52351cf (diff)
auth context api change for string_ref
Diffstat (limited to 'test/cpp')
-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
3 files changed, 31 insertions, 24 deletions
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.