FIRGitHubAuthProviderTests.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 "FIRGitHubAuthProvider.h"
  18. #import "FIRAuthCredential_Internal.h"
  19. #import "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