From 4a9621cbbe51d4eacd1556fa7dbcbc4b65b298bf Mon Sep 17 00:00:00 2001 From: Frank Merkel <138444693+frankmer@users.noreply.github.com> Date: Mon, 9 Dec 2024 08:51:06 +0100 Subject: [PATCH] fixed PushToken TTL_MINUTES validation --- lib/model/tokens/push_token.dart | 5 +--- .../model/processor_result_test.dart | 30 +++++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/model/tokens/push_token.dart b/lib/model/tokens/push_token.dart index 4e32ae87e..1c29dedca 100644 --- a/lib/model/tokens/push_token.dart +++ b/lib/model/tokens/push_token.dart @@ -219,10 +219,7 @@ class PushToken extends Token { Token.ISSUER: const ObjectValidatorNullable(defaultValue: ''), Token.SERIAL: const ObjectValidator(), SSL_VERIFY: boolValidator.withDefault(true), - TTL_MINUTES: ObjectValidator( - transformer: (v) => Duration(minutes: int.parse(v)), - defaultValue: const Duration(minutes: 10), - ), + TTL_MINUTES: intValidatorNullable, ENROLLMENT_CREDENTIAL: const ObjectValidatorNullable(), ROLLOUT_URL: stringToUrivalidator, Token.IMAGE: stringToUriValidatorNullable, diff --git a/test/unit_test/model/processor_result_test.dart b/test/unit_test/model/processor_result_test.dart index 12194cdbe..1094bd35b 100644 --- a/test/unit_test/model/processor_result_test.dart +++ b/test/unit_test/model/processor_result_test.dart @@ -20,15 +20,41 @@ void _testProcessorResult() { }); group('factories', () { test('success', () { - ProcessorResult result = const ProcessorResult.success('data'); + const ProcessorResult result = ProcessorResult.success('data'); expect(result, isA()); expect((result as ProcessorResultSuccess).resultData, 'data'); }); test('error', () { - const result = ProcessorResult.failed('error'); + const ProcessorResult result = ProcessorResult.failed('error'); expect(result, isA()); expect((result as ProcessorResultFailed).message, 'error'); }); }); + + group('is', () { + test('success', () { + const ProcessorResult result = ProcessorResultSuccess('data'); + expect(result.isSuccess, isTrue); + expect(result.isFailed, isFalse); + }); + test('error', () { + const ProcessorResult result = ProcessorResultFailed('error'); + expect(result.isSuccess, isFalse); + expect(result.isFailed, isTrue); + }); + }); + + group('as', () { + test('success', () { + const ProcessorResult result = ProcessorResultSuccess('data'); + expect(result.asSuccess, 'data'); + expect(() => result.asFailed, throwsA(isA())); + }); + test('error', () { + const ProcessorResult result = ProcessorResultFailed('error'); + expect(result.asFailed, 'error'); + expect(() => result.asSuccess, throwsA(isA())); + }); + }); }); }