Skip to content

Conversation

nlutsenko
Copy link
Contributor

Fixes #467.

Used this piece of code to test:

- (void)testLinkWithStripsNewDataOnFail {
    id mock = PFStrictProtocolMock(@protocol(PFUserAuthenticationDelegate));
    [PFUser registerAuthenticationDelegate:mock forAuthType:@"a"];
    OCMStub([mock restoreAuthenticationWithAuthData:@{ @"a" : @"b" }]).andReturn(YES);

    PFUser *user = [PFUser user];
    user.username = @"yolo";
    user.password = @"yarr";
    XCTAssertTrue([user signUp:nil]);

    XCTestExpectation *linkExpectation = [self expectationWithDescription:@"link user"];
    [[user linkWithAuthTypeInBackground:@"a" authData:@{ @"a" : @"b" }] continueWithBlock:^id(BFTask<NSNumber *> *task) {
        XCTAssertTrue(task.faulted);
        XCTAssertNotNil(task.error);
        [linkExpectation fulfill];
        return nil;
    }];
    [self waitForTestExpectations];
    XCTAssertFalse([user isLinkedWithAuthType:@"a"]);

    [self simulateApplicationReboot];

    user = [PFUser currentUser];
    XCTAssertFalse([user isLinkedWithAuthType:@"a"]);
}

@nlutsenko nlutsenko added this to the 1.10.0 milestone Oct 26, 2015
nlutsenko added a commit that referenced this pull request Oct 27, 2015
Fix an issue with persistent bad authData on failure to link a user.
@nlutsenko nlutsenko merged commit 9de425b into master Oct 27, 2015
@nlutsenko nlutsenko deleted the nlutsenko.user.link branch October 27, 2015 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants