Add a helper to return all the secure types

pull/5318/head
yang-g 9 years ago
parent 17197ddc71
commit 4c8aed3dba
  1. 51
      test/cpp/end2end/end2end_test.cc
  2. 6
      test/cpp/util/test_credentials_provider.cc
  3. 3
      test/cpp/util/test_credentials_provider.h

@ -1365,25 +1365,42 @@ TEST_P(SecureEnd2endTest, ClientAuthContext) {
EXPECT_EQ("*.test.youtube.com", ToString(auth_ctx->GetPeerIdentity()[2]));
}
INSTANTIATE_TEST_CASE_P(
End2end, End2endTest,
::testing::Values(TestScenario(false, kInsecureCredentialsType),
TestScenario(false, kTlsCredentialsType)));
INSTANTIATE_TEST_CASE_P(
End2endServerTryCancel, End2endServerTryCancelTest,
::testing::Values(TestScenario(false, kInsecureCredentialsType)));
INSTANTIATE_TEST_CASE_P(
ProxyEnd2end, ProxyEnd2endTest,
::testing::Values(TestScenario(false, kInsecureCredentialsType),
TestScenario(false, kTlsCredentialsType),
TestScenario(true, kInsecureCredentialsType),
TestScenario(true, kTlsCredentialsType)));
std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
bool test_insecure,
bool test_secure) {
std::vector<TestScenario> scenarios;
std::vector<grpc::string> credentials_types;
if (test_secure) {
credentials_types = GetSecureCredentialsTypeList();
}
if (test_insecure) {
credentials_types.push_back(kInsecureCredentialsType);
}
for (auto it = credentials_types.begin(); it != credentials_types.end();
++it) {
scenarios.push_back(TestScenario(false, *it));
if (use_proxy) {
scenarios.push_back(TestScenario(true, *it));
}
}
return scenarios;
}
INSTANTIATE_TEST_CASE_P(End2end, End2endTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
true)));
INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
false)));
INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(true, true,
true)));
INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest,
::testing::Values(TestScenario(false,
kTlsCredentialsType)));
::testing::ValuesIn(CreateTestScenarios(false, false,
true)));
} // namespace
} // namespace testing

@ -70,5 +70,11 @@ std::shared_ptr<ServerCredentials> GetServerCredentials(
return nullptr;
}
std::vector<grpc::string> GetSecureCredentialsTypeList() {
std::vector<grpc::string> types;
types.push_back(kTlsCredentialsType);
return types;
}
} // namespace testing
} // namespace grpc

@ -55,6 +55,9 @@ std::shared_ptr<ChannelCredentials> GetChannelCredentials(
std::shared_ptr<ServerCredentials> GetServerCredentials(
const grpc::string& type);
// Provide a list of secure credentials type.
std::vector<grpc::string> GetSecureCredentialsTypeList();
} // namespace testing
} // namespace grpc

Loading…
Cancel
Save