|
|
@@ -153,6 +153,38 @@ func (suite *ClientHelloTestSuite) TestSnapshotBad() {
|
|
153
|
153
|
}
|
|
154
|
154
|
}
|
|
155
|
155
|
|
|
|
156
|
+func (suite *ClientHelloTestSuite) TestValidateHostname() {
|
|
|
157
|
+ hello := faketls.ClientHello{
|
|
|
158
|
+ Time: time.Now(),
|
|
|
159
|
+ }
|
|
|
160
|
+ suite.NoError(hello.Valid("hostname", time.Second))
|
|
|
161
|
+
|
|
|
162
|
+ hello.Host = "hostname"
|
|
|
163
|
+ suite.Error(hello.Valid("hostname2", time.Second))
|
|
|
164
|
+ suite.NoError(hello.Valid("hostname", time.Second))
|
|
|
165
|
+}
|
|
|
166
|
+
|
|
|
167
|
+func (suite *ClientHelloTestSuite) TestValidateTime() {
|
|
|
168
|
+ testData := []time.Duration{
|
|
|
169
|
+ -2 * time.Second,
|
|
|
170
|
+ 2 * time.Second,
|
|
|
171
|
+ }
|
|
|
172
|
+
|
|
|
173
|
+ for _, v := range testData {
|
|
|
174
|
+ value := v
|
|
|
175
|
+
|
|
|
176
|
+ suite.T().Run(value.String(), func(t *testing.T) {
|
|
|
177
|
+ hello := faketls.ClientHello{
|
|
|
178
|
+ Host: "hostname",
|
|
|
179
|
+ Time: time.Now().Add(value),
|
|
|
180
|
+ }
|
|
|
181
|
+ suite.Error(hello.Valid("hostname", 500*time.Millisecond))
|
|
|
182
|
+ suite.Error(hello.Valid("hostname", time.Second))
|
|
|
183
|
+ suite.NoError(hello.Valid("hostname", 3*time.Second))
|
|
|
184
|
+ })
|
|
|
185
|
+ }
|
|
|
186
|
+}
|
|
|
187
|
+
|
|
156
|
188
|
func TestClientHello(t *testing.T) {
|
|
157
|
189
|
t.Parallel()
|
|
158
|
190
|
suite.Run(t, &ClientHelloTestSuite{})
|