diff options
author | 2015-07-15 00:50:15 -0700 | |
---|---|---|
committer | 2015-07-15 00:55:30 -0700 | |
commit | 811536efce1ba1203c4cb469e455a41fdd207e86 (patch) | |
tree | 6a8f916b5c82ca1351526116d92dfea2094cd816 /test | |
parent | 1cbeeb508b033c84f73ec79756bb4f7c0227a0d0 (diff) |
auth context iterator
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/common/secure_auth_context_test.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc index a1819dc4d6..6cc271f3a7 100644 --- a/test/cpp/common/secure_auth_context_test.cc +++ b/test/cpp/common/secure_auth_context_test.cc @@ -48,6 +48,7 @@ TEST_F(SecureAuthContextTest, EmptyContext) { EXPECT_TRUE(context.GetPeerIdentityPropertyName().empty()); EXPECT_TRUE(context.FindPropertyValues("").empty()); EXPECT_TRUE(context.FindPropertyValues("whatever").empty()); + EXPECT_TRUE(context.begin() == context.end()); } TEST_F(SecureAuthContextTest, Properties) { @@ -68,6 +69,31 @@ TEST_F(SecureAuthContextTest, Properties) { EXPECT_EQ("bar", bar[0]); } +TEST_F(SecureAuthContextTest, Iterators) { + grpc_auth_context* ctx = grpc_auth_context_create(NULL, 3); + ctx->properties[0] = grpc_auth_property_init_from_cstring("name", "chapi"); + ctx->properties[1] = grpc_auth_property_init_from_cstring("name", "chapo"); + ctx->properties[2] = grpc_auth_property_init_from_cstring("foo", "bar"); + ctx->peer_identity_property_name = ctx->properties[0].name; + + SecureAuthContext context(ctx); + AuthContext::const_iterator iter = context.begin(); + EXPECT_TRUE(context.end() != iter); + AuthContext::Property p0 = *iter; + ++iter; + AuthContext::Property p1 = *iter; + iter++; + AuthContext::Property 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); + ++iter; + EXPECT_EQ(context.end(), iter); +} + } // namespace } // namespace grpc |