GIDConfiguration+Testing.m 2.3 KB

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