|
|
|
@ -24,6 +24,8 @@ |
|
|
|
|
#include <gmock/gmock.h> |
|
|
|
|
#include <gtest/gtest.h> |
|
|
|
|
|
|
|
|
|
#include "absl/log/check.h" |
|
|
|
|
|
|
|
|
|
#include <grpc/support/alloc.h> |
|
|
|
|
#include <grpc/support/log.h> |
|
|
|
|
#include <grpc/support/string_util.h> |
|
|
|
@ -368,12 +370,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( |
|
|
|
@ -404,12 +406,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
const char* expected_error_msg = |
|
|
|
|
"Custom verification check failed with error: UNAUTHENTICATED: " |
|
|
|
@ -557,12 +559,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( |
|
|
|
@ -593,12 +595,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
const char* expected_error_msg = |
|
|
|
|
"Custom verification check failed with error: UNAUTHENTICATED: " |
|
|
|
@ -631,28 +633,28 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a full TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(7, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == |
|
|
|
|
TSI_OK); |
|
|
|
|
TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == |
|
|
|
|
TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_SECURITY_LEVEL_PEER_PROPERTY, |
|
|
|
|
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), |
|
|
|
|
&peer.properties[3]) == TSI_OK); |
|
|
|
|
TSI_SECURITY_LEVEL_PEER_PROPERTY, |
|
|
|
|
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), |
|
|
|
|
&peer.properties[3]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", |
|
|
|
|
&peer.properties[4]) == TSI_OK); |
|
|
|
|
TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", |
|
|
|
|
&peer.properties[4]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[5]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[5]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", |
|
|
|
|
&peer.properties[6]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", |
|
|
|
|
&peer.properties[6]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( |
|
|
|
@ -679,28 +681,28 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a full TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(7, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == |
|
|
|
|
TSI_OK); |
|
|
|
|
TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == |
|
|
|
|
TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_SECURITY_LEVEL_PEER_PROPERTY, |
|
|
|
|
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), |
|
|
|
|
&peer.properties[3]) == TSI_OK); |
|
|
|
|
TSI_SECURITY_LEVEL_PEER_PROPERTY, |
|
|
|
|
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), |
|
|
|
|
&peer.properties[3]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", |
|
|
|
|
&peer.properties[4]) == TSI_OK); |
|
|
|
|
TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", |
|
|
|
|
&peer.properties[4]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", |
|
|
|
|
&peer.properties[5]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", |
|
|
|
|
&peer.properties[5]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", |
|
|
|
|
&peer.properties[6]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", |
|
|
|
|
&peer.properties[6]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
const char* expected_error_msg = |
|
|
|
|
"Custom verification check failed with error: UNAUTHENTICATED: Hostname " |
|
|
|
@ -988,12 +990,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( |
|
|
|
@ -1019,12 +1021,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
const char* expected_error_msg = |
|
|
|
|
"Custom verification check failed with error: UNAUTHENTICATED: " |
|
|
|
@ -1054,12 +1056,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
ExecCtx exec_ctx; |
|
|
|
|
grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( |
|
|
|
@ -1087,12 +1089,12 @@ TEST_F(TlsSecurityConnectorTest, |
|
|
|
|
// Construct a basic TSI Peer.
|
|
|
|
|
tsi_peer peer; |
|
|
|
|
CHECK(tsi_construct_peer(2, &peer) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, |
|
|
|
|
"h2", strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", |
|
|
|
|
strlen("h2"), |
|
|
|
|
&peer.properties[0]) == TSI_OK); |
|
|
|
|
CHECK(tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", |
|
|
|
|
&peer.properties[1]) == TSI_OK); |
|
|
|
|
RefCountedPtr<grpc_auth_context> auth_context; |
|
|
|
|
const char* expected_error_msg = |
|
|
|
|
"Custom verification check failed with error: UNAUTHENTICATED: " |
|
|
|
|