Skip to content

Commit

Permalink
test: add a test for an expired cert (#4103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Nelson authored Nov 9, 2023
1 parent c48f62d commit 4619117
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/aws_common/test/http/bad_certificate_test.dart
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,
);
});
}

0 comments on commit 4619117

Please sign in to comment.