Skip to content

Commit 24e5886

Browse files
davidbenCQ bot account: commit-bot@chromium.org
authored and
CQ bot account: [email protected]
committed
Add a test for invalid alert types.
This doesn't hugely matter, but I noticed it was some missing coverage. Change-Id: I3e425d47fbbeaacd9da2ae883f34e89b4562ec11 Reviewed-on: https://boringssl-review.googlesource.com/17184 Commit-Queue: Steven Valdez <[email protected]> Reviewed-by: Steven Valdez <[email protected]> CQ-Verified: CQ bot account: [email protected] <[email protected]>
1 parent 5e578c9 commit 24e5886

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

ssl/test/runner/runner.go

+24-2
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,14 @@ type testCase struct {
412412
// which will be compared against the expected value.
413413
testTLSUnique bool
414414
// sendEmptyRecords is the number of consecutive empty records to send
415-
// before and after the test message.
415+
// before each test message.
416416
sendEmptyRecords int
417417
// sendWarningAlerts is the number of consecutive warning alerts to send
418-
// before and after the test message.
418+
// before each test message.
419419
sendWarningAlerts int
420+
// sendBogusAlertType, if true, causes a bogus alert of invalid type to
421+
// be sent before each test message.
422+
sendBogusAlertType bool
420423
// sendKeyUpdates is the number of consecutive key updates to send
421424
// before and after the test message.
422425
sendKeyUpdates int
@@ -750,6 +753,10 @@ func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, nu
750753
tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage)
751754
}
752755

756+
if test.sendBogusAlertType {
757+
tlsConn.SendAlert(0x42, alertUnexpectedMessage)
758+
}
759+
753760
testMessage := make([]byte, messageLen)
754761
for i := range testMessage {
755762
testMessage[i] = 0x42 ^ byte(j)
@@ -2096,6 +2103,21 @@ func addBasicTests() {
20962103
shouldFail: true,
20972104
expectedError: ":TOO_MANY_WARNING_ALERTS:",
20982105
},
2106+
{
2107+
name: "SendBogusAlertType",
2108+
sendBogusAlertType: true,
2109+
shouldFail: true,
2110+
expectedError: ":UNKNOWN_ALERT_TYPE:",
2111+
expectedLocalError: "remote error: illegal parameter",
2112+
},
2113+
{
2114+
protocol: dtls,
2115+
name: "SendBogusAlertType-DTLS",
2116+
sendBogusAlertType: true,
2117+
shouldFail: true,
2118+
expectedError: ":UNKNOWN_ALERT_TYPE:",
2119+
expectedLocalError: "remote error: illegal parameter",
2120+
},
20992121
{
21002122
name: "TooManyKeyUpdates",
21012123
config: Config{

0 commit comments

Comments
 (0)