/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*/
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#import "FRAFMDatabaseConnectionHelper.h"
#import "FRAIdentity.h"
#import "FRAIdentityDatabase.h"
#import "FRAIdentityDatabaseSQLiteOperations.h"
#import "FRAIdentityModel.h"
#import "FRAMechanism.h"
#import "FRAModelsFromDatabase.h"
#import "FRANotification.h"
#import "FRAPushMechanism.h"
@interface FRAIdentityModelTests : XCTestCase
@end
}
- (void)setUp {
[super setUp];
OCMStub([mockModelsFromDatabase allIdentitiesWithDatabase:[OCMArg any] identityDatabase:[OCMArg any] identityModel:[OCMArg any] error:[OCMArg anyObjectRef]]).andReturn(@[]);
aliceIdentity = [FRAIdentity identityWithDatabase:database identityModel:identityModel accountName:@"alice" issuer:@"Forgerock" image:nil backgroundColor:nil];
bobIdentity = [FRAIdentity identityWithDatabase:database identityModel:identityModel accountName:@"bob" issuer:@"Forgerock" image:nil backgroundColor:nil];
}
- (void)tearDown {
[super tearDown];
}
- (void)testCanSaveNewIdentityToDatabase {
// Given
// When
// Then
}
// Given
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
// When
// Then
}
- (void)testCanFindIdentityByIssuerAndLabel {
// Given
// When
FRAIdentity* foundIdentity = [identityModel identityWithIssuer:aliceIdentity.issuer accountName:aliceIdentity.accountName];
// Then
}
- (void)testCanRemoveIdentityFromDatabase {
// Given
// When
// Then
}
// Given
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
// When
// Then
}
// Given
FRAPushMechanism *mechanism = [[FRAPushMechanism alloc] initWithDatabase:database identityModel:identityModel];
// When
// Then
}
// Given
FRAPushMechanism *mechanism = [[FRAPushMechanism alloc] initWithDatabase:database identityModel:identityModel];
FRANotification *notification = [[FRANotification alloc] initWithDatabase:database identityModel:identityModel messageId:@"messageId" challenge:@"challenge" timeReceived:[NSDate date] timeToLive:timeToLive loadBalancerCookieData:amlbCookie];
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
NSDictionary *expectedChanges = @{
};
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:expectedChanges];
// When
// Then
}
// Given
FRAPushMechanism *mechanism = [[FRAPushMechanism alloc] initWithDatabase:database identityModel:identityModel];
FRANotification *notification = [[FRANotification alloc] initWithDatabase:database identityModel:identityModel messageId:@"messageId" challenge:@"challenge" timeReceived:[NSDate date] timeToLive:timeToLive loadBalancerCookieData:amlbCookie];
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
NSDictionary *expectedChanges = @{
};
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:expectedChanges];
// When
// Then
}
- (void)testCanFindMechanismById {
// Given
FRAPushMechanism *mechanism = [[FRAPushMechanism alloc] initWithDatabase:database identityModel:identityModel];
// When
// Then
}
// Given
// When
// Then
}
// Given
// When
// Then
@end