diff --git a/packages/auth_twitter/CHANGELOG.md b/packages/auth_twitter/CHANGELOG.md index 1fba24f8..80e655a6 100644 --- a/packages/auth_twitter/CHANGELOG.md +++ b/packages/auth_twitter/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 8.0.0 + +* Require Dart >= 3.0 +* Updated `oauth1` to `belatuk_oauth1` + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/auth_twitter/LICENSE b/packages/auth_twitter/LICENSE index df5e0635..2bcd0235 100644 --- a/packages/auth_twitter/LICENSE +++ b/packages/auth_twitter/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2021, dukefirehawk.com +Copyright (c) 2023, dukefirehawk.com All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/packages/auth_twitter/pubspec.yaml b/packages/auth_twitter/pubspec.yaml index efe2fae9..6032b8a4 100644 --- a/packages/auth_twitter/pubspec.yaml +++ b/packages/auth_twitter/pubspec.yaml @@ -6,29 +6,28 @@ repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth_twit publish_to: none environment: sdk: ">=3.0.0 <4.0.0" -published_to: none dependencies: angel3_auth: ^8.0.0 angel3_framework: ^8.0.0 http: ^1.0.0 path: ^1.0.0 - oauth1: ^2.0.0 + belatuk_oauth1: ^3.0.0 dart_twitter_api: ^0.5.6+1 dev_dependencies: logging: ^1.2.0 lints: ^2.1.0 -dependency_overrides: - angel3_container: - path: ../container/angel_container - angel3_framework: - path: ../framework - angel3_http_exception: - path: ../http_exception - angel3_model: - path: ../model - angel3_route: - path: ../route - angel3_mock_request: - path: ../mock_request - angel3_auth: - path: ../auth \ No newline at end of file +# dependency_overrides: +# angel3_container: +# path: ../container/angel_container +# angel3_framework: +# path: ../framework +# angel3_http_exception: +# path: ../http_exception +# angel3_model: +# path: ../model +# angel3_route: +# path: ../route +# angel3_mock_request: +# path: ../mock_request +# angel3_auth: +# path: ../auth \ No newline at end of file diff --git a/packages/shelf/pubspec.yaml b/packages/shelf/pubspec.yaml index a55e3c59..dcb44e4f 100644 --- a/packages/shelf/pubspec.yaml +++ b/packages/shelf/pubspec.yaml @@ -16,12 +16,12 @@ dependencies: logging: ^1.2.0 charcode: ^1.3.0 http: ^1.0.0 -# dev_dependencies: -# angel3_test: ^8.0.0 -# belatuk_pretty_logging: ^6.0.0 -# shelf_static: ^1.1.0 -# test: ^1.24.0 -# lints: ^2.1.0 +dev_dependencies: + angel3_test: ^8.0.0 + belatuk_pretty_logging: ^6.0.0 + shelf_static: ^1.1.0 + test: ^1.24.0 + lints: ^2.1.0 # dependency_overrides: # angel3_test: # path: ../test diff --git a/packages/shelf/test/embed_shelf_test.dart b/packages/shelf/test/embed_shelf_test.dart index 3e9dd38f..f3afe998 100644 --- a/packages/shelf/test/embed_shelf_test.dart +++ b/packages/shelf/test/embed_shelf_test.dart @@ -16,7 +16,7 @@ void main() { late http.Client client; late HttpServer server; - Uri _path(String p) { + Uri path(String p) { return Uri( scheme: 'http', host: server.address.address, @@ -65,25 +65,25 @@ void main() { }); test('expose angel side', () async { - var response = await client.get(_path('/angel')); + var response = await client.get(path('/angel')); expect(json.decode(response.body), equals('Angel')); }); test('expose shelf side', () async { - var response = await client.get(_path('/foo')); + var response = await client.get(path('/foo')); expect(response, hasStatus(200)); expect(response.body, equals('Request for "foo"')); }); test('shelf can return arbitrary values', () async { - var response = await client.get(_path('/two')); + var response = await client.get(path('/two')); expect(response, isJson(2)); }); test('shelf can hijack', () async { try { var client = HttpClient(); - var rq = await client.openUrl('GET', _path('/hijack')); + var rq = await client.openUrl('GET', path('/hijack')); var rs = await rq.close(); var body = await rs.cast>().transform(utf8.decoder).join(); print('Response: $body'); @@ -96,17 +96,17 @@ void main() { }); test('shelf can set status code', () async { - var response = await client.get(_path('/status')); + var response = await client.get(path('/status')); expect(response, allOf(hasStatus(304), hasHeader('foo', 'bar'))); }); test('shelf can throw error', () async { - var response = await client.get(_path('/error')); + var response = await client.get(path('/error')); expect(response, hasStatus(404)); }); test('throw on null', () async { - var response = await client.get(_path('/throw')); + var response = await client.get(path('/throw')); expect(response, hasStatus(500)); }); } diff --git a/packages/test/README.md b/packages/test/README.md index ec25181a..b2b66bd3 100644 --- a/packages/test/README.md +++ b/packages/test/README.md @@ -1,11 +1,11 @@ -# Angel3 Testing Library +# Angel3 Test ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_test?include_prereleases) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/test/LICENSE) -Testing utility library for the Angel3 framework. +Testing utility library for Angel3 framework. ## TestClient @@ -51,7 +51,7 @@ void test('error', () async { ```dart test('validate response', () async { var res = await client.get('/bar'); - expect(res, hasValidBody(new Validator({ + expect(res, hasValidBody(Validator({ 'foo': isBoolean, 'bar': [isString, equals('baz')], 'age*': [], diff --git a/packages/validate/README.md b/packages/validate/README.md index 81e0fd0f..e13ce601 100644 --- a/packages/validate/README.md +++ b/packages/validate/README.md @@ -1,17 +1,15 @@ -# Angel3 Request Validator +# Angel3 Validate ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_validate?include_prereleases) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/validate/LICENSE) -Validation library based on the `matcher` library, with Angel3 support. Why re-invent the wheel, when you can use the same validators you already use for tests? - -This library runs both on the server, and on the client. Thus, you can use the same validation rules for forms on the server, and on the frontend. +This validator library is based on the `matcher` library and comes with build in support for Angel3 framework. It can be run on both server and client side. Thus, the same validation rules apply to forms on both backend and frontend code. For convenience's sake, this library also exports `matcher`. -- [Angel3 Request Validator](#angel3-request-validator) +- [Angel3 Validate](#angel3-validate) - [Examples](#examples) - [Creating a Validator](#creating-a-validator) - [Validating data](#validating-data) @@ -25,7 +23,7 @@ For convenience's sake, this library also exports `matcher`. - [Extending Validators](#extending-validators) - [Bundled Matchers](#bundled-matchers) - [Nested Validators](#nested-validators) - - [Use with Angel](#use-with-angel) + - [Use with Angel3](#use-with-angel3) ## Examples @@ -82,9 +80,7 @@ main() { ### Required Fields -Fields are optional by default. - -Suffix a field name with a `'*'` to mark it as required, and to throw an error if it is not present. +Fields are optional by default. Suffix a field name with a `'*'` to mark it as required, and to throw an error if it is not present. ```dart main() { @@ -118,9 +114,7 @@ Default values can also be parameterless, *synchronous* functions that return a ### Custom Validator Functions -Creating a whole `Matcher` class is sometimes cumbersome, but if you pass a function to the constructor, it will be wrapped in a `Matcher` instance. - -(It simply returns the value of calling [`predicate`](https://pub.dev/documentation/matcher/latest/matcher/predicate.html).) +Creating a whole `Matcher` class is sometimes cumbersome, but if you pass a function to the constructor, it will be wrapped in a `Matcher` instance. (It simply returns the value of calling [`predicate`](https://pub.dev/documentation/matcher/latest/matcher/predicate.html).) The function must *synchronously* return a `bool`. @@ -151,8 +145,7 @@ The string `{{value}}` will be replaced inside your error message automatically. ### autoParse -Oftentimes, fields that we want to validate as numbers are passed as strings. -Calling `autoParse` will correct this before validation. +Oftentimes, fields that we want to validate as numbers are passed as strings. Calling `autoParse` will correct this before validation. ```dart main() { @@ -263,7 +256,7 @@ main() { } ``` -### Use with Angel +### Use with Angel3 `server.dart` exposes seven helper middleware: diff --git a/packages/validate/pubspec.yaml b/packages/validate/pubspec.yaml index c9869a5b..06b946e6 100644 --- a/packages/validate/pubspec.yaml +++ b/packages/validate/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_validate -description: Cross-platform request body validation library based on `matcher`. +description: Cross-platform HTTP request body validator library based on `matcher`. version: 8.0.0 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/validate diff --git a/packages/validate/test/async_test.dart b/packages/validate/test/async_test.dart deleted file mode 100644 index ab73b3a2..00000000 --- a/packages/validate/test/async_test.dart +++ /dev/null @@ -1 +0,0 @@ -void main() {} diff --git a/packages/validate/test/basic_test.dart b/packages/validate/test/basic_data_test.dart similarity index 93% rename from packages/validate/test/basic_test.dart rename to packages/validate/test/basic_data_test.dart index c40a6a41..68ea10e1 100644 --- a/packages/validate/test/basic_test.dart +++ b/packages/validate/test/basic_data_test.dart @@ -31,8 +31,7 @@ void main() { expect(() { todoSchema .enforce({'id': 'fool', 'text': 'Hello, world!', 'completed': 4}); - // ignore: deprecated_member_use - }, throwsA(isInstanceOf())); + }, throwsA(isA())); }); test('filter', () { diff --git a/packages/validate/test/complex_data_test.dart b/packages/validate/test/complex_data_test.dart new file mode 100644 index 00000000..23f0af56 --- /dev/null +++ b/packages/validate/test/complex_data_test.dart @@ -0,0 +1,66 @@ +import 'package:angel3_validate/angel3_validate.dart'; +import 'package:test/test.dart'; + +void main() { + final Validator orderItemSchema = Validator({ + 'id': [isInt, isPositive], + 'item_no': isString, + 'item_name': isString, + 'quantity': isInt, + 'description?': isString + }); + + final Validator orderSchema = Validator({ + 'id': [isInt, isPositive], + 'order_no': isString, + 'order_items*': [isList, everyElement(orderItemSchema)] + }, defaultValues: { + 'order_items': [] + }); + + group('json data', () { + test('validate with child element', () { + var orderItem = { + 'id': 1, + 'item_no': 'a1', + 'item_name': 'Apple', + 'quantity': 1 + }; + + var formData = { + 'id': 1, + 'order_no': '2', + 'order_items': [orderItem] + }; + var result = orderSchema.check(formData); + + expect(result.errors.isEmpty, true); + }); + + test('validate empty child', () { + var formData = {'id': 1, 'order_no': '2'}; + var result = orderSchema.check(formData); + + expect(result.errors.isEmpty, true); + }); + + test('validate invalid child field', () { + var orderItem = { + 'id': 1, + 'item_no': 'a1', + 'item_name': 'Apple', + 'quantity': 1, + 'description': 1 + }; + + var formData = { + 'id': 1, + 'order_no': '2', + 'order_items': [orderItem] + }; + var result = orderSchema.check(formData); + + expect(result.errors.isEmpty, false); + }); + }); +} diff --git a/packages/validate/test/context_aware_test.dart b/packages/validate/test/context_aware_test.dart deleted file mode 100644 index ab73b3a2..00000000 --- a/packages/validate/test/context_aware_test.dart +++ /dev/null @@ -1 +0,0 @@ -void main() {} diff --git a/packages/validate/test/server_test.dart b/packages/validate/test/server_test.dart index 31e0b20f..467c3f37 100644 --- a/packages/validate/test/server_test.dart +++ b/packages/validate/test/server_test.dart @@ -18,29 +18,27 @@ void printRecord(LogRecord rec) { } void main() { - Angel? app; + late Angel app; late AngelHttp http; //TestClient client; setUp(() async { app = Angel(); - http = AngelHttp(app!, useZone: false); + http = AngelHttp(app, useZone: false); - app!.chain([validate(echoSchema)]).post('/echo', + app.chain([validate(echoSchema)]).post('/echo', (RequestContext req, res) async { await req.parseBody(); res.write('Hello, ${req.bodyAsMap['message']}!'); }); - app!.logger = Logger('angel')..onRecord.listen(printRecord); + app.logger = Logger('angel3')..onRecord.listen(printRecord); //client = await connectTo(app); }); tearDown(() async { //await client.close(); await http.close(); - app = null; - //client = null; }); group('echo', () { diff --git a/packages/validate/web/index.html b/packages/validate/web/index.html index f3621c7a..803aef06 100644 --- a/packages/validate/web/index.html +++ b/packages/validate/web/index.html @@ -2,7 +2,7 @@ - angel_validate + angel3_validate