FIRTwitterAuthProviderTests.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/FirebaseAuth/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. /** @var kFirebaseAppID
  33. @brief A testing Firebase app ID.
  34. */
  35. static NSString *const kFirebaseAppID = @"appID";
  36. /** @class FIRTwitterAuthProviderTests
  37. @brief Tests for @c FIRTwitterAuthProvider
  38. */
  39. @interface FIRTwitterAuthProviderTests : XCTestCase
  40. @end
  41. @implementation FIRTwitterAuthProviderTests
  42. /** @fn testCredentialWithToken
  43. @brief Tests the @c credentialWithToken method to make sure the credential it produces populates
  44. the appropriate fields in a verify assertion request.
  45. */
  46. - (void)testCredentialWithToken {
  47. FIRAuthCredential *credential = [FIRTwitterAuthProvider credentialWithToken:kTwitterToken
  48. secret:kTwitterSecret];
  49. FIRAuthRequestConfiguration *requestConfiguration =
  50. [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kAPIKey appID:kFirebaseAppID];
  51. FIRVerifyAssertionRequest *request =
  52. [[FIRVerifyAssertionRequest alloc] initWithProviderID:FIRTwitterAuthProviderID
  53. requestConfiguration:requestConfiguration];
  54. [credential prepareVerifyAssertionRequest:request];
  55. XCTAssertEqualObjects(request.providerAccessToken, kTwitterToken);
  56. XCTAssertEqualObjects(request.providerOAuthTokenSecret, kTwitterSecret);
  57. }
  58. @end