@@ -9,10 +9,12 @@ import 'dart:io';
9
9
import 'package:_pub_shared/data/package_api.dart' show UploadInfo;
10
10
import 'package:_pub_shared/data/task_payload.dart' ;
11
11
import 'package:clock/clock.dart' ;
12
+ import 'package:gcloud/db.dart' ;
12
13
import 'package:http/http.dart' as http;
13
14
import 'package:http_parser/http_parser.dart' show MediaType;
14
15
import 'package:indexed_blob/indexed_blob.dart' ;
15
16
import 'package:pana/pana.dart' ;
17
+ import 'package:pub_dev/shared/versions.dart' ;
16
18
import 'package:pub_dev/task/backend.dart' ;
17
19
import 'package:pub_dev/task/cloudcompute/fakecloudcompute.dart' ;
18
20
import 'package:pub_dev/task/models.dart' ;
@@ -695,6 +697,7 @@ void main() {
695
697
await taskBackend.backfillTrackingState ();
696
698
await taskBackend.start ();
697
699
await clockControl.elapse (minutes: 15 );
700
+ late VersionTokenPair v;
698
701
{
699
702
final instances = await cloud.listInstances ().toList ();
700
703
// There is only one package, so we should only get one instance
@@ -705,7 +708,7 @@ void main() {
705
708
706
709
// There should only be one version
707
710
expect (payload.versions, hasLength (1 ));
708
- final v = payload.versions.first;
711
+ v = payload.versions.first;
709
712
710
713
// Create new versions, removing the token from the first version
711
714
await importProfile (
@@ -729,6 +732,13 @@ void main() {
729
732
730
733
await clockControl.elapse (minutes: 15 );
731
734
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
+
732
742
// Use token to get the upload information
733
743
final api = createPubApiClient (authToken: v.token);
734
744
await expectApiException (
@@ -752,6 +762,34 @@ void main() {
752
762
// Leave time for the instance to be deleted (takes 1 min in fake cloud)
753
763
await clockControl.elapse (minutes: 5 );
754
764
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
+
755
793
await taskBackend.stop ();
756
794
757
795
await clockControl.elapse (minutes: 10 );
0 commit comments