use nullptr for cert providers in tests

pull/34861/head
Luwei Ge 1 year ago
parent fe4a121a05
commit e2d56d6530
  1. 28
      test/cpp/server/credentials_test.cc

@ -277,34 +277,18 @@ TEST(CredentialsTest, MultipleServerCredentialsOneCrlProviderDoesNotLeak) {
EXPECT_NE(server_creds_2, nullptr); EXPECT_NE(server_creds_2, nullptr);
} }
TEST( TEST(CredentialsTest, TlsServerCredentialsWithGoodMinMaxTlsVersions) {
CredentialsTest, grpc::experimental::TlsServerCredentialsOptions options(
TlsChannelCredentialsWithStaticDataCertificateProviderAndGoodMinMaxTlsVersions) { /*certificate_provider=*/nullptr);
experimental::IdentityKeyCertPair key_cert_pair;
key_cert_pair.private_key = kIdentityCertPrivateKey;
key_cert_pair.certificate_chain = kIdentityCertContents;
std::vector<experimental::IdentityKeyCertPair> identity_key_cert_pairs;
identity_key_cert_pairs.emplace_back(key_cert_pair);
auto certificate_provider = std::make_shared<StaticDataCertificateProvider>(
kRootCertContents, identity_key_cert_pairs);
grpc::experimental::TlsServerCredentialsOptions options(certificate_provider);
options.set_min_tls_version(grpc_tls_version::TLS1_2); options.set_min_tls_version(grpc_tls_version::TLS1_2);
options.set_max_tls_version(grpc_tls_version::TLS1_3); options.set_max_tls_version(grpc_tls_version::TLS1_3);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);
EXPECT_NE(server_credentials, nullptr); EXPECT_NE(server_credentials, nullptr);
} }
TEST( TEST(CredentialsTest, TlsServerCredentialsWithBadMinMaxTlsVersions) {
CredentialsTest, grpc::experimental::TlsServerCredentialsOptions options(
TlsChannelCredentialsWithStaticDataCertificateProviderAndBadMinMaxTlsVersions) { /*certificate_provider=*/nullptr);
experimental::IdentityKeyCertPair key_cert_pair;
key_cert_pair.private_key = kIdentityCertPrivateKey;
key_cert_pair.certificate_chain = kIdentityCertContents;
std::vector<experimental::IdentityKeyCertPair> identity_key_cert_pairs;
identity_key_cert_pairs.emplace_back(key_cert_pair);
auto certificate_provider = std::make_shared<StaticDataCertificateProvider>(
kRootCertContents, identity_key_cert_pairs);
grpc::experimental::TlsServerCredentialsOptions options(certificate_provider);
options.set_min_tls_version(grpc_tls_version::TLS1_3); options.set_min_tls_version(grpc_tls_version::TLS1_3);
options.set_max_tls_version(grpc_tls_version::TLS1_2); options.set_max_tls_version(grpc_tls_version::TLS1_2);
auto server_credentials = grpc::experimental::TlsServerCredentials(options); auto server_credentials = grpc::experimental::TlsServerCredentials(options);

Loading…
Cancel
Save