Files
swift-nio/Tests/NIOWebSocketTests/WebSocketFrameDecoderTest+XCTest.swift
T
Cory Benfield 3803d9b096 More featureful error handling options for WebSockets (#528)
Motivation:

Currently if you hit a parse error in the WebSocketFrameDecoder, that
handler takes it upon itself to return the error code and shut the connection
down. That's not really its job: it's not a pattern that we use anywhere
else, and it prevents users from overriding this handling with their own
choices.

We should stop doing that. Unfortunately, we can't totally stop it because
it's a supported feature in the current release of NIO, but we can give
users the option to opt-out, and also build our future solution at the same
time.

Modifications:

1. Added support for disabling the automatic error handling in
    WebSocketFrameDecoder.
2. Created a new WebSocketProtocolErrorHandler class that will be used for
    default error handling in 2.0.
3. Added support to the WebSocketUpgrader to disable automatic error handling
    altogether.
4. Changed the WebSocketUpgrader to use the WebSocketProtocolErrorHandler
    for default error handling when necessary.

Result:

Better separation of concerns, and users can override NIO's default
error handling behaviour.
2018-07-31 10:27:12 +01:00

54 lines
3.4 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
//
// WebSocketFrameDecoderTest+XCTest.swift
//
import XCTest
///
/// NOTE: This file was generated by generate_linux_tests.rb
///
/// Do NOT edit this file directly as it will be regenerated automatically when needed.
///
extension WebSocketFrameDecoderTest {
static var allTests : [(String, (WebSocketFrameDecoderTest) -> () throws -> Void)] {
return [
("testFramesWithoutBodies", testFramesWithoutBodies),
("testFramesWithExtensionDataDontRoundTrip", testFramesWithExtensionDataDontRoundTrip),
("testFramesWithExtensionDataCanBeRecovered", testFramesWithExtensionDataCanBeRecovered),
("testFramesWithReservedBitsSetRoundTrip", testFramesWithReservedBitsSetRoundTrip),
("testFramesWith16BitLengthsRoundTrip", testFramesWith16BitLengthsRoundTrip),
("testFramesWith64BitLengthsRoundTrip", testFramesWith64BitLengthsRoundTrip),
("testMaskedFramesRoundTripWithMaskingIntact", testMaskedFramesRoundTripWithMaskingIntact),
("testMaskedFramesRoundTripWithMaskingIntactEvenWithExtensions", testMaskedFramesRoundTripWithMaskingIntactEvenWithExtensions),
("testDecoderRejectsOverlongFrames", testDecoderRejectsOverlongFrames),
("testDecoderRejectsFragmentedControlFrames", testDecoderRejectsFragmentedControlFrames),
("testDecoderRejectsMultibyteControlFrameLengths", testDecoderRejectsMultibyteControlFrameLengths),
("testIgnoresFurtherDataAfterRejectedFrame", testIgnoresFurtherDataAfterRejectedFrame),
("testClosingSynchronouslyOnChannelRead", testClosingSynchronouslyOnChannelRead),
("testDecoderRejectsOverlongFramesWithNoAutomaticErrorHandling", testDecoderRejectsOverlongFramesWithNoAutomaticErrorHandling),
("testDecoderRejectsFragmentedControlFramesWithNoAutomaticErrorHandling", testDecoderRejectsFragmentedControlFramesWithNoAutomaticErrorHandling),
("testDecoderRejectsMultibyteControlFrameLengthsWithNoAutomaticErrorHandling", testDecoderRejectsMultibyteControlFrameLengthsWithNoAutomaticErrorHandling),
("testIgnoresFurtherDataAfterRejectedFrameWithNoAutomaticErrorHandling", testIgnoresFurtherDataAfterRejectedFrameWithNoAutomaticErrorHandling),
("testDecoderRejectsOverlongFramesWithSeparateErrorHandling", testDecoderRejectsOverlongFramesWithSeparateErrorHandling),
("testDecoderRejectsFragmentedControlFramesWithSeparateErrorHandling", testDecoderRejectsFragmentedControlFramesWithSeparateErrorHandling),
("testDecoderRejectsMultibyteControlFrameLengthsWithSeparateErrorHandling", testDecoderRejectsMultibyteControlFrameLengthsWithSeparateErrorHandling),
("testIgnoresFurtherDataAfterRejectedFrameWithSeparateErrorHandling", testIgnoresFurtherDataAfterRejectedFrameWithSeparateErrorHandling),
]
}
}