GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add test for Http3HeadersSink (#24) · chrisvest/netty@b306f9b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/test/java/io/netty/incubator/codec/http3
    • Http3HeadersSinkTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/test/java/io/netty/incubator/codec/http3/Http3HeadersSinkTest.java‎

Copy file name to clipboard
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2020 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package io.netty.incubator.codec.http3;
17+
18+
import org.junit.Assert;
19+
import org.junit.Test;
20+
21+
public class Http3HeadersSinkTest {
22+
23+
@Test
24+
public void testHeaderSizeExceeded() {
25+
Http3HeadersSink sink = new Http3HeadersSink(new DefaultHttp3Headers(), 32, false);
26+
sink.accept("name", "value");
27+
sink.accept("someothername", "someothervalue");
28+
29+
try {
30+
sink.finish();
31+
Assert.fail();
32+
} catch (Http3Exception e) {
33+
Http3TestUtils.assertException(Http3ErrorCode.H3_EXCESSIVE_LOAD, e);
34+
}
35+
}
36+
37+
@Test
38+
public void testHeaderSizeNotExceed() throws Exception {
39+
Http3Headers headers = new DefaultHttp3Headers();
40+
Http3HeadersSink sink = new Http3HeadersSink(headers, 64, false);
41+
sink.accept("name", "value");
42+
Assert.assertEquals("value", headers.get("name"));
43+
sink.finish();
44+
}
45+
46+
@Test(expected = Http3HeadersValidationException.class)
47+
public void testPseudoHeaderFollowsNormalHeader() throws Exception {
48+
Http3HeadersSink sink = new Http3HeadersSink(new DefaultHttp3Headers(), 512, true);
49+
sink.accept("name", "value");
50+
sink.accept(Http3Headers.PseudoHeaderName.AUTHORITY.value(), "value");
51+
sink.finish();
52+
}
53+
54+
@Test(expected = Http3HeadersValidationException.class)
55+
public void testInvalidatePseudoHeader() throws Exception {
56+
Http3HeadersSink sink = new Http3HeadersSink(new DefaultHttp3Headers(), 512, true);
57+
sink.accept(":invalid", "value");
58+
sink.finish();
59+
}
60+
61+
@Test(expected = Http3HeadersValidationException.class)
62+
public void testMixRequestResponsePseudoHeaders() throws Exception {
63+
Http3HeadersSink sink = new Http3HeadersSink(new DefaultHttp3Headers(), 512, true);
64+
sink.accept(Http3Headers.PseudoHeaderName.METHOD.value(), "value");
65+
sink.accept(Http3Headers.PseudoHeaderName.STATUS.value(), "value");
66+
sink.finish();
67+
}
68+
69+
@Test
70+
public void testValidPseudoHeader() throws Exception {
71+
Http3Headers headers = new DefaultHttp3Headers();
72+
Http3HeadersSink sink = new Http3HeadersSink(headers, 512, true);
73+
sink.accept(Http3Headers.PseudoHeaderName.AUTHORITY.value(), "value");
74+
sink.finish();
75+
Assert.assertEquals("value", headers.get(Http3Headers.PseudoHeaderName.AUTHORITY.value()));
76+
}
77+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.