aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/common
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-08-07 10:17:03 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-08-07 10:17:03 -0700
commit37f24de6034e5005134f0b861d5bfda97e8f9fee (patch)
tree478ce1c6ca06f0dd8db9ffd993add0a5b5869105 /test/cpp/common
parent0ce5540a3f1528ac0c9d4b13d910a89c8cca9b90 (diff)
parent7aff4281ef3cef89dfdb8a8754a5d2e9c6b1dd00 (diff)
Merge pull request #2777 from jboeuf/server_creds_auth_md_processor
Server creds auth md processor
Diffstat (limited to 'test/cpp/common')
-rw-r--r--test/cpp/common/auth_property_iterator_test.cc17
-rw-r--r--test/cpp/common/secure_auth_context_test.cc24
2 files changed, 25 insertions, 16 deletions
diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc
index 3d983fa310..74b18ced0d 100644
--- a/test/cpp/common/auth_property_iterator_test.cc
+++ b/test/cpp/common/auth_property_iterator_test.cc
@@ -31,10 +31,14 @@
*
*/
+#include <grpc/grpc_security.h>
#include <grpc++/auth_context.h>
#include <gtest/gtest.h>
#include "src/cpp/common/secure_auth_context.h"
+
+extern "C" {
#include "src/core/security/security_context.h"
+}
namespace grpc {
namespace {
@@ -50,14 +54,15 @@ class TestAuthPropertyIterator : public AuthPropertyIterator {
class AuthPropertyIteratorTest : public ::testing::Test {
protected:
void SetUp() GRPC_OVERRIDE {
- 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;
+ ctx_ = grpc_auth_context_create(NULL);
+ grpc_auth_context_add_cstring_property(ctx_, "name", "chapi");
+ grpc_auth_context_add_cstring_property(ctx_, "name", "chapo");
+ grpc_auth_context_add_cstring_property(ctx_, "foo", "bar");
+ EXPECT_EQ(1,
+ grpc_auth_context_set_peer_identity_property_name(ctx_, "name"));
}
void TearDown() GRPC_OVERRIDE {
- GRPC_AUTH_CONTEXT_UNREF(ctx_, "AuthPropertyIteratorTest");
+ grpc_auth_context_release(ctx_);
}
grpc_auth_context* ctx_;
diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc
index d0243a5432..075d4ce8c9 100644
--- a/test/cpp/common/secure_auth_context_test.cc
+++ b/test/cpp/common/secure_auth_context_test.cc
@@ -31,10 +31,14 @@
*
*/
+#include <grpc/grpc_security.h>
#include <grpc++/auth_context.h>
#include <gtest/gtest.h>
#include "src/cpp/common/secure_auth_context.h"
+
+extern "C" {
#include "src/core/security/security_context.h"
+}
namespace grpc {
namespace {
@@ -52,11 +56,11 @@ TEST_F(SecureAuthContextTest, EmptyContext) {
}
TEST_F(SecureAuthContextTest, Properties) {
- 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;
+ grpc_auth_context* ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context_add_cstring_property(ctx, "name", "chapi");
+ grpc_auth_context_add_cstring_property(ctx, "name", "chapo");
+ grpc_auth_context_add_cstring_property(ctx, "foo", "bar");
+ EXPECT_EQ(1, grpc_auth_context_set_peer_identity_property_name(ctx, "name"));
SecureAuthContext context(ctx);
std::vector<grpc::string> peer_identity = context.GetPeerIdentity();
@@ -70,11 +74,11 @@ TEST_F(SecureAuthContextTest, Properties) {
}
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;
+ grpc_auth_context* ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context_add_cstring_property(ctx, "name", "chapi");
+ grpc_auth_context_add_cstring_property(ctx, "name", "chapo");
+ grpc_auth_context_add_cstring_property(ctx, "foo", "bar");
+ EXPECT_EQ(1, grpc_auth_context_set_peer_identity_property_name(ctx, "name"));
SecureAuthContext context(ctx);
AuthPropertyIterator iter = context.begin();