@@ -110,8 +110,15 @@ public async Task ClientAbortsConnection()
110110 await processing ;
111111 }
112112
113- [ Fact ]
114- public async Task InvalidFrameTypeOnControlStream_Aborts ( )
113+ [ Theory ]
114+ [ InlineData ( 0 ) ]
115+ [ InlineData ( 1 ) ]
116+ [ InlineData ( 2 ) ]
117+ [ InlineData ( 5 ) ]
118+ [ InlineData ( 6 ) ]
119+ [ InlineData ( 8 ) ]
120+ [ InlineData ( 9 ) ]
121+ public async Task InvalidFrameTypeOnControlStream_Aborts ( int frameType )
115122 {
116123 await using var fixture = await QuicConnectionFixture . SetupConnectionAsync ( Port , TestContext . Current . CancellationToken ) ;
117124 Http3Connection sut = CreateHttp3Connection ( fixture . ServerConnection ) ;
@@ -125,8 +132,43 @@ public async Task InvalidFrameTypeOnControlStream_Aborts()
125132 } , TestContext . Current . CancellationToken ) ;
126133 var clientControlStream = await fixture . ClientConnection . OpenOutboundStreamAsync ( QuicStreamType . Unidirectional , TestContext . Current . CancellationToken ) ;
127134
128- // StreamType: 0-control, FrameType: 4-Headers, Length: 0
129- byte [ ] data = [ 0 , 1 , 0 ] ;
135+ // StreamType: 0-control, FrameType: 1-Invalid, Length: 0
136+ byte [ ] data = [ 0 , ( byte ) frameType , 0 ] ;
137+ await clientControlStream . WriteAsync ( data , TestContext . Current . CancellationToken ) ;
138+ await clientControlStream . FlushAsync ( TestContext . Current . CancellationToken ) ;
139+
140+ await readServerControlStream ;
141+ await processing ;
142+ }
143+
144+ [ Theory ]
145+ [ InlineData ( 1 * 31 + 33 ) ]
146+ [ InlineData ( 2 * 31 + 33 ) ]
147+ [ InlineData ( 0x0f0700 ) ]
148+ public async Task UnknownFrameType_OnControlStream_ISgnored ( int frameType )
149+ {
150+ await using var fixture = await QuicConnectionFixture . SetupConnectionAsync ( Port , TestContext . Current . CancellationToken ) ;
151+ Http3Connection sut = CreateHttp3Connection ( fixture . ServerConnection ) ;
152+ var processing = sut . ProcessConnectionAsync ( new TestBase . TestApplication ( _ => Task . CompletedTask ) )
153+ . WaitAsync ( TimeSpan . FromSeconds ( 10 ) , TestContext . Current . CancellationToken ) ;
154+ var readServerControlStream = Task . Run ( async ( ) =>
155+ {
156+ var controlStream = await fixture . ClientConnection . AcceptInboundStreamAsync ( TestContext . Current . CancellationToken ) ;
157+ await AssertReadSettigsAsync ( controlStream ) ;
158+ await AssertGoAwayAsync ( controlStream , 2 ) ;
159+ } , TestContext . Current . CancellationToken ) ;
160+ var clientControlStream = await fixture . ClientConnection . OpenOutboundStreamAsync ( QuicStreamType . Unidirectional , TestContext . Current . CancellationToken ) ;
161+
162+ // StreamType: 0-control, FrameType, Length: 0
163+ Span < byte > buffer = stackalloc byte [ 8 ] ;
164+ VariableLenghtIntegerDecoder . TryWrite ( buffer , frameType , out var length ) ;
165+
166+ byte [ ] data = [ 0 , .. buffer [ ..length ] , 0 ] ;
167+ await clientControlStream . WriteAsync ( data , TestContext . Current . CancellationToken ) ;
168+ await clientControlStream . FlushAsync ( TestContext . Current . CancellationToken ) ;
169+
170+ // Write GOAWAY FrameType: 7, Length: 1, StreamId: 0
171+ data = [ 7 , 1 , 0 ] ;
130172 await clientControlStream . WriteAsync ( data , TestContext . Current . CancellationToken ) ;
131173 await clientControlStream . FlushAsync ( TestContext . Current . CancellationToken ) ;
132174
0 commit comments