From 8c3ef6b780d5b9b116c693b3b440dcc7f68b4827 Mon Sep 17 00:00:00 2001 From: Xiangtian Dai Date: Fri, 11 Aug 2017 17:12:11 -0700 Subject: Handles MISSING_EMAIL error from server. (#187) --- .../Tests/FIRGetOOBConfirmationCodeResponseTests.m | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Example') diff --git a/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m b/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m index e722c9d..1cac822 100644 --- a/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m +++ b/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m @@ -53,6 +53,11 @@ static NSString *const kTestOOBCode = @"OOBCode"; */ static NSString *const kEmailNotFoundMessage = @"EMAIL_NOT_FOUND: fake custom message"; +/** @var kMissingEmailErrorMessage + @brief The value of the "message" field returned for a "missing email" error. + */ +static NSString *const kMissingEmailErrorMessage = @"MISSING_EMAIL"; + /** @var kInvalidEmailErrorMessage @brief The error returned by the server if the email is invalid. */ @@ -234,6 +239,36 @@ static NSString *const kIosBundleID = @"testBundleID"; XCTAssertNil(RPCResponse); } +/** @fn testMissingEmailError + @brief This test checks for missing email responses, and makes sure they are decoded to the + correct error response. + */ +- (void)testMissingEmailError { + FIRGetOOBConfirmationCodeRequest *request = [FIRGetOOBConfirmationCodeRequest + verifyEmailRequestWithAccessToken:kTestAccessToken + actionCodeSettings:[self fakeActionCodeSettings] + requestConfiguration:_requestConfiguration]; + + __block BOOL callbackInvoked; + __block FIRGetOOBConfirmationCodeResponse *RPCResponse; + __block NSError *RPCError; + [FIRAuthBackend getOOBConfirmationCode:request + callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response, + NSError *_Nullable error) { + callbackInvoked = YES; + RPCResponse = response; + RPCError = error; + }]; + + [_RPCIssuer respondWithServerErrorMessage:kMissingEmailErrorMessage]; + + XCTAssert(callbackInvoked); + XCTAssertNotNil(RPCError); + XCTAssertEqualObjects(RPCError.domain, FIRAuthErrorDomain); + XCTAssertEqual(RPCError.code, FIRAuthErrorCodeMissingEmail); + XCTAssertNil(RPCResponse); +} + /** @fn testInvalidEmailError @brief This test checks for the INVALID_EMAIL error message from the backend. */ -- cgit v1.2.3