Commit c76ee315 authored by Kyle Nekritz's avatar Kyle Nekritz Committed by Facebook Github Bot 6

Add additional ALPN mismatch tests.

Reviewed By: siyengar

Differential Revision: D3264727

fbshipit-source-id: fb10558096e73a3cbb6f2fb93296524c0206910d
parent f7f9e64e
...@@ -522,15 +522,26 @@ TEST_P(NextProtocolMismatchTest, NpnAlpnTestNoOverlap) { ...@@ -522,15 +522,26 @@ TEST_P(NextProtocolMismatchTest, NpnAlpnTestNoOverlap) {
{SSLContext::NextProtocolType::NPN, SSLContext::NextProtocolType::NPN}); {SSLContext::NextProtocolType::NPN, SSLContext::NextProtocolType::NPN});
} }
TEST_P(NextProtocolNPNOnlyTest, NpnTestNoOverlap) { // Note: the behavior changed in the ANY/ANY case in OpenSSL 1.0.2h, this test
// will fail on 1.0.2 before that.
TEST_P(NextProtocolTest, NpnTestNoOverlap) {
clientCtx->setAdvertisedNextProtocols({"blub"}, GetParam().first); clientCtx->setAdvertisedNextProtocols({"blub"}, GetParam().first);
serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"}, serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"},
GetParam().second); GetParam().second);
connect(); connect();
expectProtocol("blub"); if (GetParam().first == SSLContext::NextProtocolType::ALPN ||
expectProtocolType(); GetParam().second == SSLContext::NextProtocolType::ALPN) {
// This is arguably incorrect behavior since RFC7301 states an ALPN protocol
// mismatch should result in a fatal alert, but this is OpenSSL's current
// behavior and we want to know if it changes.
expectNoProtocol();
} else {
expectProtocol("blub");
expectProtocolType(
{SSLContext::NextProtocolType::NPN, SSLContext::NextProtocolType::NPN});
}
} }
TEST_P(NextProtocolNPNOnlyTest, NpnTestClientProtoFilterHit) { TEST_P(NextProtocolNPNOnlyTest, NpnTestClientProtoFilterHit) {
...@@ -586,20 +597,27 @@ TEST_P(NextProtocolTest, RandomizedNpnTest) { ...@@ -586,20 +597,27 @@ TEST_P(NextProtocolTest, RandomizedNpnTest) {
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
AsyncSSLSocketTest, AsyncSSLSocketTest,
NextProtocolTest, NextProtocolTest,
::testing::Values(NextProtocolTypePair(SSLContext::NextProtocolType::NPN, ::testing::Values(
SSLContext::NextProtocolType::NPN), NextProtocolTypePair(
SSLContext::NextProtocolType::NPN,
SSLContext::NextProtocolType::NPN),
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT) #if OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT)
NextProtocolTypePair(SSLContext::NextProtocolType::ALPN, NextProtocolTypePair(
SSLContext::NextProtocolType::ALPN), SSLContext::NextProtocolType::ALPN,
#endif SSLContext::NextProtocolType::ALPN),
NextProtocolTypePair(SSLContext::NextProtocolType::NPN, NextProtocolTypePair(
SSLContext::NextProtocolType::ANY), SSLContext::NextProtocolType::ALPN,
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT) SSLContext::NextProtocolType::ANY),
NextProtocolTypePair(SSLContext::NextProtocolType::ALPN, NextProtocolTypePair(
SSLContext::NextProtocolType::ANY), SSLContext::NextProtocolType::ANY,
SSLContext::NextProtocolType::ALPN),
#endif #endif
NextProtocolTypePair(SSLContext::NextProtocolType::ANY, NextProtocolTypePair(
SSLContext::NextProtocolType::ANY))); SSLContext::NextProtocolType::NPN,
SSLContext::NextProtocolType::ANY),
NextProtocolTypePair(
SSLContext::NextProtocolType::ANY,
SSLContext::NextProtocolType::ANY)));
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
AsyncSSLSocketTest, AsyncSSLSocketTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment