Revision control

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
@testable import Client
6
import Foundation
7
import Shared
8
import Storage
9
import SwiftKeychainWrapper
10
11
import XCTest
12
13
/*
14
* A base test type for tests that need a profile.
15
*/
16
class ProfileTest: XCTestCase {
17
func withTestProfile(_ callback: (_ profile: Client.Profile) -> Void) {
18
let profile = MockProfile(databasePrefix: "profile-test")
19
profile._reopen()
20
callback(profile)
21
profile._shutdown()
22
}
23
24
func testNewProfileClearsExistingAuthenticationInfo() {
25
let authInfo = AuthenticationKeychainInfo(passcode: "1234")
26
KeychainWrapper.sharedAppContainerKeychain.setAuthenticationInfo(authInfo)
27
XCTAssertNotNil(KeychainWrapper.sharedAppContainerKeychain.authenticationInfo())
28
let _ = BrowserProfile(localName: "my_profile", clear: true)
29
XCTAssertNil(KeychainWrapper.sharedAppContainerKeychain.authenticationInfo())
30
}
31
}