-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathProfileTest.swift
47 lines (37 loc) · 1.36 KB
/
ProfileTest.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@testable import Client
@testable import Account
import Foundation
import Shared
import Storage
import SwiftKeychainWrapper
import XCTest
/*
* A base test type for tests that need a profile.
*/
class ProfileTest: XCTestCase {
var profile: MockProfile?
override func setUp() {
super.setUp()
continueAfterFailure = false
// Setup mock profile
profile = MockProfile(databasePrefix: "profile-test")
}
func withTestProfile(_ callback: (_ profile: Client.Profile) -> Void) {
guard let mockProfile = profile else {
return
}
mockProfile._reopen()
callback(mockProfile)
mockProfile._shutdown()
}
func testNewProfileClearsExistingAuthenticationInfo() {
let authInfo = AuthenticationKeychainInfo(passcode: "1234")
KeychainWrapper.sharedAppContainerKeychain.setAuthenticationInfo(authInfo)
XCTAssertNotNil(KeychainWrapper.sharedAppContainerKeychain.authenticationInfo())
let _ = BrowserProfile(localName: "my_profile", clear: true)
XCTAssertNil(KeychainWrapper.sharedAppContainerKeychain.authenticationInfo())
}
}