Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up authData when linkWithAsync() fails #787

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Parse/src/main/java/com/parse/ParseUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ private Task<Void> linkWithAsync(
public Task<Void> then(Task<Void> task) throws Exception {
synchronized (mutex) {
if (task.isFaulted() || task.isCancelled()) {
removeAuthData(authType);
restoreAnonymity(oldAnonymousData);
return task;
}
Expand Down
4 changes: 2 additions & 2 deletions Parse/src/test/java/com/parse/ParseUserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,13 @@ public void testlinkWithInBackgroundWithSaveAsyncFailure() throws Exception {
partialMockUser.linkWithInBackground(authType, authData);
linkTask.waitForCompletion();

// Make sure new authData is added
assertSame(authData, partialMockUser.getAuthData().get(authType));
Copy link
Contributor Author

@mhartvick mhartvick Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same test/comment from testlinkWithInBackgroundWithSaveAsyncSuccess() above, which makes me think it was expected in the test only because it was copied

// Make sure we save the user
verify(partialMockUser, times(1))
.saveAsync(eq("sessionTokenAgain"), eq(false), Matchers.<Task<Void>>any());
// Make sure old authData is restored
assertSame(anonymousAuthData, partialMockUser.getAuthData().get(ParseAnonymousUtils.AUTH_TYPE));
// Make sure failed new authData is cleared
assertNull(partialMockUser.getAuthData().get("facebook"));
// Verify exception
assertSame(saveException, linkTask.getError());
}
Expand Down