@@ -9,10 +9,12 @@ import 'dart:io';
99import 'package:_pub_shared/data/package_api.dart' show UploadInfo;
1010import 'package:_pub_shared/data/task_payload.dart' ;
1111import 'package:clock/clock.dart' ;
12+ import 'package:gcloud/db.dart' ;
1213import 'package:http/http.dart' as http;
1314import 'package:http_parser/http_parser.dart' show MediaType;
1415import 'package:indexed_blob/indexed_blob.dart' ;
1516import 'package:pana/pana.dart' ;
17+ import 'package:pub_dev/shared/versions.dart' ;
1618import 'package:pub_dev/task/backend.dart' ;
1719import 'package:pub_dev/task/cloudcompute/fakecloudcompute.dart' ;
1820import 'package:pub_dev/task/models.dart' ;
@@ -695,6 +697,7 @@ void main() {
695697 await taskBackend.backfillTrackingState ();
696698 await taskBackend.start ();
697699 await clockControl.elapse (minutes: 15 );
700+ late VersionTokenPair v;
698701 {
699702 final instances = await cloud.listInstances ().toList ();
700703 // There is only one package, so we should only get one instance
@@ -705,7 +708,7 @@ void main() {
705708
706709 // There should only be one version
707710 expect (payload.versions, hasLength (1 ));
708- final v = payload.versions.first;
711+ v = payload.versions.first;
709712
710713 // Create new versions, removing the token from the first version
711714 await importProfile (
@@ -729,6 +732,13 @@ void main() {
729732
730733 await clockControl.elapse (minutes: 15 );
731734
735+ // verify token is now aborted
736+ final ps = await dbService.lookupValue <PackageState >(
737+ PackageState .createKey (dbService.emptyKey, runtimeVersion, 'neon' ));
738+ expect (ps.versions? [v.version]? .secretToken, isNull);
739+ expect (ps.abortedTokens, isNotEmpty);
740+ expect (ps.abortedTokens? .where ((x) => x.token == v.token), isNotEmpty);
741+
732742 // Use token to get the upload information
733743 final api = createPubApiClient (authToken: v.token);
734744 await expectApiException (
@@ -752,6 +762,34 @@ void main() {
752762 // Leave time for the instance to be deleted (takes 1 min in fake cloud)
753763 await clockControl.elapse (minutes: 5 );
754764
765+ {
766+ await clockControl.elapseTime (maxTaskExecutionTime);
767+ // Create new version, removing the token from the aborted list
768+ await importProfile (
769+ profile: TestProfile (
770+ 771+ generatedPackages: [
772+ GeneratedTestPackage (
773+ name: 'neon' ,
774+ versions: [GeneratedTestVersion (version: '6.0.0' )],
775+ ),
776+ ],
777+ ),
778+ );
779+ final ps = await dbService.lookupValue <PackageState >(
780+ PackageState .createKey (dbService.emptyKey, runtimeVersion, 'neon' ));
781+ expect (ps.abortedTokens? .where ((x) => x.token == v.token), isEmpty);
782+
783+ // Report the task as finished
784+ final api = createPubApiClient (authToken: v.token);
785+ await expectApiException (
786+ api.taskUploadFinished ('neon' , v.version),
787+ status: 400 ,
788+ code: 'TaskAborted' ,
789+ message: 'The provided token is invalid or expired.' ,
790+ );
791+ }
792+
755793 await taskBackend.stop ();
756794
757795 await clockControl.elapse (minutes: 10 );
0 commit comments