Skip to content

Commit 2b3a68f

Browse files
mhartvickrogerhu
authored andcommitted
Test for failed auth data not cleared + fix (#787)
1 parent 71d9d9b commit 2b3a68f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Parse/src/main/java/com/parse/ParseUser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ private Task<Void> linkWithAsync(
12941294
public Task<Void> then(Task<Void> task) throws Exception {
12951295
synchronized (mutex) {
12961296
if (task.isFaulted() || task.isCancelled()) {
1297+
removeAuthData(authType);
12971298
restoreAnonymity(oldAnonymousData);
12981299
return task;
12991300
}

Parse/src/test/java/com/parse/ParseUserTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,13 +699,13 @@ public void testlinkWithInBackgroundWithSaveAsyncFailure() throws Exception {
699699
partialMockUser.linkWithInBackground(authType, authData);
700700
linkTask.waitForCompletion();
701701

702-
// Make sure new authData is added
703-
assertSame(authData, partialMockUser.getAuthData().get(authType));
704702
// Make sure we save the user
705703
verify(partialMockUser, times(1))
706704
.saveAsync(eq("sessionTokenAgain"), eq(false), Matchers.<Task<Void>>any());
707705
// Make sure old authData is restored
708706
assertSame(anonymousAuthData, partialMockUser.getAuthData().get(ParseAnonymousUtils.AUTH_TYPE));
707+
// Make sure failed new authData is cleared
708+
assertNull(partialMockUser.getAuthData().get("facebook"));
709709
// Verify exception
710710
assertSame(saveException, linkTask.getError());
711711
}

0 commit comments

Comments
 (0)