mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Test case for too-short request
This commit is contained in:
@@ -2,10 +2,12 @@ package protocol
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
"github.com/v2ray/v2ray-core/transport"
|
||||
)
|
||||
|
||||
func TestHasAuthenticationMethod(t *testing.T) {
|
||||
@@ -94,3 +96,17 @@ func TestResponseWrite(t *testing.T) {
|
||||
}
|
||||
assert.Bytes(buffer.Value).Named("raw response").Equals(expectedBytes)
|
||||
}
|
||||
|
||||
func TestEOF(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
_, _, err := ReadAuthentication(bytes.NewReader(make([]byte, 0)))
|
||||
assert.Error(err).Equals(io.EOF)
|
||||
}
|
||||
|
||||
func TestSignleByte(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
_, _, err := ReadAuthentication(bytes.NewReader(make([]byte, 1)))
|
||||
assert.Error(err).Equals(transport.CorruptedPacket)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user