GIDConfiguration+Testing.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/GIDConfiguration+Testing.h"
  15. #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
  16. #import "GoogleSignIn/Tests/Unit/OIDAuthorizationRequest+Testing.h"
  17. #import "GoogleSignIn/Tests/Unit/OIDTokenResponse+Testing.h"
  18. NSString *const kServerClientID = @"fakeServerClientID";
  19. NSString *const kOpenIDRealm = @"fakeOpenIDRealm";
  20. @implementation GIDConfiguration (Testing)
  21. // TODO(petea): consider moving -isEqual* to the base class and implementing -hash as well.
  22. - (BOOL)isEqual:(id)object {
  23. if (self == object) {
  24. return YES;
  25. }
  26. if (![object isKindOfClass:[GIDConfiguration class]]) {
  27. return NO;
  28. }
  29. return [self isEqualToConfiguration:(GIDConfiguration *)object];
  30. }
  31. - (BOOL)isEqualToConfiguration:(GIDConfiguration *)other {
  32. // Nullable properties get an extra check to cover the nil case.
  33. return [self.clientID isEqual:other.clientID] &&
  34. ([self.serverClientID isEqual:other.serverClientID] ||
  35. self.serverClientID == other.serverClientID) &&
  36. ([self.hostedDomain isEqual:other.hostedDomain] ||
  37. self.hostedDomain == other.hostedDomain) &&
  38. ([self.openIDRealm isEqual:other.openIDRealm] ||
  39. self.openIDRealm == other.openIDRealm);
  40. }
  41. + (instancetype)testInstance {
  42. return [[GIDConfiguration alloc] initWithClientID:OIDAuthorizationRequestTestingClientID
  43. serverClientID:kServerClientID
  44. hostedDomain:kHostedDomain
  45. openIDRealm:kOpenIDRealm];
  46. }
  47. @end