Skip to content

Commit fd8e029

Browse files
author
Julian Locke
authored
Ensure that test secure storage access impl shares and returns token data (#415)
1 parent 5fd733f commit fd8e029

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

TestSwiftyDropbox/TestSwiftyDropbox_iOSTests/SwiftyDropboxTestExtensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ public class DBXSecureStorageAccessTestImpl: DBXSecureStorageAccessImpl {
3030
}
3131

3232
public class SecureStorageAccessTestImpl: SecureStorageAccess {
33-
private var accessTokenData: Data?
33+
private static var accessTokenData: Data?
3434

3535
public init() {}
3636

3737
public func checkAccessibilityMigrationOneTime() {}
3838

3939
public func setAccessTokenData(for userId: String, data: Data) -> Bool {
40-
accessTokenData = data
40+
Self.accessTokenData = data
4141
return true
4242
}
4343

4444
public func getAllUserIds() -> [String] {
45-
[]
45+
[TestAuthTokenGenerator.testUid]
4646
}
4747

4848
public func getDropboxAccessToken(for key: String) -> DropboxAccessToken? {
49-
guard let accessTokenData = accessTokenData else {
49+
guard let accessTokenData = Self.accessTokenData else {
5050
return nil
5151
}
5252

TestSwiftyDropbox/TestSwiftyDropbox_iOSTests/TeamRoutesTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ class TeamRoutesTests: XCTestCase {
5656
apiAppKey,
5757
transportClient: transportClient,
5858
secureStorageAccess: SecureStorageAccessTestImpl(),
59-
tokenUid: TestUid
59+
tokenUid: TestAuthTokenGenerator.testUid
6060
)
6161
#elseif os(iOS)
6262
DropboxClientsManager.setupWithTeamAppKeyMultiUser(
6363
apiAppKey,
6464
transportClient: transportClient,
6565
secureStorageAccess: SecureStorageAccessTestImpl(),
66-
tokenUid: TestUid
66+
tokenUid: TestAuthTokenGenerator.testUid
6767
)
6868
#endif
6969

TestSwiftyDropbox/TestUtils/TestTokenAuthGenerator.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
@testable import SwiftyDropbox
22
import XCTest
33

4-
let TestUid = "test" // non-empty string needed here as subsequent tokens will share the uid and macOS keychain drops the attribute if empty
54
enum TestAuthTokenGenerator {
5+
static let testUid = "test" // non-empty string needed here as subsequent tokens will share the uid and macOS keychain drops the attribute if empty
6+
67
static func transportClient(with refreshToken: String, apiKey: String, scopes: [String]) -> DropboxTransportClient? {
78
let manager = SwiftyDropbox.DropboxOAuthManager(appKey: apiKey, secureStorageAccess: SecureStorageAccessTestImpl())
89

910
let defaultToken = DropboxAccessToken(
1011
accessToken: "",
11-
uid: TestUid,
12+
uid: Self.testUid,
1213
refreshToken: refreshToken,
1314
tokenExpirationTimestamp: 0
1415
)

0 commit comments

Comments
 (0)