Unverified Commit 99d0f8f2 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] handle HandshakeException in httphostvalidator (#105076)

parent 4e23ed36
......@@ -72,6 +72,8 @@ class HttpHostValidator extends DoctorValidator {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on HttpException catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on HandshakeException catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on OSError catch (e) {
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}');
} on FormatException catch (e) {
......
......@@ -302,6 +302,40 @@ void main() {
});
});
testWithoutContext('Does not throw on HandshakeException', () async {
const String handshakeMessage = '''
Handshake error in client (OS Error:
BLOCK_TYPE_IS_NOT_01(../../third_party/boringssl/src/crypto/fipsmodule/rsa/padding.c:108)
PADDING_CHECK_FAILED(../../third_party/boringssl/src/crypto/fipsmodule/rsa/rsa_impl.c:676)
public key routines(../../third_party/boringssl/src/crypto/x509/a_verify.c:108)
CERTIFICATE_VERIFY_FAILED: certificate signature failure(../../third_party/boringssl/src/ssl/handshake.cc:393))
''';
final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(environment: kTestEnvironment),
featureFlags: TestFeatureFlags(isAndroidEnabled: false),
httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(
Uri.parse(kTestEnvPubHost),
method: HttpMethod.head,
responseError: const HandshakeException(handshakeMessage),
),
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head),
]),
);
// Run the validation check and get the results
final ValidationResult result = await httpHostValidator.validate();
expect(
result.messages.first,
isA<ValidationMessage>().having(
(ValidationMessage msg) => msg.message,
'message',
contains(handshakeMessage),
),
);
});
testWithoutContext('Http host validator timeout message includes timeout duration.', () async {
final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(environment: kTestEnvironment),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment