Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that test secure storage access impl shares and returns token data #415

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ public class DBXSecureStorageAccessTestImpl: DBXSecureStorageAccessImpl {
}

public class SecureStorageAccessTestImpl: SecureStorageAccess {
private var accessTokenData: Data?
private static var accessTokenData: Data?

public init() {}

public func checkAccessibilityMigrationOneTime() {}

public func setAccessTokenData(for userId: String, data: Data) -> Bool {
accessTokenData = data
Self.accessTokenData = data
return true
}

public func getAllUserIds() -> [String] {
[]
[TestAuthTokenGenerator.testUid]
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class TeamRoutesTests: XCTestCase {
apiAppKey,
transportClient: transportClient,
secureStorageAccess: SecureStorageAccessTestImpl(),
tokenUid: TestUid
tokenUid: TestAuthTokenGenerator.testUid
)
#elseif os(iOS)
DropboxClientsManager.setupWithTeamAppKeyMultiUser(
apiAppKey,
transportClient: transportClient,
secureStorageAccess: SecureStorageAccessTestImpl(),
tokenUid: TestUid
tokenUid: TestAuthTokenGenerator.testUid
)
#endif

Expand Down
5 changes: 3 additions & 2 deletions TestSwiftyDropbox/TestUtils/TestTokenAuthGenerator.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@testable import SwiftyDropbox
import XCTest

let TestUid = "test" // non-empty string needed here as subsequent tokens will share the uid and macOS keychain drops the attribute if empty
enum TestAuthTokenGenerator {
static let testUid = "test" // non-empty string needed here as subsequent tokens will share the uid and macOS keychain drops the attribute if empty

static func transportClient(with refreshToken: String, apiKey: String, scopes: [String]) -> DropboxTransportClient? {
let manager = SwiftyDropbox.DropboxOAuthManager(appKey: apiKey, secureStorageAccess: SecureStorageAccessTestImpl())

let defaultToken = DropboxAccessToken(
accessToken: "",
uid: TestUid,
uid: Self.testUid,
refreshToken: refreshToken,
tokenExpirationTimestamp: 0
)
Expand Down
Loading