diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index f9265b5..b1d0b27 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -25,3 +25,11 @@ jobs: run: pub get - name: Run tests run: pub run test + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cedx/setup-dart@v2 + with: + release-channel: dev + - run: _tool/test-coverage.sh diff --git a/.gitignore b/.gitignore index 84f5bfe..cad9560 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ doc/api/ /test_v4.kdbx /test_v4x.kdbx /test_output*.kdbx + +/coverage + diff --git a/_tool/test-coverage.sh b/_tool/test-coverage.sh index e749918..e28dfd8 100755 --- a/_tool/test-coverage.sh +++ b/_tool/test-coverage.sh @@ -1,24 +1,51 @@ #!/bin/bash # WARNING: +# Running coverage tests with kdbx 3 seems to be too slow right now, so we only run kdbx 4 tests +# (kdbx4 with argon2 runs on native code, so no code coverage is collected there, vs. +# kdbx3's AES KDF runs in dart). +# # This is way too slow. Probably because of cryptography with coverage colleciton. # https://github.com/dart-lang/coverage/issues/261 +# +# This script requires `jq`, `curl`, `git`. set -xeu cd "${0%/*}"/.. - pub get -pub global activate test_coverage +pub global activate coverage fail=false -pub global run test_coverage || fail=true +dart test --exclude-tags kdbx4 --coverage coverage || fail=true echo "fail=$fail" + +# shellcheck disable=SC2038 +# shellcheck disable=SC2046 +jq -s '{coverage: [.[].coverage] | flatten}' $(find coverage -name '*.json' | xargs) > coverage/merged_json.cov + +pub global run coverage:format_coverage --packages=.packages -i coverage/merged_json.cov -l > coverage/lcov.info + bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info + test "$fail" == "true" && exit 1 echo "Success 🎉️" exit 0 + +#pub get +#pub global activate test_coverage +# +#fail=false +#pub global run test_coverage || fail=true +#echo "fail=$fail" +#bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info +# +#test "$fail" == "true" && exit 1 +# +#echo "Success 🎉️" +# +#exit 0 diff --git a/lib/src/kdbx_deleted_object.dart b/lib/src/kdbx_deleted_object.dart new file mode 100644 index 0000000..35593b7 --- /dev/null +++ b/lib/src/kdbx_deleted_object.dart @@ -0,0 +1,20 @@ +import 'package:kdbx/kdbx.dart'; +import 'package:kdbx/src/kdbx_xml.dart'; +import 'package:xml/xml.dart'; + +class KdbxDeletedObject extends KdbxNode implements KdbxNodeContext { + KdbxDeletedObject.create(this.ctx, KdbxUuid uuid) + : super.create('DeletedObject') { + _uuid.set(uuid); + deletionTime.setToNow(); + } + + KdbxDeletedObject.read(XmlElement node, this.ctx) : super.read(node); + + @override + final KdbxReadWriteContext ctx; + + KdbxUuid get uuid => _uuid.get(); + UuidNode get _uuid => UuidNode(this, KdbxXml.NODE_UUID); + DateTimeUtcNode get deletionTime => DateTimeUtcNode(this, 'DeletionTime'); +}