OIDTokenRequest+Testing.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "GoogleSignIn/Tests/Unit/OIDTokenRequest+Testing.h"
  15. #import "GoogleSignIn/Tests/Unit/OIDAuthorizationResponse+Testing.h"
  16. #import <AppAuth/OIDAuthorizationRequest.h>
  17. #import <AppAuth/OIDScopeUtilities.h>
  18. @implementation OIDTokenRequest (Testing)
  19. + (instancetype)testInstance {
  20. return [self testInstanceWithAdditionalParameters:nil];
  21. }
  22. + (instancetype)testInstanceWithAdditionalParameters:
  23. (NSDictionary<NSString *, NSString *> *)additionalParameters {
  24. OIDAuthorizationResponse *authorizationResponse = [OIDAuthorizationResponse testInstance];
  25. OIDAuthorizationRequest *authorizationRequest = authorizationResponse.request;
  26. return [[OIDTokenRequest alloc]
  27. initWithConfiguration:authorizationResponse.request.configuration
  28. grantType:OIDGrantTypeAuthorizationCode
  29. authorizationCode:authorizationResponse.authorizationCode
  30. redirectURL:authorizationRequest.redirectURL
  31. clientID:authorizationRequest.clientID
  32. clientSecret:authorizationRequest.clientID
  33. scopes:[OIDScopeUtilities scopesArrayWithString:authorizationRequest.scope]
  34. refreshToken:@"refreshToken"
  35. codeVerifier:authorizationRequest.codeVerifier
  36. additionalParameters:additionalParameters];
  37. }
  38. @end