GIDScopesTest.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 <Foundation/Foundation.h>
  15. #import <XCTest/XCTest.h>
  16. #import "GoogleSignIn/Sources/GIDScopes.h"
  17. // Scope constants.
  18. static NSString *const kProfile = @"profile";
  19. static NSString *const kUserinfoProfile = @"https://www.googleapis.com/auth/userinfo.profile";
  20. static NSString *const kEmail = @"email";
  21. static NSString *const kUserinfoEmail = @"https://www.googleapis.com/auth/userinfo.email";
  22. static NSString *const kDriveScope = @"https://www.googleapis.com/auth/drive";
  23. @interface GIDScopesTest : XCTestCase
  24. @end
  25. @implementation GIDScopesTest
  26. - (void)testScopesWithBasicProfile_NoChange {
  27. XCTAssertEqualObjects([GIDScopes scopesWithBasicProfile:(@[ kProfile, kEmail])],
  28. (@[ kProfile, kEmail]));
  29. }
  30. - (void)testScopesWithBasicProfile_NoChangeOldScopes {
  31. XCTAssertEqualObjects([GIDScopes scopesWithBasicProfile:(@[ kUserinfoProfile, kUserinfoEmail])],
  32. (@[ kUserinfoProfile, kUserinfoEmail]));
  33. }
  34. - (void)testScopesWithBasicProfile_AddScope {
  35. XCTAssertEqualObjects([GIDScopes scopesWithBasicProfile:(@[ kDriveScope ])],
  36. (@[ kDriveScope, kEmail, kProfile ]));
  37. }
  38. @end