Skip to content

Commit beb3f4f

Browse files
committed
Revert changes to app password deletion
1 parent 7c4ca45 commit beb3f4f

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

WooCommerce/Classes/System/SessionManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ final class SessionManager: SessionManagerProtocol {
200200
/// Nukes all of the known Session's properties.
201201
///
202202
func reset() {
203+
deleteApplicationPassword()
203204
defaultAccount = nil
204205
defaultCredentials = nil
205206
defaultStoreID = nil

WooCommerce/Classes/Yosemite/DefaultStoresManager.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ class DefaultStoresManager: StoresManager {
246246
applicationPasswordGenerationFailureObserver = nil
247247

248248
if isAuthenticated {
249-
if case .wpcom = sessionManager.defaultCredentials {
250-
// TODO: fetch site list and delete password for each site
251-
} else {
252-
sessionManager.deleteApplicationPassword()
253-
}
254249
let resetAction = CardPresentPaymentAction.reset
255250
dispatch(resetAction)
256251
}

WooCommerce/WooCommerceTests/System/SessionManagerTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,28 @@ final class SessionManagerTests: XCTestCase {
106106
}
107107
}
108108

109+
/// Verifies that application password is deleted upon reset
110+
///
111+
func test_application_password_is_deleted_upon_reset() {
112+
// Given
113+
manager.defaultCredentials = Settings.wporgCredentials
114+
let storage = ApplicationPasswordStorage(keychain: Keychain(service: Settings.keychainServiceName))
115+
116+
// When
117+
storage.saveApplicationPassword(applicationPassword)
118+
119+
// Then
120+
XCTAssertNotNil(storage.applicationPassword)
121+
122+
// When
123+
manager.reset()
124+
125+
// Then
126+
waitUntil {
127+
storage.applicationPassword == nil
128+
}
129+
}
130+
109131
/// Verifies that `storePhoneNumber` is set to `nil` upon reset
110132
///
111133
func test_storePhoneNumber_is_set_to_nil_upon_reset() throws {

WooCommerce/WooCommerceTests/Yosemite/StoresManagerTests.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -421,32 +421,6 @@ final class StoresManagerTests: XCTestCase {
421421
XCTAssertNil(defaults[UserDefaults.Key.numberOfTimesWriteWithAITooltipIsShown])
422422
}
423423

424-
func test_deauthenticate_triggers_deleteApplicationPassword_in_sessionManager_when_authenticated_with_site_credentials() {
425-
// Given
426-
let mockSessionManager = MockSessionManager()
427-
mockSessionManager.defaultCredentials = .wporg(username: "miffy", password: "secret", siteAddress: "https://example.com")
428-
let sut = DefaultStoresManager(sessionManager: mockSessionManager)
429-
430-
// When
431-
sut.deauthenticate()
432-
433-
// Then
434-
XCTAssertTrue(mockSessionManager.deleteApplicationPasswordInvoked)
435-
}
436-
437-
func test_deauthenticate_triggers_deleteApplicationPassword_in_sessionManager_when_authenticated_with_app_password() {
438-
// Given
439-
let mockSessionManager = MockSessionManager()
440-
mockSessionManager.defaultCredentials = .applicationPassword(username: "miffy", password: "secret", siteAddress: "https://example.com")
441-
let sut = DefaultStoresManager(sessionManager: mockSessionManager)
442-
443-
// When
444-
sut.deauthenticate()
445-
446-
// Then
447-
XCTAssertTrue(mockSessionManager.deleteApplicationPasswordInvoked)
448-
}
449-
450424
/// Verifies that user is logged out when application password regeneration fails
451425
///
452426
func test_it_deauthenticates_upon_receiving_application_password_generation_failure_notification() {

0 commit comments

Comments
 (0)