FIRTwitterAuthProviderTests.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <XCTest/XCTest.h>
  17. #import "FirebaseAuth/Sources/Public/FIRTwitterAuthProvider.h"
  18. #import "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
  19. #import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
  20. /** @var kTwitterToken
  21. @brief A testing Twitter token.
  22. */
  23. static NSString *const kTwitterToken = @"Token";
  24. /** @var kTwitterSecret
  25. @brief A testing Twitter secret.
  26. */
  27. static NSString *const kTwitterSecret = @"Secret";
  28. /** @var kAPIKey
  29. @brief A testing API Key.
  30. */
  31. static NSString *const kAPIKey = @"APIKey";
  32. /** @class FIRTwitterAuthProviderTests
  33. @brief Tests for @c FIRTwitterAuthProvider
  34. */
  35. @interface FIRTwitterAuthProviderTests : XCTestCase
  36. @end
  37. @implementation FIRTwitterAuthProviderTests
  38. /** @fn testCredentialWithToken
  39. @brief Tests the @c credentialWithToken method to make sure the credential it produces populates
  40. the appropriate fields in a verify assertion request.
  41. */
  42. - (void)testCredentialWithToken {
  43. FIRAuthCredential *credential = [FIRTwitterAuthProvider credentialWithToken:kTwitterToken
  44. secret:kTwitterSecret];
  45. FIRAuthRequestConfiguration *requestConfiguration =
  46. [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kAPIKey];
  47. FIRVerifyAssertionRequest *request =
  48. [[FIRVerifyAssertionRequest alloc] initWithProviderID:FIRTwitterAuthProviderID
  49. requestConfiguration:requestConfiguration];
  50. [credential prepareVerifyAssertionRequest:request];
  51. XCTAssertEqualObjects(request.providerAccessToken, kTwitterToken);
  52. XCTAssertEqualObjects(request.providerOAuthTokenSecret, kTwitterSecret);
  53. }
  54. @end