зеркало из https://github.com/microsoft/msquic.git
Add GetParam test for Tls (#2821)
* Add GetParam test for Tls * Fix for Schannel case
This commit is contained in:
Родитель
323d04c72a
Коммит
5c5e242ffd
|
@ -2828,6 +2828,12 @@ CxPlatTlsParamGet(
|
|||
{
|
||||
QUIC_STATUS Status;
|
||||
|
||||
// TODO:
|
||||
// Need to check Connection->Crypto.TlsState.HandshakeComplete for
|
||||
// QUIC_PARAM_TLS_HANDSHAKE_INFO and QUIC_PARAM_TLS_NEGOTIATED_ALPN
|
||||
// It is difficult to access this flag because of dependency problem
|
||||
// caused by including connection.h
|
||||
|
||||
switch (Param) {
|
||||
|
||||
case QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W: {
|
||||
|
|
|
@ -42,7 +42,7 @@ void QuicTestRegistrationParam();
|
|||
void QuicTestConfigurationParam();
|
||||
void QuicTestListenerParam();
|
||||
void QuicTestConnectionParam();
|
||||
void QuicTestTlsSetParam();
|
||||
void QuicTestTlsParam();
|
||||
void QuicTestStreamParam();
|
||||
void QuicTestGetPerfCounters();
|
||||
void QuicTestVersionSettings();
|
||||
|
@ -1049,7 +1049,7 @@ typedef struct {
|
|||
#define IOCTL_QUIC_RUN_VALIDATE_CONNECTION_PARAM \
|
||||
QUIC_CTL_CODE(95, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
|
||||
#define IOCTL_QUIC_RUN_VALIDATE_TLS_SET_PARAM \
|
||||
#define IOCTL_QUIC_RUN_VALIDATE_TLS_PARAM \
|
||||
QUIC_CTL_CODE(96, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
|
||||
#define IOCTL_QUIC_RUN_VALIDATE_STREAM_PARAM \
|
||||
|
|
|
@ -233,12 +233,12 @@ TEST(ParameterValidation, ValidateConnectionParam) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ParameterValidation, ValidateTlsSetParam) {
|
||||
TestLogger Logger("QuicTestValidateTlsSetParam");
|
||||
TEST(ParameterValidation, ValidateTlsParam) {
|
||||
TestLogger Logger("QuicTestValidateTlsParam");
|
||||
if (TestingKernelMode) {
|
||||
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_VALIDATE_TLS_SET_PARAM));
|
||||
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_VALIDATE_TLS_PARAM));
|
||||
} else {
|
||||
QuicTestTlsSetParam();
|
||||
QuicTestTlsParam();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1236,8 +1236,8 @@ QuicTestCtlEvtIoDeviceControl(
|
|||
QuicTestCtlRun(QuicTestConnectionParam());
|
||||
break;
|
||||
|
||||
case IOCTL_QUIC_RUN_VALIDATE_TLS_SET_PARAM:
|
||||
QuicTestCtlRun(QuicTestTlsSetParam());
|
||||
case IOCTL_QUIC_RUN_VALIDATE_TLS_PARAM:
|
||||
QuicTestCtlRun(QuicTestTlsParam());
|
||||
break;
|
||||
|
||||
case IOCTL_QUIC_RUN_VALIDATE_STREAM_PARAM:
|
||||
|
|
|
@ -4075,7 +4075,13 @@ void QuicTestConnectionParam()
|
|||
}
|
||||
}
|
||||
|
||||
void QuicTestTlsSetParam()
|
||||
//
|
||||
// This test uses TEST_NOT_EQUAL(XXX, QUIC_STATUS_SUCCESS) to cover both
|
||||
// OpenSSL and Schannel which return different error code.
|
||||
// This need to be fixed in the future.
|
||||
// see src/platform/tsl_schannel.c about the TODO
|
||||
//
|
||||
void QuicTestTlsParam()
|
||||
{
|
||||
MsQuicRegistration Registration;
|
||||
TEST_TRUE(Registration.IsValid());
|
||||
|
@ -4098,30 +4104,208 @@ void QuicTestTlsSetParam()
|
|||
// QUIC_PARAM_TLS_HANDSHAKE_INFO
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope("QUIC_PARAM_TLS_HANDSHAKE_INFO is get only");
|
||||
QUIC_HANDSHAKE_INFO Dummy = {};
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_HANDSHAKE_INFO,
|
||||
sizeof(Dummy),
|
||||
&Dummy));
|
||||
TestScopeLogger LogScope0("QUIC_PARAM_TLS_HANDSHAKE_INFO");
|
||||
//
|
||||
// SetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("SetParam is not allowed");
|
||||
QUIC_HANDSHAKE_INFO Dummy = {};
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_HANDSHAKE_INFO,
|
||||
sizeof(Dummy),
|
||||
&Dummy));
|
||||
}
|
||||
|
||||
//
|
||||
// GetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("GetParam");
|
||||
uint32_t Length = 0;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_BUFFER_TOO_SMALL,
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_HANDSHAKE_INFO,
|
||||
&Length,
|
||||
nullptr));
|
||||
TEST_EQUAL(Length, sizeof(QUIC_HANDSHAKE_INFO));
|
||||
|
||||
//
|
||||
// Before handshake
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope2("Before handshake");
|
||||
QUIC_HANDSHAKE_INFO Info = {};
|
||||
|
||||
TEST_NOT_EQUAL(
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_HANDSHAKE_INFO,
|
||||
&Length,
|
||||
&Info
|
||||
), QUIC_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
{
|
||||
TestScopeLogger LogScope2("Successful case is covered by TlsTest.HandshakeParamInfo*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// QUIC_PARAM_TLS_NEGOTIATED_ALPN
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope("QUIC_PARAM_TLS_NEGOTIATED_ALPN is get only");
|
||||
TestScopeLogger LogScope0("QUIC_PARAM_TLS_NEGOTIATED_ALPN is get only");
|
||||
//
|
||||
// SetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("SetParam is not allowed");
|
||||
uint8_t Dummy[] = "MsQuicTest";
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_NEGOTIATED_ALPN,
|
||||
sizeof(Dummy),
|
||||
&Dummy));
|
||||
}
|
||||
|
||||
uint8_t Dummy[] = "MsQuicTest";
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_NEGOTIATED_ALPN,
|
||||
sizeof(Dummy),
|
||||
&Dummy));
|
||||
//
|
||||
// GetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("GetParam");
|
||||
{
|
||||
TestScopeLogger LogScope2("Before handshake");
|
||||
uint32_t Length = 0;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_INVALID_PARAMETER,
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_NEGOTIATED_ALPN,
|
||||
&Length,
|
||||
nullptr));
|
||||
|
||||
uint8_t Dummy[] = "MsQuicTest";
|
||||
TEST_NOT_EQUAL(
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_NEGOTIATED_ALPN,
|
||||
&Length,
|
||||
&Dummy),
|
||||
QUIC_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
{
|
||||
TestScopeLogger LogScope2("Successful case is covered by TlsTest.HandshakeParamNegotiatedAlpn");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QUIC_TEST_SCHANNEL_FLAGS
|
||||
{
|
||||
//
|
||||
// SetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("SetParam is not allowed");
|
||||
QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W Data;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W,
|
||||
sizeof(Data),
|
||||
&Data));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t Length = 0;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_BUFFER_TOO_SMALL,
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W,
|
||||
&Length,
|
||||
nullptr));
|
||||
|
||||
QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W Data;
|
||||
TEST_NOT_EQUAL(
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W,
|
||||
&Length,
|
||||
&Data),
|
||||
QUIC_STATUS_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
//
|
||||
// SetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("SetParam is not allowed");
|
||||
QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W Data;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W,
|
||||
sizeof(Data),
|
||||
&Data));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t Length = 0;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_BUFFER_TOO_SMALL,
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W,
|
||||
&Length,
|
||||
nullptr));
|
||||
|
||||
QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W Data;
|
||||
TEST_NOT_EQUAL(
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W,
|
||||
&Length,
|
||||
&Data),
|
||||
QUIC_STATUS_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
//
|
||||
// SetParam
|
||||
//
|
||||
{
|
||||
TestScopeLogger LogScope1("SetParam is not allowed");
|
||||
HANDLE DummyHandle;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_NOT_SUPPORTED,
|
||||
Connection.SetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_SECURITY_CONTEXT_TOKEN,
|
||||
sizeof(DummyHandle),
|
||||
&DummyHandle));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t Length = 0;
|
||||
TEST_QUIC_STATUS(
|
||||
QUIC_STATUS_BUFFER_TOO_SMALL,
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_SECURITY_CONTEXT_TOKEN,
|
||||
&Length,
|
||||
nullptr));
|
||||
|
||||
HANDLE Handle;
|
||||
TEST_NOT_EQUAL(
|
||||
Connection.GetParam(
|
||||
QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_EX_W,
|
||||
&Length,
|
||||
&Handle),
|
||||
QUIC_STATUS_SUCCESS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QuicTestStreamParam()
|
||||
|
|
Загрузка…
Ссылка в новой задаче