aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/tsi/transport_security_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/tsi/transport_security_test.cc')
-rw-r--r--test/core/tsi/transport_security_test.cc176
1 files changed, 88 insertions, 88 deletions
diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc
index 39adf2fab6..8dfe72e03b 100644
--- a/test/core/tsi/transport_security_test.cc
+++ b/test/core/tsi/transport_security_test.cc
@@ -54,29 +54,29 @@ typedef struct {
chromium/src/net/cert/x509_certificate_unittest.cc.
TODO(jboeuf) uncomment test cases as we fix tsi_ssl_peer_matches_name. */
const cert_name_test_entry cert_name_test_entries[] = {
- {1, "foo.com", "foo.com", NULL, NULL},
- {1, "f", "f", NULL, NULL},
- {0, "h", "i", NULL, NULL},
- {1, "bar.foo.com", "*.foo.com", NULL, NULL},
+ {1, "foo.com", "foo.com", nullptr, nullptr},
+ {1, "f", "f", nullptr, nullptr},
+ {0, "h", "i", nullptr, nullptr},
+ {1, "bar.foo.com", "*.foo.com", nullptr, nullptr},
{1, "www.test.fr", "common.name",
- "*.test.com,*.test.co.uk,*.test.de,*.test.fr", NULL},
+ "*.test.com,*.test.co.uk,*.test.de,*.test.fr", nullptr},
/*
{1, "wwW.tESt.fr", "common.name", ",*.*,*.test.de,*.test.FR,www"},
*/
- {0, "f.uk", ".uk", NULL, NULL},
- {0, "w.bar.foo.com", "?.bar.foo.com", NULL, NULL},
- {0, "www.foo.com", "(www|ftp).foo.com", NULL, NULL},
- {0, "www.foo.com", "www.foo.com#", NULL, NULL}, /* # = null char. */
- {0, "www.foo.com", "", "www.foo.com#*.foo.com,#,#", NULL},
- {0, "www.house.example", "ww.house.example", NULL, NULL},
- {0, "test.org", "", "www.test.org,*.test.org,*.org", NULL},
- {0, "w.bar.foo.com", "w*.bar.foo.com", NULL, NULL},
- {0, "www.bar.foo.com", "ww*ww.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "ww*ww.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "w*w.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "w*w.bar.foo.c0m", NULL, NULL},
- {0, "WALLY.bar.foo.com", "wa*.bar.foo.com", NULL, NULL},
- {0, "wally.bar.foo.com", "*Ly.bar.foo.com", NULL, NULL},
+ {0, "f.uk", ".uk", nullptr, nullptr},
+ {0, "w.bar.foo.com", "?.bar.foo.com", nullptr, nullptr},
+ {0, "www.foo.com", "(www|ftp).foo.com", nullptr, nullptr},
+ {0, "www.foo.com", "www.foo.com#", nullptr, nullptr}, /* # = null char. */
+ {0, "www.foo.com", "", "www.foo.com#*.foo.com,#,#", nullptr},
+ {0, "www.house.example", "ww.house.example", nullptr, nullptr},
+ {0, "test.org", "", "www.test.org,*.test.org,*.org", nullptr},
+ {0, "w.bar.foo.com", "w*.bar.foo.com", nullptr, nullptr},
+ {0, "www.bar.foo.com", "ww*ww.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "ww*ww.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "w*w.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "w*w.bar.foo.c0m", nullptr, nullptr},
+ {0, "WALLY.bar.foo.com", "wa*.bar.foo.com", nullptr, nullptr},
+ {0, "wally.bar.foo.com", "*Ly.bar.foo.com", nullptr, nullptr},
/*
{1, "ww%57.foo.com", "", "www.foo.com"},
{1, "www&.foo.com", "www%26.foo.com", NULL},
@@ -84,107 +84,107 @@ const cert_name_test_entry cert_name_test_entries[] = {
/* Common name must not be used if subject alternative name was provided. */
{0, "www.test.co.jp", "www.test.co.jp",
- "*.test.de,*.jp,www.test.co.uk,www.*.co.jp", NULL},
+ "*.test.de,*.jp,www.test.co.uk,www.*.co.jp", nullptr},
{0, "www.bar.foo.com", "www.bar.foo.com",
- "*.foo.com,*.*.foo.com,*.*.bar.foo.com,*..bar.foo.com,", NULL},
+ "*.foo.com,*.*.foo.com,*.*.bar.foo.com,*..bar.foo.com,", nullptr},
/* IDN tests */
- {1, "xn--poema-9qae5a.com.br", "xn--poema-9qae5a.com.br", NULL, NULL},
- {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", NULL, NULL},
+ {1, "xn--poema-9qae5a.com.br", "xn--poema-9qae5a.com.br", nullptr, nullptr},
+ {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", nullptr, nullptr},
{0, "xn--poema-9qae5a.com.br", "",
"*.xn--poema-9qae5a.com.br,"
"xn--poema-*.com.br,"
"xn--*-9qae5a.com.br,"
"*--poema-9qae5a.com.br",
- NULL},
+ nullptr},
/* The following are adapted from the examples quoted from
http://tools.ietf.org/html/rfc6125#section-6.4.3
(e.g., *.example.com would match foo.example.com but
not bar.foo.example.com or example.com). */
- {1, "foo.example.com", "*.example.com", NULL, NULL},
- {0, "bar.foo.example.com", "*.example.com", NULL, NULL},
- {0, "example.com", "*.example.com", NULL, NULL},
+ {1, "foo.example.com", "*.example.com", nullptr, nullptr},
+ {0, "bar.foo.example.com", "*.example.com", nullptr, nullptr},
+ {0, "example.com", "*.example.com", nullptr, nullptr},
/* Partial wildcards are disallowed, though RFC 2818 rules allow them.
That is, forms such as baz*.example.net, *baz.example.net, and
b*z.example.net should NOT match domains. Instead, the wildcard must
always be the left-most label, and only a single label. */
- {0, "baz1.example.net", "baz*.example.net", NULL, NULL},
- {0, "foobaz.example.net", "*baz.example.net", NULL, NULL},
- {0, "buzz.example.net", "b*z.example.net", NULL, NULL},
- {0, "www.test.example.net", "www.*.example.net", NULL, NULL},
+ {0, "baz1.example.net", "baz*.example.net", nullptr, nullptr},
+ {0, "foobaz.example.net", "*baz.example.net", nullptr, nullptr},
+ {0, "buzz.example.net", "b*z.example.net", nullptr, nullptr},
+ {0, "www.test.example.net", "www.*.example.net", nullptr, nullptr},
/* Wildcards should not be valid for public registry controlled domains,
and unknown/unrecognized domains, at least three domain components must
be present. */
- {1, "www.test.example", "*.test.example", NULL, NULL},
- {1, "test.example.co.uk", "*.example.co.uk", NULL, NULL},
- {0, "test.example", "*.example", NULL, NULL},
+ {1, "www.test.example", "*.test.example", nullptr, nullptr},
+ {1, "test.example.co.uk", "*.example.co.uk", nullptr, nullptr},
+ {0, "test.example", "*.example", nullptr, nullptr},
/*
{0, "example.co.uk", "*.co.uk", NULL},
*/
- {0, "foo.com", "*.com", NULL, NULL},
- {0, "foo.us", "*.us", NULL, NULL},
- {0, "foo", "*", NULL, NULL},
+ {0, "foo.com", "*.com", nullptr, nullptr},
+ {0, "foo.us", "*.us", nullptr, nullptr},
+ {0, "foo", "*", nullptr, nullptr},
/* IDN variants of wildcards and registry controlled domains. */
- {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", NULL, NULL},
- {1, "test.example.xn--mgbaam7a8h", "*.example.xn--mgbaam7a8h", NULL, NULL},
+ {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", nullptr, nullptr},
+ {1, "test.example.xn--mgbaam7a8h", "*.example.xn--mgbaam7a8h", nullptr, nullptr},
/*
{0, "xn--poema-9qae5a.com.br", "*.com.br", NULL},
*/
- {0, "example.xn--mgbaam7a8h", "*.xn--mgbaam7a8h", NULL, NULL},
+ {0, "example.xn--mgbaam7a8h", "*.xn--mgbaam7a8h", nullptr, nullptr},
/* Wildcards should be permissible for 'private' registry controlled
domains. */
- {1, "www.appspot.com", "*.appspot.com", NULL, NULL},
- {1, "foo.s3.amazonaws.com", "*.s3.amazonaws.com", NULL, NULL},
+ {1, "www.appspot.com", "*.appspot.com", nullptr, nullptr},
+ {1, "foo.s3.amazonaws.com", "*.s3.amazonaws.com", nullptr, nullptr},
/* Multiple wildcards are not valid. */
- {0, "foo.example.com", "*.*.com", NULL, NULL},
- {0, "foo.bar.example.com", "*.bar.*.com", NULL, NULL},
+ {0, "foo.example.com", "*.*.com", nullptr, nullptr},
+ {0, "foo.bar.example.com", "*.bar.*.com", nullptr, nullptr},
/* Absolute vs relative DNS name tests. Although not explicitly specified
in RFC 6125, absolute reference names (those ending in a .) should
match either absolute or relative presented names. */
- {1, "foo.com", "foo.com.", NULL, NULL},
- {1, "foo.com.", "foo.com", NULL, NULL},
- {1, "foo.com.", "foo.com.", NULL, NULL},
- {1, "f", "f.", NULL, NULL},
- {1, "f.", "f", NULL, NULL},
- {1, "f.", "f.", NULL, NULL},
- {1, "www-3.bar.foo.com", "*.bar.foo.com.", NULL, NULL},
- {1, "www-3.bar.foo.com.", "*.bar.foo.com", NULL, NULL},
- {1, "www-3.bar.foo.com.", "*.bar.foo.com.", NULL, NULL},
- {0, ".", ".", NULL, NULL},
- {0, "example.com", "*.com.", NULL, NULL},
- {0, "example.com.", "*.com", NULL, NULL},
- {0, "example.com.", "*.com.", NULL, NULL},
- {0, "foo.", "*.", NULL, NULL},
- {0, "foo", "*.", NULL, NULL},
+ {1, "foo.com", "foo.com.", nullptr, nullptr},
+ {1, "foo.com.", "foo.com", nullptr, nullptr},
+ {1, "foo.com.", "foo.com.", nullptr, nullptr},
+ {1, "f", "f.", nullptr, nullptr},
+ {1, "f.", "f", nullptr, nullptr},
+ {1, "f.", "f.", nullptr, nullptr},
+ {1, "www-3.bar.foo.com", "*.bar.foo.com.", nullptr, nullptr},
+ {1, "www-3.bar.foo.com.", "*.bar.foo.com", nullptr, nullptr},
+ {1, "www-3.bar.foo.com.", "*.bar.foo.com.", nullptr, nullptr},
+ {0, ".", ".", nullptr, nullptr},
+ {0, "example.com", "*.com.", nullptr, nullptr},
+ {0, "example.com.", "*.com", nullptr, nullptr},
+ {0, "example.com.", "*.com.", nullptr, nullptr},
+ {0, "foo.", "*.", nullptr, nullptr},
+ {0, "foo", "*.", nullptr, nullptr},
/*
{0, "foo.co.uk", "*.co.uk.", NULL},
{0, "foo.co.uk.", "*.co.uk.", NULL},
*/
/* An empty CN is OK. */
- {1, "test.foo.com", "", "test.foo.com", NULL},
+ {1, "test.foo.com", "", "test.foo.com", nullptr},
/* An IP should not be used for the CN. */
- {0, "173.194.195.139", "173.194.195.139", NULL, NULL},
+ {0, "173.194.195.139", "173.194.195.139", nullptr, nullptr},
/* An IP can be used if the SAN IP is present */
- {1, "173.194.195.139", "foo.example.com", NULL, "173.194.195.139"},
- {0, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8"},
- {0, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8,8.8.4.4"},
- {1, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8,173.194.195.139"},
- {0, "173.194.195.139", "foo.example.com", NULL, "173.194.195.13"},
- {0, "2001:db8:a0b:12f0::1", "foo.example.com", NULL, "173.194.195.13"},
- {1, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {1, "173.194.195.139", "foo.example.com", nullptr, "173.194.195.139"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "8.8.8.8"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "8.8.8.8,8.8.4.4"},
+ {1, "173.194.195.139", "foo.example.com", nullptr, "8.8.8.8,173.194.195.139"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "173.194.195.13"},
+ {0, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr, "173.194.195.13"},
+ {1, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::1"},
- {0, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {0, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::2"},
- {1, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {1, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::2,2001:db8:a0b:12f0::1,8.8.8.8"},
};
@@ -202,7 +202,7 @@ typedef struct {
name_list* name_list_add(const char* n) {
name_list* result = static_cast<name_list*>(gpr_malloc(sizeof(name_list)));
result->name = n;
- result->next = NULL;
+ result->next = nullptr;
return result;
}
@@ -211,7 +211,7 @@ static parsed_names parse_names(const char* names_str) {
name_list* current_nl;
size_t i;
memset(&result, 0, sizeof(parsed_names));
- if (names_str == 0) return result;
+ if (names_str == nullptr) return result;
result.name_count = 1;
result.buffer = gpr_strdup(names_str);
result.names = name_list_add(result.buffer);
@@ -230,8 +230,8 @@ static parsed_names parse_names(const char* names_str) {
static void destruct_parsed_names(parsed_names* pdn) {
name_list* nl = pdn->names;
- if (pdn->buffer != NULL) gpr_free(pdn->buffer);
- while (nl != NULL) {
+ if (pdn->buffer != nullptr) gpr_free(pdn->buffer);
+ while (nl != nullptr) {
name_list* to_be_free = nl;
nl = nl->next;
gpr_free(to_be_free);
@@ -264,7 +264,7 @@ static tsi_peer peer_from_cert_name_test_entry(
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, entry->common_name,
&peer.properties[0]) == TSI_OK);
i = 1;
- while (nl != NULL) {
+ while (nl != nullptr) {
char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
@@ -274,7 +274,7 @@ static tsi_peer peer_from_cert_name_test_entry(
}
nl = ip_entries.names;
- while (nl != NULL) {
+ while (nl != nullptr) {
char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
@@ -294,8 +294,8 @@ char* cert_name_test_entry_to_string(const cert_name_test_entry* entry) {
"%s, ip_names = %s}",
entry->expected ? "true" : "false", entry->host_name,
entry->common_name,
- entry->dns_names != NULL ? entry->dns_names : "",
- entry->ip_names != NULL ? entry->ip_names : "");
+ entry->dns_names != nullptr ? entry->dns_names : "",
+ entry->ip_names != nullptr ? entry->ip_names : "");
return s;
}
@@ -344,24 +344,24 @@ static void test_result_strings(void) {
}
static void test_protector_invalid_args(void) {
- GPR_ASSERT(tsi_frame_protector_protect(NULL, NULL, NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_frame_protector_protect(nullptr, nullptr, nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_frame_protector_protect_flush(NULL, NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_frame_protector_protect_flush(nullptr, nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_frame_protector_unprotect(NULL, NULL, NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_frame_protector_unprotect(nullptr, nullptr, nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
}
static void test_handshaker_invalid_args(void) {
- GPR_ASSERT(tsi_handshaker_get_result(NULL) == TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_extract_peer(NULL, NULL) == TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_create_frame_protector(NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_get_result(nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_extract_peer(nullptr, nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_create_frame_protector(nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_process_bytes_from_peer(NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_process_bytes_from_peer(nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer(NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer(nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_next(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
}
@@ -370,7 +370,7 @@ static void test_handshaker_invalid_state(void) {
tsi_peer peer;
tsi_frame_protector* p;
GPR_ASSERT(tsi_handshaker_extract_peer(h, &peer) == TSI_FAILED_PRECONDITION);
- GPR_ASSERT(tsi_handshaker_create_frame_protector(h, NULL, &p) ==
+ GPR_ASSERT(tsi_handshaker_create_frame_protector(h, nullptr, &p) ==
TSI_FAILED_PRECONDITION);
tsi_handshaker_destroy(h);
}