FIRGitHubAuthProviderTests.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/FIRGitHubAuthProvider.h"
  18. #import "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
  19. #import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
  20. /** @var kGitHubToken
  21. @brief A testing GitHub token.
  22. */
  23. static NSString *const kGitHubToken = @"Token";
  24. /** @var kAPIKey
  25. @brief A testing API Key.
  26. */
  27. static NSString *const kAPIKey = @"APIKey";
  28. /** @class FIRGitHubAuthProviderTests
  29. @brief Tests for @c FIRGitHubAuthProvider
  30. */
  31. @interface FIRGitHubAuthProviderTests : XCTestCase
  32. @end
  33. @implementation FIRGitHubAuthProviderTests
  34. /** @fn testCredentialWithToken
  35. @brief Tests the @c credentialWithToken method to make sure the credential it produces populates
  36. the appropriate fields in a verify assertion request.
  37. */
  38. - (void)testCredentialWithToken {
  39. FIRAuthRequestConfiguration *requestConfiguration =
  40. [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kAPIKey];
  41. FIRAuthCredential *credential = [FIRGitHubAuthProvider credentialWithToken:kGitHubToken];
  42. FIRVerifyAssertionRequest *request =
  43. [[FIRVerifyAssertionRequest alloc] initWithProviderID:FIRGitHubAuthProviderID
  44. requestConfiguration:requestConfiguration];
  45. [credential prepareVerifyAssertionRequest:request];
  46. XCTAssertEqualObjects(request.providerAccessToken, kGitHubToken);
  47. }
  48. @end