|
|
@@ -22,6 +22,9 @@
|
|
|
#import "GoogleSignIn/Tests/Unit/GIDFakeMainBundle.h"
|
|
|
|
|
|
static NSString * const kClientId = @"FakeClientID";
|
|
|
+static NSString * const kServerClientId = @"FakeServerClientID";
|
|
|
+static NSString * const kOpenIDRealm = @"FakeRealm";
|
|
|
+static NSString * const kFakeHostedDomain = @"fakehosteddomain.com";
|
|
|
|
|
|
@interface GIDVerifyAccountDetailTests : XCTestCase {
|
|
|
@private
|
|
|
@@ -54,13 +57,61 @@ static NSString * const kClientId = @"FakeClientID";
|
|
|
_verifiableAccountDetails = @[ageOver18Detail];
|
|
|
|
|
|
_fakeMainBundle = [[GIDFakeMainBundle alloc] init];
|
|
|
- [_fakeMainBundle startFakingWithClientID:kClientId];
|
|
|
- [_fakeMainBundle fakeAllSchemesSupported];
|
|
|
}
|
|
|
|
|
|
|
|
|
#pragma mark - Tests
|
|
|
|
|
|
+- (void)testInit {
|
|
|
+ [_fakeMainBundle startFakingWithClientID:kClientId];
|
|
|
+
|
|
|
+ GIDVerifyAccountDetail *verifyAccountDetail = [[GIDVerifyAccountDetail alloc] init];
|
|
|
+ XCTAssertNotNil(verifyAccountDetail.configuration);
|
|
|
+ XCTAssertEqual(verifyAccountDetail.configuration.clientID, kClientId);
|
|
|
+ XCTAssertNil(verifyAccountDetail.configuration.serverClientID);
|
|
|
+ XCTAssertNil(verifyAccountDetail.configuration.hostedDomain);
|
|
|
+ XCTAssertNil(verifyAccountDetail.configuration.openIDRealm);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)testInit_noConfig {
|
|
|
+ [_fakeMainBundle startFakingWithClientID:kClientId];
|
|
|
+ [_fakeMainBundle fakeWithClientID:nil
|
|
|
+ serverClientID:nil
|
|
|
+ hostedDomain:nil
|
|
|
+ openIDRealm:nil];
|
|
|
+ GIDVerifyAccountDetail *verifyAccountDetail = [[GIDVerifyAccountDetail alloc] init];
|
|
|
+
|
|
|
+ XCTAssertNil(verifyAccountDetail.configuration);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)testInit_fullConfig {
|
|
|
+ [_fakeMainBundle startFakingWithClientID:kClientId];
|
|
|
+ [_fakeMainBundle fakeWithClientID:kClientId
|
|
|
+ serverClientID:kServerClientId
|
|
|
+ hostedDomain:kFakeHostedDomain
|
|
|
+ openIDRealm:kOpenIDRealm];
|
|
|
+
|
|
|
+ GIDVerifyAccountDetail *verifyAccountDetail = [[GIDVerifyAccountDetail alloc] init];
|
|
|
+ XCTAssertNotNil(verifyAccountDetail.configuration);
|
|
|
+ XCTAssertEqual(verifyAccountDetail.configuration.clientID, kClientId);
|
|
|
+ XCTAssertEqual(verifyAccountDetail.configuration.serverClientID, kServerClientId);
|
|
|
+ XCTAssertEqual(verifyAccountDetail.configuration.hostedDomain, kFakeHostedDomain);
|
|
|
+ XCTAssertEqual(verifyAccountDetail.configuration.openIDRealm, kOpenIDRealm);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)testInit_invalidConfig {
|
|
|
+ [_fakeMainBundle startFakingWithClientID:kClientId];
|
|
|
+ [_fakeMainBundle fakeWithClientID:@[ @"bad", @"config", @"values" ]
|
|
|
+ serverClientID:nil
|
|
|
+ hostedDomain:nil
|
|
|
+ openIDRealm:nil];
|
|
|
+
|
|
|
+ GIDVerifyAccountDetail *verifyAccountDetail = [[GIDVerifyAccountDetail alloc] init];
|
|
|
+ XCTAssertNil(verifyAccountDetail.configuration);
|
|
|
+}
|
|
|
+
|
|
|
- (void)testPresentingViewControllerException {
|
|
|
_presentingViewController = nil;
|
|
|
|
|
|
@@ -74,35 +125,21 @@ static NSString * const kClientId = @"FakeClientID";
|
|
|
#pragma GCC diagnostic ignored "-Wnonnull"
|
|
|
_verifyAccountDetail.configuration = [[GIDConfiguration alloc] initWithClientID:nil];
|
|
|
#pragma GCC diagnostic pop
|
|
|
- BOOL threw = NO;
|
|
|
- @try {
|
|
|
- [_verifyAccountDetail verifyAccountDetails:_verifiableAccountDetails
|
|
|
- presentingViewController:_presentingViewController
|
|
|
- completion:nil];
|
|
|
- } @catch (NSException *exception) {
|
|
|
- threw = YES;
|
|
|
- XCTAssertEqualObjects(exception.description,
|
|
|
- @"You must specify |clientID| in |GIDConfiguration|");
|
|
|
- } @finally {
|
|
|
- }
|
|
|
- XCTAssert(threw);
|
|
|
+
|
|
|
+ XCTAssertThrowsSpecificNamed(
|
|
|
+ [_verifyAccountDetail verifyAccountDetails:_verifiableAccountDetails presentingViewController:_presentingViewController completion:nil],
|
|
|
+ NSException,
|
|
|
+ NSInvalidArgumentException,
|
|
|
+ @"You must specify |clientID| in |GIDConfiguration|");
|
|
|
}
|
|
|
|
|
|
- (void)testSchemesNotSupportedException {
|
|
|
- [_fakeMainBundle fakeMissingAllSchemes];
|
|
|
- BOOL threw = NO;
|
|
|
- @try {
|
|
|
- [_verifyAccountDetail verifyAccountDetails:_verifiableAccountDetails
|
|
|
- presentingViewController:_presentingViewController
|
|
|
- completion:nil];
|
|
|
- } @catch (NSException *exception) {
|
|
|
- threw = YES;
|
|
|
- XCTAssertEqualObjects(exception.description,
|
|
|
- @"Your app is missing support for the following URL schemes: "
|
|
|
- "fakeclientid");
|
|
|
- } @finally {
|
|
|
- }
|
|
|
- XCTAssert(threw);
|
|
|
+ XCTAssertThrowsSpecificNamed(
|
|
|
+ [_verifyAccountDetail verifyAccountDetails:_verifiableAccountDetails presentingViewController:_presentingViewController completion:nil],
|
|
|
+ NSException,
|
|
|
+ NSInvalidArgumentException,
|
|
|
+ @"Your app is missing support for the following URL schemes: "
|
|
|
+ "fakeclientid");
|
|
|
}
|
|
|
|
|
|
@end
|