FRANotificationViewControllerTests.m revision 6d34df76ea55353d972de9caf3585e04714b2780
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * The contents of this file are subject to the terms of the Common Development and
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * Distribution License (the License). You may not use this file except in compliance with the
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * specific language governing permission and limitations under the License.
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * When distributing Covered Software, include this CDDL Header Notice in each file and include
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * Header, with the fields enclosed by brackets [] replaced by your own identifying
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * information: "Portions copyright [year] [name of copyright owner]".
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell * Copyright 2016 ForgeRock AS.
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell#import "FRALAContextFactory.h"
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell#import "FRANotification.h"
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell#import "FRANotificationViewController.h"
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell@interface FRANotificationViewControllerTests : XCTestCase
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell@implementation FRANotificationViewControllerTests {
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell FRANotificationViewController *viewController;
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell notification = OCMClassMock([FRANotification class]);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell authContextFactory = OCMClassMock([FRALAContextFactory class]);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell // load notification controller from storyboard
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell viewController = [storyboard instantiateViewControllerWithIdentifier:FRANotificationViewControllerStoryboardIdentifer];
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell viewController.authContextFactory = authContextFactory;
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell- (void)testIfTouchIDUnavailableThenUserShouldBeShownSliderToApproveAndButtonToDenyAuthentication {
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell id authContext = OCMClassMock([LAContext class]);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell OCMStub([authContextFactory newLAContext]).andReturn(authContext);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell XCTAssertEqual(viewController.authorizeSlider.hidden, NO, "slider should be shown if Touch ID unavailable");
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell XCTAssertEqual(viewController.denyButton.hidden, NO, "deny button should be shown if Touch ID unavailable");
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell id authContext = OCMClassMock([LAContext class]);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell OCMStub([authContextFactory newLAContext]).andReturn(authContext);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell OCMExpect([authContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:[OCMArg anyObjectRef]]).andReturn(YES);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell OCMExpect([authContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Log in to <issuer> using Touch ID" reply:[OCMArg any]]);
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell XCTAssertEqual(viewController.authorizeSlider.hidden, YES, "slider should not be shown if Touch ID is available");
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell XCTAssertEqual(viewController.denyButton.hidden, YES, "deny button should not be shown if Touch ID is available");
6d34df76ea55353d972de9caf3585e04714b2780Craig McDonnell [viewController loadViewIfNeeded]; // force IBOutlets etc to be initialized