Allow FxA profile to refresh even when there exists a profile

This commit is contained in:
Nishant Bhasin 2020-04-21 17:12:46 -04:00 коммит произвёл Edouard Oger
Родитель dc813e2f50
Коммит b2b66cb7c6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A2F740742307674A
3 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -524,6 +524,15 @@ open class FxAccountManager {
)
}
}
case let .fetchProfile(refresh): do {
FxALog.info("Refreshing profile...")
do {
profile = try requireAccount().getProfile(forceRefresh: refresh)
} catch {
return Event.failedToFetchProfile
}
return Event.fetchedProfile
}
default: break // Do nothing
}
}

Просмотреть файл

@ -86,6 +86,8 @@ extension FxAccountManager {
}
case .authenticatedWithProfile:
switch event {
case .fetchProfile: return .authenticatedWithProfile
case .fetchedProfile: return .authenticatedWithProfile
case .authenticationError: return .authenticationProblem
case .changedPassword: return .authenticatedNoProfile
case .logout: return .notAuthenticated

Просмотреть файл

@ -74,8 +74,8 @@ class FxAccountManagerTests: XCTestCase {
XCTAssertNil(FxAccountManager.nextState(state: state, event: .accountRestored))
XCTAssertNil(FxAccountManager.nextState(state: state, event: .authenticated(authData: FxaAuthData(code: "foo", state: "bar", actionQueryParam: "bobo"))))
XCTAssertEqual(.authenticationProblem, FxAccountManager.nextState(state: state, event: .authenticationError))
XCTAssertNil(FxAccountManager.nextState(state: state, event: .fetchProfile(forceRefresh: false)))
XCTAssertNil(FxAccountManager.nextState(state: state, event: .fetchedProfile))
XCTAssertEqual(.authenticatedWithProfile, FxAccountManager.nextState(state: state, event: .fetchProfile(forceRefresh: false)))
XCTAssertEqual(.authenticatedWithProfile, FxAccountManager.nextState(state: state, event: .fetchedProfile))
XCTAssertNil(FxAccountManager.nextState(state: state, event: .failedToFetchProfile))
XCTAssertEqual(.notAuthenticated, FxAccountManager.nextState(state: state, event: .logout))
XCTAssertNil(FxAccountManager.nextState(state: state, event: .recoveredFromAuthenticationProblem))