Skip to content

Commit

Permalink
test: added intgrity test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zekfad committed Apr 17, 2024
1 parent 78a94e9 commit 12be9ee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/client_conformance_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,37 @@
library;

import 'package:fetch_client/fetch_client.dart';
import 'package:http/http.dart';
import 'package:http_client_conformance_tests/http_client_conformance_tests.dart';
import 'package:test/test.dart';


void main() {
group('integrity tests', () {
final client = FetchClient(mode: RequestMode.cors);
final uri = Uri.parse('https://raw.githubusercontent.com/Zekfad/fetch_client/22c3a2732c4a89ef284827cba4a7e62a01535776/LICENSE');

test('throw error when integrity mismatch', () async {
const integrity = 'sha256-0';
final request = FetchRequest(
Request('GET', uri),
)..integrity = integrity;
await expectLater(
client.send(request),
throwsA(isA<ClientException>()),
);
});

test('succeed with correct integrity', () async {
const integrity = 'sha256-NTaW0fWGbetqbg/iB0CfyvrxlEvm4rk3f1MXq+Zu0S8=';
final request = FetchRequest(
Request('GET', uri),
)..integrity = integrity;
final response = await client.send(request);
expect(response.statusCode, 200);
});
});

group('client conformance tests', () {
testAll(
() => FetchClient(mode: RequestMode.cors),
Expand Down

0 comments on commit 12be9ee

Please sign in to comment.