Skip to content

Commit 4619117

Browse files
test: add a test for an expired cert (#4103)
1 parent c48f62d commit 4619117

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import 'package:aws_common/aws_common.dart';
5+
import 'package:test/test.dart';
6+
7+
final expiredCertUrl = Uri.parse('https://expired.badssl.com/');
8+
9+
void main() {
10+
group('AWSHttpClient', () {
11+
test('throws by default for expired certificates', () async {
12+
final client = AWSHttpClient();
13+
final request = AWSHttpRequest.get(expiredCertUrl);
14+
final operation = client.send(request);
15+
await expectLater(
16+
operation.response,
17+
throwsA(isA<AWSHttpException>()),
18+
);
19+
});
20+
21+
test(
22+
'does not throw when onBadCertificate is overridden',
23+
() async {
24+
final client = AWSHttpClient()
25+
..onBadCertificate = (p0, host, port) => true;
26+
final request = AWSHttpRequest.get(expiredCertUrl);
27+
final operation = client.send(request);
28+
expect(
29+
operation.response,
30+
completes,
31+
);
32+
},
33+
// onBadCertificate override is only used on vm
34+
skip: zIsWeb,
35+
);
36+
});
37+
}

0 commit comments

Comments
 (0)