/*
* 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 "FRAIdentityDatabase.h"
#import "FRAIdentityDatabaseSQLiteOperations.h"
#import "FRAIdentitymodel.h"
#import "FRAMechanism.h"
#import "FRANotification.h"
@interface FRAMechanismTest : XCTestCase
@end
}
- (void)setUp {
[super setUp];
}
- (void)tearDown {
[super tearDown];
}
- (void)testCanAddNotificationToMechanism {
// Given
// When
// Then
}
// Given
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertMechanism:mechanism error:nil]).andReturn(YES);
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertNotification:notification error:nil]).andReturn(YES);
// When
// Then
}
// Given
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertMechanism:mechanism error:nil]).andReturn(YES);
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertNotification:notification error:nil]).andReturn(YES);
// When
// Then
}
- (void)testCanRemoveNotificationFromMechanism {
// Given
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations deleteNotification:notification error:nil]).andReturn(YES);
// When
// Then
}
// Given
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertMechanism:mechanism error:nil]).andReturn(YES);
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertNotification:notification error:nil]).andReturn(YES);
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations deleteNotification:notification error:nil]).andReturn(YES);
// When
// Then
}
// Given
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertMechanism:mechanism error:nil]).andReturn(YES);
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations insertNotification:notification error:nil]).andReturn(YES);
[[NSNotificationCenter defaultCenter] addMockObserver:databaseObserverMock name:FRAIdentityDatabaseChangedNotification object:database];
[[databaseObserverMock expect] notificationWithName:FRAIdentityDatabaseChangedNotification object:database userInfo:[OCMArg any]];
OCMStub([(FRAIdentityDatabaseSQLiteOperations*)mockSqlOperations deleteNotification:notification error:nil]).andReturn(YES);
// When
// Then
}
// Given
// When
// Then
XCTAssertEqual([mechanism notificationWithMessageId:@"ID-1"].messageId, @"ID-1", @"Should find child notification by message ID");
XCTAssertEqual([mechanism notificationWithMessageId:@"ID-2"].messageId, @"ID-2", @"Should find child notification by message ID");
XCTAssertEqual([mechanism notificationWithMessageId:@"ID-3"].messageId, @"ID-3", @"Should find child notification by message ID");
}
- (FRANotification *)dummyNotification {
}
challenge:@"Challenge"
timeToLive:120.0
loadBalancerCookieData:@"amlbcookie=03"];
}
@end