aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util/test_credentials_provider.h
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2017-01-11 11:10:43 -0800
committerGravatar yang-g <yangg@google.com>2017-01-11 11:10:43 -0800
commitcc5910228d84561d40cd8f0513faddc1e0100275 (patch)
tree930e2290e83bdaa04187ddc866982db354723801 /test/cpp/util/test_credentials_provider.h
parent3c42128a350f4e153cd3f098fa6b928addb99c58 (diff)
manual revert of #8901
Diffstat (limited to 'test/cpp/util/test_credentials_provider.h')
-rw-r--r--test/cpp/util/test_credentials_provider.h50
1 files changed, 33 insertions, 17 deletions
diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h
index 1fb311e556..0bc52ebe4d 100644
--- a/test/cpp/util/test_credentials_provider.h
+++ b/test/cpp/util/test_credentials_provider.h
@@ -59,23 +59,39 @@ class CredentialTypeProvider {
virtual std::shared_ptr<ServerCredentials> GetServerCredentials() = 0;
};
-// Add a secure type in addition to the defaults above
-// (kInsecureCredentialsType, kTlsCredentialsType) that can be returned from the
-// functions below.
-void AddSecureType(const grpc::string& type,
- std::unique_ptr<CredentialTypeProvider> type_provider);
-
-// Provide channel credentials according to the given type. Alter the channel
-// arguments if needed.
-std::shared_ptr<ChannelCredentials> GetChannelCredentials(
- const grpc::string& type, ChannelArguments* args);
-
-// Provide server credentials according to the given type.
-std::shared_ptr<ServerCredentials> GetServerCredentials(
- const grpc::string& type);
-
-// Provide a list of secure credentials type.
-std::vector<grpc::string> GetSecureCredentialsTypeList();
+// Provide test credentials. Thread-safe.
+class CredentialsProvider {
+ public:
+ virtual ~CredentialsProvider() {}
+
+ // Add a secure type in addition to the defaults. The default provider has
+ // (kInsecureCredentialsType, kTlsCredentialsType).
+ virtual void AddSecureType(
+ const grpc::string& type,
+ std::unique_ptr<CredentialTypeProvider> type_provider) = 0;
+
+ // Provide channel credentials according to the given type. Alter the channel
+ // arguments if needed. Return nullptr if type is not registered.
+ virtual std::shared_ptr<ChannelCredentials> GetChannelCredentials(
+ const grpc::string& type, ChannelArguments* args) = 0;
+
+ // Provide server credentials according to the given type.
+ // Return nullptr if type is not registered.
+ virtual std::shared_ptr<ServerCredentials> GetServerCredentials(
+ const grpc::string& type) = 0;
+
+ // Provide a list of secure credentials type.
+ virtual std::vector<grpc::string> GetSecureCredentialsTypeList() = 0;
+};
+
+// Get the current provider. Create a default one if not set.
+// Not thread-safe.
+CredentialsProvider* GetCredentialsProvider();
+
+// Set the global provider. Takes ownership. The previous set provider will be
+// destroyed.
+// Not thread-safe.
+void SetCredentialsProvider(CredentialsProvider* provider);
} // namespace testing
} // namespace grpc