FRANotificationHandlerTest.m revision c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81b
486N/A * Distribution License (the License). You may not use this file except in compliance with the
486N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
486N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
486N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
486N/A#import <OCMock/OCMock.h>
486N/A#import <XCTest/XCTest.h>
- (void)setUp {
[super setUp];
identity = [FRAIdentity identityWithDatabase:database accountName:TEST_USERNAME issuer:@"ForgeRock" image:nil backgroundColor:nil];
- (void)tearDown {
[super tearDown];
NSDictionary *data = @{@"aps":@{@"messageId":@"123", @"data":@"eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0.ew0KICAgICJjIjoiZEdobGJHVm5aVzVrYjJac2RXNWgiLA0KICAgICJsIjoiWVcxc1ltTnZiMnRwWlQxaGJXeGlZMjl2YTJsbFBUQXgiLA0KICAgICJ0IiA6IjEyMCIsDQogICAgInUiOiIwIg0KfQ==.1SAWJlT-5vjYRbpZ_57K-NpFRs4VZbSzZjAF_3RTu7k"}};
XCTAssertEqualObjects(notification.database, database, @"Notification not initialized with database");
XCTAssertEqualObjects(notification.messageId, @"123", @"Notification not initialized with messageId");
XCTAssertEqualObjects(notification.challenge, CHALLENGE, @"Notification not initialized with challenge");
NSDictionary *data = @{@"aps":@{@"messageId":@"123", @"data":@"eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0.ew0KICAgICJjIjoiZEdobGJHVm5aVzVrYjJac2RXNWgiLA0KICAgICJsIjoiWVcxc1ltTnZiMnRwWlQxaGJXeGlZMjl2YTJsbFBUQXgiLA0KICAgICJ0IiA6IjEyMCIsDQogICAgInUiOiIwIg0KfQ==.1SAWJlT-5vjYRbpZ_57K-NpFRs4VZbSzZjAF_3RTu7k"}};
XCTAssertEqual([pushMechanism notifications].count, 1, @"Notification handling should be idempotent");
NSDictionary *data = @{@"aps":@{@"messageId":@"123", @"data":@"eyAidHlwIjogIkpXVCIsICJhbGciOiAiSFMyNTYiIH0.ew0KICAgICJjIjoiZEdobGJHVm5aVzVrYjJac2RXNWgiLA0KICAgICJsIjoiWVcxc1ltTnZiMnRwWlQxaGJXeGlZMjl2YTJsbFBUQXgiLA0KICAgICJ0IiA6IjEyMCIsDQogICAgInUiOiIwIg0KfQ==.1SAWJlT-5vjYRbpZ_57K-NpFRs4VZbSzZjAF_3RTu7k"}};
XCTAssertEqual([oathMechanism notifications].count, 0, @"Only Push-Mechanism notifications should be handled");
XCTAssertEqual([pushMechanism notifications].count, 1, @"Only Push-Mechanism notifications should be handled");
@end