-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add a test for an expired cert (#4103)
- Loading branch information
1 parent
c48f62d
commit 4619117
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:aws_common/aws_common.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
final expiredCertUrl = Uri.parse('https://expired.badssl.com/'); | ||
|
||
void main() { | ||
group('AWSHttpClient', () { | ||
test('throws by default for expired certificates', () async { | ||
final client = AWSHttpClient(); | ||
final request = AWSHttpRequest.get(expiredCertUrl); | ||
final operation = client.send(request); | ||
await expectLater( | ||
operation.response, | ||
throwsA(isA<AWSHttpException>()), | ||
); | ||
}); | ||
|
||
test( | ||
'does not throw when onBadCertificate is overridden', | ||
() async { | ||
final client = AWSHttpClient() | ||
..onBadCertificate = (p0, host, port) => true; | ||
final request = AWSHttpRequest.get(expiredCertUrl); | ||
final operation = client.send(request); | ||
expect( | ||
operation.response, | ||
completes, | ||
); | ||
}, | ||
// onBadCertificate override is only used on vm | ||
skip: zIsWeb, | ||
); | ||
}); | ||
} |