Skip to content

Commit

Permalink
Updates tests and fixes a couple of typoes
Browse files Browse the repository at this point in the history
  • Loading branch information
maskit committed Jul 14, 2020
1 parent f41ca7b commit 47e1eb7
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 44 deletions.
2 changes: 1 addition & 1 deletion iocore/net/P_QUICNetVConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class QUICNetVConnection : public UnixNetVConnection,
QUICConnectionId original_connection_id() const override;
QUICConnectionId first_connection_id() const override;
QUICConnectionId retry_source_connection_id() const override;
QUICConnectionId initial_source_connectoin_id() const override;
QUICConnectionId initial_source_connection_id() const override;
QUICConnectionId connection_id() const override;
std::string_view cids() const override;
const QUICFiveTuple five_tuple() const override;
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/QUICNetVConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ QUICNetVConnection::retry_source_connection_id() const
}

QUICConnectionId
QUICNetVConnection::initial_source_connectoin_id() const
QUICNetVConnection::initial_source_connection_id() const
{
return this->_initial_source_connection_id;
}
Expand Down
39 changes: 39 additions & 0 deletions iocore/net/quic/Mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "QUICApplication.h"
#include "QUICStreamManager.h"
#include "QUICLossDetector.h"
#include "QUICPacketProtectionKeyInfo.h"
#include "QUICPinger.h"
#include "QUICPadder.h"
#include "QUICEvents.h"
#include "QUICPacketProtectionKeyInfo.h"
#include "QUICPinger.h"
Expand Down Expand Up @@ -154,6 +157,18 @@ class MockQUICConnectionInfoProvider : public QUICConnectionInfoProvider
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

QUICConnectionId
retry_source_connection_id() const override
{
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

QUICConnectionId
initial_source_connection_id() const override
{
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

const QUICFiveTuple
five_tuple() const override
{
Expand Down Expand Up @@ -192,6 +207,12 @@ class MockQUICConnectionInfoProvider : public QUICConnectionInfoProvider
return false;
}

QUICVersion
negotiated_version() const override
{
return QUIC_SUPPORTED_VERSIONS[0];
}

std::string_view
negotiated_application_name() const override
{
Expand Down Expand Up @@ -341,6 +362,18 @@ class MockQUICConnection : public QUICConnection
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

QUICConnectionId
retry_source_connection_id() const override
{
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

QUICConnectionId
initial_source_connection_id() const override
{
return {reinterpret_cast<const uint8_t *>("\x00"), 1};
}

const QUICFiveTuple
five_tuple() const override
{
Expand Down Expand Up @@ -419,6 +452,12 @@ class MockQUICConnection : public QUICConnection
{
}

QUICVersion
negotiated_version() const override
{
return QUIC_SUPPORTED_VERSIONS[0];
}

std::string_view
negotiated_application_name() const override
{
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/quic/QUICConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class QUICConnectionInfoProvider
/**
* This is C1 or S3 on 7.3.Authenticating Connection IDs
*/
virtual QUICConnectionId initial_source_connectoin_id() const = 0;
virtual QUICConnectionId initial_source_connection_id() const = 0;
virtual QUICConnectionId connection_id() const = 0;
virtual std::string_view cids() const = 0;
virtual const QUICFiveTuple five_tuple() const = 0;
Expand Down
10 changes: 5 additions & 5 deletions iocore/net/quic/QUICHandshake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ QUICHandshake::start(const QUICTPConfig &tp_config, QUICPacketFactory *packet_fa
{
QUICVersion initital_version = QUIC_SUPPORTED_VERSIONS[0];
if (vn_exercise_enabled) {
initital_version = QUIC_EXERCISE_VERSION;
initital_version = QUIC_EXERCISE_VERSION1;
}

this->_load_local_client_transport_parameters(tp_config);
Expand Down Expand Up @@ -441,8 +441,8 @@ QUICHandshake::_load_local_server_transport_parameters(const QUICTPConfig &tp_co
}
}
if (this->negotiated_version() == QUIC_SUPPORTED_VERSIONS[0]) { // draft-28
tp->set(QUICTransportParameterId::INITIAL_SOURCE_CONNECTION_ID, this->_qc->initial_source_connectoin_id(),
this->_qc->initial_source_connectoin_id().length());
tp->set(QUICTransportParameterId::INITIAL_SOURCE_CONNECTION_ID, this->_qc->initial_source_connection_id(),
this->_qc->initial_source_connection_id().length());
}

// MAYs
Expand Down Expand Up @@ -497,8 +497,8 @@ QUICHandshake::_load_local_client_transport_parameters(const QUICTPConfig &tp_co

// MUSTs
tp->set(QUICTransportParameterId::MAX_IDLE_TIMEOUT, static_cast<uint16_t>(tp_config.no_activity_timeout()));
tp->set(QUICTransportParameterId::INITIAL_SOURCE_CONNECTION_ID, this->_qc->initial_source_connectoin_id(),
this->_qc->initial_source_connectoin_id().length());
tp->set(QUICTransportParameterId::INITIAL_SOURCE_CONNECTION_ID, this->_qc->initial_source_connection_id(),
this->_qc->initial_source_connection_id().length());

// MAYs
if (tp_config.initial_max_data() != 0) {
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/quic/QUICPacket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ QUICVersionNegotiationPacket::payload_block() const
// [draft-18] 6.3. Using Reserved Versions
// To help ensure this, a server SHOULD include a reserved version (see Section 15) while generating a
// Version Negotiation packet.
QUICTypeUtil::write_QUICVersion(QUIC_EXERCISE_VERSION, buf + written_len, &n);
QUICTypeUtil::write_QUICVersion(QUIC_EXERCISE_VERSION1, buf + written_len, &n);
written_len += n;

block->fill(written_len);
Expand Down
3 changes: 2 additions & 1 deletion iocore/net/quic/QUICTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ constexpr QUICVersion QUIC_SUPPORTED_VERSIONS[] = {
0xff00001c,
0xff00001b,
};
constexpr QUICVersion QUIC_EXERCISE_VERSION = 0x1a2a3a4a;
constexpr QUICVersion QUIC_EXERCISE_VERSION1 = 0x1a2a3a4a;
constexpr QUICVersion QUIC_EXERCISE_VERSION2 = 0x5a6a7a8a;

enum class QUICEncryptionLevel {
NONE = -1,
Expand Down
15 changes: 14 additions & 1 deletion iocore/net/quic/test/test_QUICHandshakeProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@

#include <openssl/ssl.h>

// #include "Mock.h"
#include "QUICPacketHeaderProtector.h"
#include "QUICPacketPayloadProtector.h"
#include "QUICPacketProtectionKeyInfo.h"
#include "QUICTLS.h"
#include "QUICGlobals.h"
#include "Mock.h"

// XXX For NetVCOptions::reset
struct PollCont;
Expand Down Expand Up @@ -107,8 +108,12 @@ TEST_CASE("QUICHandshakeProtocol")
QUICPacketProtectionKeyInfo pp_key_info_client;
QUICPacketProtectionKeyInfo pp_key_info_server;
NetVCOptions netvc_options;
MockQUICConnection mock_client_connection;
MockQUICConnection mock_server_connection;
QUICHandshakeProtocol *client = new QUICTLS(pp_key_info_client, client_ssl_ctx, NET_VCONNECTION_OUT, netvc_options);
QUICHandshakeProtocol *server = new QUICTLS(pp_key_info_server, server_ssl_ctx, NET_VCONNECTION_IN, netvc_options);
SSL_set_ex_data(static_cast<QUICTLS *>(client)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_client_connection);
SSL_set_ex_data(static_cast<QUICTLS *>(server)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_server_connection);
QUICPacketPayloadProtector ppp_client(pp_key_info_client);
QUICPacketPayloadProtector ppp_server(pp_key_info_server);

Expand Down Expand Up @@ -232,8 +237,12 @@ TEST_CASE("QUICHandshakeProtocol")
QUICPacketProtectionKeyInfo pp_key_info_client;
QUICPacketProtectionKeyInfo pp_key_info_server;
NetVCOptions netvc_options;
MockQUICConnection mock_client_connection;
MockQUICConnection mock_server_connection;
QUICHandshakeProtocol *client = new QUICTLS(pp_key_info_client, client_ssl_ctx, NET_VCONNECTION_OUT, netvc_options);
QUICHandshakeProtocol *server = new QUICTLS(pp_key_info_server, server_ssl_ctx, NET_VCONNECTION_IN, netvc_options);
SSL_set_ex_data(static_cast<QUICTLS *>(client)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_client_connection);
SSL_set_ex_data(static_cast<QUICTLS *>(server)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_server_connection);
QUICPacketPayloadProtector ppp_client(pp_key_info_client);
QUICPacketPayloadProtector ppp_server(pp_key_info_server);

Expand Down Expand Up @@ -401,8 +410,12 @@ TEST_CASE("QUICHandshakeProtocol")
QUICPacketProtectionKeyInfo pp_key_info_client;
QUICPacketProtectionKeyInfo pp_key_info_server;
NetVCOptions netvc_options;
MockQUICConnection mock_client_connection;
MockQUICConnection mock_server_connection;
QUICHandshakeProtocol *client = new QUICTLS(pp_key_info_client, client_ssl_ctx, NET_VCONNECTION_OUT, netvc_options);
QUICHandshakeProtocol *server = new QUICTLS(pp_key_info_server, server_ssl_ctx, NET_VCONNECTION_IN, netvc_options);
SSL_set_ex_data(static_cast<QUICTLS *>(client)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_client_connection);
SSL_set_ex_data(static_cast<QUICTLS *>(server)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_server_connection);

auto client_tp = std::make_shared<QUICTransportParametersInClientHello>();
auto server_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
Expand Down
2 changes: 2 additions & 0 deletions iocore/net/quic/test/test_QUICLossDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "QUICPacketFactory.h"
#include "QUICAckFrameCreator.h"
#include "QUICEvents.h"
#include "QUICPacketFactory.h"
#include "QUICAckFrameCreator.h"
#include "Mock.h"
#include "tscore/ink_hrtime.h"

Expand Down
10 changes: 6 additions & 4 deletions iocore/net/quic/test/test_QUICPacket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ TEST_CASE("Sending Packet", "[quic]")

SECTION("RETRY Packet (store)")
{
uint8_t buf[64] = {0};
size_t len = 0;
uint8_t buf[128] = {0};
size_t len = 0;

const uint8_t expected[] = {
0xf0, // Long header, Type: RETRY
Expand All @@ -267,11 +267,13 @@ TEST_CASE("Sending Packet", "[quic]")
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // Source Connection ID
0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Retry Token
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //
0x10, 0x11, 0x12, 0x13, 0x14, 0xf0, 0xf1, 0xf2, //
0x10, 0x11, 0x12, 0x13, 0x14, 0x08, 0x01, 0x02, //
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x08, 0x11, //
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, //
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Retry Integrity Tag
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
QUICRetryToken token(expected + 23, 24);
QUICRetryToken token(expected + 23, 39);

QUICRetryPacket packet(0x11223344, {reinterpret_cast<const uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8},
{reinterpret_cast<const uint8_t *>("\x11\x12\x13\x14\x15\x16\x17\x18"), 8}, token);
Expand Down
1 change: 1 addition & 0 deletions iocore/net/quic/test/test_QUICPacketFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
0x08, // SCID Len
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Source Connection ID
0xff, 0x00, 0x00, 0x1c, // Supported Version
0xff, 0x00, 0x00, 0x1b, // Supported Version
0x1a, 0x2a, 0x3a, 0x4a, // Excercise Version
};
uint8_t buf[1024] = {0};
Expand Down
6 changes: 6 additions & 0 deletions iocore/net/quic/test/test_QUICPacketHeaderProtector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "QUICPacketProtectionKeyInfo.h"
#include "QUICPacketHeaderProtector.h"
#include "QUICTLS.h"
#include "QUICGlobals.h"
#include "Mock.h"

struct PollCont;
#include "P_UDPConnection.h"
Expand Down Expand Up @@ -121,8 +123,12 @@ TEST_CASE("QUICPacketHeaderProtector")
QUICPacketProtectionKeyInfo pp_key_info_client;
QUICPacketProtectionKeyInfo pp_key_info_server;
NetVCOptions netvc_options;
MockQUICConnection mock_client_connection;
MockQUICConnection mock_server_connection;
QUICHandshakeProtocol *client = new QUICTLS(pp_key_info_client, client_ssl_ctx, NET_VCONNECTION_OUT, netvc_options);
QUICHandshakeProtocol *server = new QUICTLS(pp_key_info_server, server_ssl_ctx, NET_VCONNECTION_IN, netvc_options);
SSL_set_ex_data(static_cast<QUICTLS *>(client)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_client_connection);
SSL_set_ex_data(static_cast<QUICTLS *>(server)->ssl_handle(), QUIC::ssl_quic_qc_index, &mock_server_connection);

auto client_tp = std::make_shared<QUICTransportParametersInClientHello>();
auto server_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
Expand Down
16 changes: 8 additions & 8 deletions iocore/net/quic/test/test_QUICStreamManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
0x40, 0x10 // value
};
std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf));
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

uint8_t remote_tp_buf[] = {
0x08, // parameter id - initial_max_streams_bidi
0x02, // length of value
0x40, 0x10 // value
};
std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf));
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

sm.init_flow_control_params(local_tp, remote_tp);

Expand Down Expand Up @@ -139,7 +139,7 @@ TEST_CASE("QUICStreamManager_total_offset_received", "[quic]")
0xbf, 0xff, 0xff, 0xff // value
};
std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf));
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

uint8_t remote_tp_buf[] = {
0x08, // parameter id - initial_max_streams_bidi
Expand All @@ -150,7 +150,7 @@ TEST_CASE("QUICStreamManager_total_offset_received", "[quic]")
0xbf, 0xff, 0xff, 0xff // value
};
std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf));
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

sm.init_flow_control_params(local_tp, remote_tp);

Expand Down Expand Up @@ -194,7 +194,7 @@ TEST_CASE("QUICStreamManager_total_offset_sent", "[quic]")
0xbf, 0xff, 0xff, 0xff // value
};
std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf));
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

uint8_t remote_tp_buf[] = {
0x08, // parameter id - initial_max_streams_bidi
Expand All @@ -205,7 +205,7 @@ TEST_CASE("QUICStreamManager_total_offset_sent", "[quic]")
0xbf, 0xff, 0xff, 0xff // value
};
std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf));
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

sm.init_flow_control_params(local_tp, remote_tp);

Expand Down Expand Up @@ -262,7 +262,7 @@ TEST_CASE("QUICStreamManager_max_streams", "[quic]")
0x03, // value
};
std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf));
std::make_shared<QUICTransportParametersInEncryptedExtensions>(local_tp_buf, sizeof(local_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

uint8_t remote_tp_buf[] = {
0x08, // parameter id - initial_max_streams_bidi
Expand All @@ -273,7 +273,7 @@ TEST_CASE("QUICStreamManager_max_streams", "[quic]")
0x03, // value
};
std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf));
std::make_shared<QUICTransportParametersInClientHello>(remote_tp_buf, sizeof(remote_tp_buf), QUIC_SUPPORTED_VERSIONS[0]);

sm.init_flow_control_params(local_tp, remote_tp);

Expand Down

0 comments on commit 47e1eb7

Please sign in to comment.