Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/coverage_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
- uses: subosito/flutter-action@4cab68ce0f1c7c924f688bff4792e044f1aeb30c
with:
cache: true
- run: |
chmod +x ./scripts/prepare_pinning_certs.sh
./scripts/prepare_pinning_certs.sh
- name: Install proxy for tests
run: sudo apt-get update && sudo apt-get install -y squid
- run: dart pub get
Expand All @@ -47,7 +44,6 @@ jobs:
- name: Melos Bootstrap
run: melos bootstrap
# Tests
- run: ./scripts/prepare_pinning_certs.sh
- name: Install proxy for tests
run: sudo apt-get update && sudo apt-get install -y squid mkcert
- name: Start local httpbun
Expand All @@ -64,14 +60,23 @@ jobs:
--env HTTPBUN_TLS_KEY=/tmp/key.pem \
--pull always \
sharat87/httpbun
docker run \
--name httpbun-http \
--detach \
--publish 80:80 \
--pull always \
sharat87/httpbun
sleep 1
curl --fail --silent --show-error https://httpbun.local/any
curl --fail --silent --show-error http://httpbun.local/any
- name: Prepare pinning certificates
run: HTTPBUN_HOST=httpbun.local ./scripts/prepare_pinning_certs.sh
- name: Use httpbun.local for tests
run: melos run httpbun:local
- name: '[Verify step] Test Dart packages [VM]'
run: melos run test:vm
- name: Use httpbun.com for Web/Flutter tests
run: melos run httpbun:com
- name: Use local HTTP for Web/Flutter tests
run: melos run httpbun:local:http
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos run test:web:chrome
- name: '[Verify step] Test Dart packages [Firefox]'
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
if: ${{ matrix.sdk == 'stable' }}
run: melos run publish-dry-run
# Tests
- run: ./scripts/prepare_pinning_certs.sh
- name: Install proxy for tests
run: sudo apt-get update && sudo apt-get install -y squid mkcert
- name: Start local httpbun
Expand All @@ -85,14 +84,23 @@ jobs:
--env HTTPBUN_TLS_KEY=/tmp/key.pem \
--pull always \
sharat87/httpbun
docker run \
--name httpbun-http \
--detach \
--publish 80:80 \
--pull always \
sharat87/httpbun
sleep 1
curl --fail --silent --show-error https://httpbun.local/any
curl --fail --silent --show-error http://httpbun.local/any
- name: Prepare pinning certificates
run: HTTPBUN_HOST=httpbun.local ./scripts/prepare_pinning_certs.sh
- name: Use httpbun.local for tests
run: melos run httpbun:local
- name: '[Verify step] Test Dart packages [VM]'
run: melos run test:vm
- name: Use httpbun.com for Web/Flutter tests
run: melos run httpbun:com
- name: Use local HTTP for Web/Flutter tests
run: melos run httpbun:local:http
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos run test:web:chrome
- name: '[Verify step] Test Dart packages [Firefox]'
Expand Down
5 changes: 4 additions & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ scripts:
httpbun:local:
description: Run httpbun locally
run: echo "const httpbunBaseUrl = 'https://httpbun.local';" > dio_test/lib/src/httpbun.dart
httpbun:local:http:
description: Run httpbun locally over HTTP
run: echo "const httpbunBaseUrl = 'http://httpbun.local';" > dio_test/lib/src/httpbun.dart
httpbun:com:
description: Run httpbun locally
description: Run tests against httpbun.com
run: echo "const httpbunBaseUrl = 'https://httpbun.com';" > dio_test/lib/src/httpbun.dart

test:
Expand Down
3 changes: 2 additions & 1 deletion plugins/http2_adapter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ See the [Migration Guide][] for the complete breaking changes list.**

## Unreleased

*None.*
- Run HTTP integration and certificate pinning tests against the configured
test server.

## 2.7.1

Expand Down
12 changes: 4 additions & 8 deletions plugins/http2_adapter/test/pinning_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:dio/dio.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
import 'package:dio_test/util.dart';
import 'package:test/test.dart';

void main() {
Expand All @@ -17,8 +18,9 @@ void main() {
}

group('SSL pinning', () {
final expectedHostString = Uri.parse(httpbunBaseUrl).host;
final Dio dio = Dio()
..options.baseUrl = 'https://httpbun.com/'
..options.baseUrl = '$httpbunBaseUrl/'
..interceptors.add(
QueuedInterceptorsWrapper(
onRequest: (options, handler) async {
Expand All @@ -28,8 +30,6 @@ void main() {
},
),
);
final expectedHostString = 'httpbun.com';

test('trusted host allowed with no approver', () async {
dio.httpClientAdapter = Http2Adapter(
ConnectionManager(
Expand Down Expand Up @@ -149,13 +149,9 @@ void main() {
expect(badCert, true);
expect(approved, true);
expect(badCertSubject, isNotNull);
expect(badCertSubject, isNot(contains(expectedHostString)));
expect(badCertSha256, isNot(fingerprint()));
expect(badCertSha256, isNotNull);
expect(approverSubject, isNotNull);
expect(approverSubject, contains(expectedHostString));
expect(approverSha256, fingerprint());
expect(approverSubject, isNot(badCertSubject));
expect(approverSha256, isNot(badCertSha256));
expect(res, isNotNull);
expect(res.data, isNotNull);
expect(res.data.toString(), contains(expectedHostString));
Expand Down
5 changes: 3 additions & 2 deletions scripts/prepare_pinning_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ openssl s_client \
| openssl x509 -noout -fingerprint -sha256 > dio/test/_pinning.txt 2>/dev/null

# For http2_adapter pinning tests
HTTPBUN_HOST="${HTTPBUN_HOST:-httpbun.com}"
openssl s_client \
-servername httpbun.com \
-connect httpbun.com:443 < /dev/null 2>/dev/null \
-servername "$HTTPBUN_HOST" \
-connect "$HTTPBUN_HOST:443" < /dev/null 2>/dev/null \
| openssl x509 -noout -fingerprint -sha256 > plugins/http2_adapter/test/_pinning_http2.txt 2>/dev/null
Loading