@@ -41,21 +41,35 @@ void main() {
4141 expect (temp.expiration, equals (expiration));
4242 });
4343
44- test ('defaults expiration to 1 hour when not provided' , () async {
45- const v2Creds = v2.AWSCredentials (
46- 'accessKey' ,
47- 'secretKey' ,
48- 'sessionToken' ,
49- );
50- const v2Provider = v2.AWSCredentialsProvider (v2Creds);
51- const bridge = V2CredentialsProviderBridge (v2Provider);
44+ test (
45+ 'throws when session token is present but expiration is null' ,
46+ () async {
47+ const v2Creds = v2.AWSCredentials (
48+ 'accessKey' ,
49+ 'secretKey' ,
50+ 'sessionToken' ,
51+ );
52+ const v2Provider = v2.AWSCredentialsProvider (v2Creds);
53+ const bridge = V2CredentialsProviderBridge (v2Provider);
5254
53- final before = DateTime . now (). add ( const Duration (minutes : 59 ) );
54- final v3Creds = await bridge. resolve () as v3. TemporaryCredentials ;
55- final after = DateTime . now (). add ( const Duration (hours : 1 , minutes : 1 ) );
55+ expect (bridge. resolve (), throwsStateError );
56+ },
57+ );
5658
57- expect (v3Creds.expiration.isAfter (before), isTrue);
58- expect (v3Creds.expiration.isBefore (after), isTrue);
59- });
59+ test (
60+ 'throws when expiration is present but session token is null' ,
61+ () async {
62+ final v2Creds = v2.AWSCredentials (
63+ 'accessKey' ,
64+ 'secretKey' ,
65+ null ,
66+ DateTime .now ().add (const Duration (hours: 1 )),
67+ );
68+ final v2Provider = v2.AWSCredentialsProvider (v2Creds);
69+ final bridge = V2CredentialsProviderBridge (v2Provider);
70+
71+ expect (bridge.resolve (), throwsStateError);
72+ },
73+ );
6074 });
6175}
0 commit comments