generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-12012] Save region during account creation (#946)
- Loading branch information
1 parent
fe37cb6
commit a8d5a6c
Showing
12 changed files
with
263 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -707,6 +707,21 @@ class StateServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body | |
XCTAssertNil(urls) | ||
} | ||
|
||
/// `getAccountCreationEnvironmentUrls` returns the saved pre-auth URLs for a given email. | ||
func test_getAccountCreationEnvironmentUrls() async { | ||
let email = "[email protected]" | ||
let urls = EnvironmentUrlData(base: .example) | ||
appSettingsStore.setAccountCreationEnvironmentUrls(environmentUrlData: urls, email: email) | ||
let preAuthUrls = await subject.getAccountCreationEnvironmentUrls(email: email) | ||
XCTAssertEqual(preAuthUrls, urls) | ||
} | ||
|
||
/// `getAccountCreationEnvironmentUrls` returns `nil` if the URLs haven't been set for a given email. | ||
func test_getAccountCreationEnvironmentUrls_notSet() async { | ||
let urls = await subject.getAccountCreationEnvironmentUrls(email: "[email protected]") | ||
XCTAssertNil(urls) | ||
} | ||
|
||
/// `getPreAuthServerConfig` returns the saved pre-auth server config. | ||
func test_getPreAuthServerConfig() async { | ||
let config = ServerConfig( | ||
|
@@ -1606,6 +1621,14 @@ class StateServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body | |
XCTAssertEqual(appSettingsStore.preAuthEnvironmentUrls, urls) | ||
} | ||
|
||
/// `test_setAccountCreationEnvironmentUrls` saves the pre-auth URLs for email for a given email. | ||
func test_setAccountCreationEnvironmentUrls() async { | ||
let email = "[email protected]" | ||
let urls = EnvironmentUrlData(base: .example) | ||
await subject.setAccountCreationEnvironmentUrls(urls: urls, email: email) | ||
XCTAssertEqual(appSettingsStore.accountCreationEnvironmentUrls(email: email), urls) | ||
} | ||
|
||
/// `setPreAuthServerConfig(config:)` saves the pre-auth server config. | ||
func test_setPreAuthServerConfig() async { | ||
let config = ServerConfig( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,6 +616,43 @@ class AppSettingsStoreTests: BitwardenTestCase { // swiftlint:disable:this type_ | |
) | ||
} | ||
|
||
/// `accountCreationEnvironmentUrls` returns `nil` if there isn't a previously stored value. | ||
func test_accountCreationEnvironmentUrls_isInitiallyNil() { | ||
XCTAssertNil(subject.accountCreationEnvironmentUrls(email: "[email protected]")) | ||
} | ||
|
||
/// `accountCreationEnvironmentUrls` can be used to get and set the persisted value in user defaults. | ||
func test_accountCreationEnvironmentUrls_withValue() { | ||
let email = "[email protected]" | ||
subject.setAccountCreationEnvironmentUrls(environmentUrlData: .defaultUS, email: email) | ||
XCTAssertEqual(subject.accountCreationEnvironmentUrls(email: email), .defaultUS) | ||
try XCTAssertEqual( | ||
JSONDecoder().decode( | ||
EnvironmentUrlData.self, | ||
from: XCTUnwrap( | ||
userDefaults | ||
.string(forKey: "bwPreferencesStorage:accountCreationEnvironmentUrls_\(email)")? | ||
.data(using: .utf8) | ||
) | ||
), | ||
.defaultUS | ||
) | ||
|
||
subject.setAccountCreationEnvironmentUrls(environmentUrlData: .defaultEU, email: email) | ||
XCTAssertEqual(subject.accountCreationEnvironmentUrls(email: email), .defaultEU) | ||
try XCTAssertEqual( | ||
JSONDecoder().decode( | ||
EnvironmentUrlData.self, | ||
from: XCTUnwrap( | ||
userDefaults | ||
.string(forKey: "bwPreferencesStorage:accountCreationEnvironmentUrls_\(email)")? | ||
.data(using: .utf8) | ||
) | ||
), | ||
.defaultEU | ||
) | ||
} | ||
|
||
/// `preAuthServerConfig` is initially `nil` | ||
func test_preAuthServerConfig_isInitiallyNil() { | ||
XCTAssertNil(subject.preAuthServerConfig) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.