|
|
|
@ -8413,6 +8413,150 @@ TEST_P(XdsSecurityTest, UnknownIdentityCertificateProvider) { |
|
|
|
|
g_fake1_cert_data_map = nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, |
|
|
|
|
NacksCertificateValidationContextWithVerifyCertificateSpki) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|
g_fake1_cert_data_map = &fake1_cert_map; |
|
|
|
|
auto cluster = default_cluster_; |
|
|
|
|
auto* transport_socket = cluster.mutable_transport_socket(); |
|
|
|
|
transport_socket->set_name("envoy.transport_sockets.tls"); |
|
|
|
|
UpstreamTlsContext upstream_tls_context; |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_validation_context_certificate_provider_instance() |
|
|
|
|
->set_instance_name("fake_plugin1"); |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_default_validation_context() |
|
|
|
|
->add_verify_certificate_spki("spki"); |
|
|
|
|
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context); |
|
|
|
|
balancers_[0]->ads_service()->SetCdsResource(cluster); |
|
|
|
|
ASSERT_TRUE(WaitForCdsNack()) << "timed out waiting for NACK"; |
|
|
|
|
const auto response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr( |
|
|
|
|
"CertificateValidationContext: verify_certificate_spki unsupported")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, |
|
|
|
|
NacksCertificateValidationContextWithVerifyCertificateHash) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|
g_fake1_cert_data_map = &fake1_cert_map; |
|
|
|
|
auto cluster = default_cluster_; |
|
|
|
|
auto* transport_socket = cluster.mutable_transport_socket(); |
|
|
|
|
transport_socket->set_name("envoy.transport_sockets.tls"); |
|
|
|
|
UpstreamTlsContext upstream_tls_context; |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_validation_context_certificate_provider_instance() |
|
|
|
|
->set_instance_name("fake_plugin1"); |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_default_validation_context() |
|
|
|
|
->add_verify_certificate_hash("hash"); |
|
|
|
|
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context); |
|
|
|
|
balancers_[0]->ads_service()->SetCdsResource(cluster); |
|
|
|
|
ASSERT_TRUE(WaitForCdsNack()) << "timed out waiting for NACK"; |
|
|
|
|
const auto response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr( |
|
|
|
|
"CertificateValidationContext: verify_certificate_hash unsupported")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, |
|
|
|
|
NacksCertificateValidationContextWithRequireSignedCertificateTimes) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|
g_fake1_cert_data_map = &fake1_cert_map; |
|
|
|
|
auto cluster = default_cluster_; |
|
|
|
|
auto* transport_socket = cluster.mutable_transport_socket(); |
|
|
|
|
transport_socket->set_name("envoy.transport_sockets.tls"); |
|
|
|
|
UpstreamTlsContext upstream_tls_context; |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_validation_context_certificate_provider_instance() |
|
|
|
|
->set_instance_name("fake_plugin1"); |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_default_validation_context() |
|
|
|
|
->mutable_require_signed_certificate_timestamp() |
|
|
|
|
->set_value(true); |
|
|
|
|
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context); |
|
|
|
|
balancers_[0]->ads_service()->SetCdsResource(cluster); |
|
|
|
|
ASSERT_TRUE(WaitForCdsNack()) << "timed out waiting for NACK"; |
|
|
|
|
const auto response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr("CertificateValidationContext: " |
|
|
|
|
"require_signed_certificate_timestamp unsupported")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, NacksCertificateValidationContextWithCrl) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|
g_fake1_cert_data_map = &fake1_cert_map; |
|
|
|
|
auto cluster = default_cluster_; |
|
|
|
|
auto* transport_socket = cluster.mutable_transport_socket(); |
|
|
|
|
transport_socket->set_name("envoy.transport_sockets.tls"); |
|
|
|
|
UpstreamTlsContext upstream_tls_context; |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_validation_context_certificate_provider_instance() |
|
|
|
|
->set_instance_name("fake_plugin1"); |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_default_validation_context() |
|
|
|
|
->mutable_crl(); |
|
|
|
|
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context); |
|
|
|
|
balancers_[0]->ads_service()->SetCdsResource(cluster); |
|
|
|
|
ASSERT_TRUE(WaitForCdsNack()) << "timed out waiting for NACK"; |
|
|
|
|
const auto response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr("CertificateValidationContext: crl unsupported")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, |
|
|
|
|
NacksCertificateValidationContextWithCustomValidatorConfig) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|
g_fake1_cert_data_map = &fake1_cert_map; |
|
|
|
|
auto cluster = default_cluster_; |
|
|
|
|
auto* transport_socket = cluster.mutable_transport_socket(); |
|
|
|
|
transport_socket->set_name("envoy.transport_sockets.tls"); |
|
|
|
|
UpstreamTlsContext upstream_tls_context; |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_validation_context_certificate_provider_instance() |
|
|
|
|
->set_instance_name("fake_plugin1"); |
|
|
|
|
upstream_tls_context.mutable_common_tls_context() |
|
|
|
|
->mutable_combined_validation_context() |
|
|
|
|
->mutable_default_validation_context() |
|
|
|
|
->mutable_custom_validator_config(); |
|
|
|
|
transport_socket->mutable_typed_config()->PackFrom(upstream_tls_context); |
|
|
|
|
balancers_[0]->ads_service()->SetCdsResource(cluster); |
|
|
|
|
ASSERT_TRUE(WaitForCdsNack()) << "timed out waiting for NACK"; |
|
|
|
|
const auto response_state = |
|
|
|
|
balancers_[0]->ads_service()->cds_response_state(); |
|
|
|
|
EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
response_state.error_message, |
|
|
|
|
::testing::HasSubstr( |
|
|
|
|
"CertificateValidationContext: custom_validator_config unsupported")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(XdsSecurityTest, TestMtlsConfigurationWithNoSanMatchers) { |
|
|
|
|
FakeCertificateProvider::CertDataMap fake1_cert_map = { |
|
|
|
|
{"", {root_cert_, identity_pair_}}}; |
|
|
|
|