@@ -9,6 +9,7 @@ import XCTest
9
9
10
10
@testable import Amplify
11
11
@testable import AWSPluginsCore
12
+ import AWSClientRuntime
12
13
13
14
class AWSAuthServiceTests : XCTestCase {
14
15
@@ -153,4 +154,41 @@ class AWSAuthServiceTests: XCTestCase {
153
154
154
155
XCTAssertEqual ( iat, 1_551_307_661 )
155
156
}
157
+
158
+
159
+ /// Given: A credentials that will expire after 100 second
160
+ /// When: I convert the credentials to AWS SDK ClientRuntime
161
+ /// Then: I should get a valid CRT credentials
162
+ func testValidCredentialsToCRTConversion( ) throws {
163
+
164
+ let credentials = MockCredentials (
165
+ sessionToken: " somesession " ,
166
+ accessKeyId: " accessKeyId " ,
167
+ secretAccessKey: " secretAccessKey " ,
168
+ expiration: Date ( ) . addingTimeInterval ( 100 ) )
169
+ let sdkCredentials = credentials. toAWSSDKCredentials ( )
170
+ XCTAssertNotNil ( sdkCredentials)
171
+ }
172
+
173
+ /// Given: A credentials that expired 100 second back
174
+ /// When: I convert the credentials to AWS SDK ClientRuntime
175
+ /// Then: I should get a valid CRT credentials
176
+ func testExpiredCredentialsToCRTConversion( ) throws {
177
+
178
+ let credentials = MockCredentials (
179
+ sessionToken: " somesession " ,
180
+ accessKeyId: " accessKeyId " ,
181
+ secretAccessKey: " secretAccessKey " ,
182
+ expiration: Date ( ) . addingTimeInterval ( - 100 ) )
183
+ let sdkCredentials = credentials. toAWSSDKCredentials ( )
184
+ XCTAssertNotNil ( sdkCredentials)
185
+ }
186
+ }
187
+
188
+
189
+ struct MockCredentials : AWSTemporaryCredentials {
190
+ let sessionToken : String
191
+ let accessKeyId : String
192
+ let secretAccessKey : String
193
+ let expiration : Date
156
194
}
0 commit comments