FRAQRUtilsTests.m revision 2708b42676edf3d2e8f85b3c22b9e3be3cf43eb8
859N/A/*
2887N/A * The contents of this file are subject to the terms of the Common Development and
859N/A * Distribution License (the License). You may not use this file except in compliance with the
859N/A * License.
859N/A *
859N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
859N/A * specific language governing permission and limitations under the License.
859N/A *
859N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
859N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
859N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
859N/A * information: "Portions copyright [year] [name of copyright owner]".
859N/A *
859N/A * Copyright 2016 ForgeRock AS.
859N/A */
859N/A
859N/A#import <XCTest/XCTest.h>
859N/A
859N/A#import "FRAQRUtils.h"
859N/A
873N/A@interface FRAQRUtilsTests : XCTestCase
859N/A
859N/A@end
859N/A
859N/A@implementation FRAQRUtilsTests
4618N/A
859N/A- (void)testReplaceCharactersForURLDecodingReplacesDashes {
859N/A
859N/A NSString *content = @"-123-456-";
859N/A
3816N/A NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
3816N/A
3816N/A XCTAssertEqualObjects(result, @"+123+456+");
946N/A}
859N/A
4618N/A- (void)testReplaceCharactersForURLDecodingReplacesUnderscores {
4618N/A
4618N/A NSString *content = @"_123_456_";
4618N/A
4618N/A NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
4618N/A
4618N/A XCTAssertEqualObjects(result, @"/123/456/");
4618N/A}
4618N/A
4618N/A- (void)testReplaceCharactersForURLDecodingDoesntReplaceIfValid {
4618N/A
4618N/A NSString *content = @"123456";
4618N/A
4618N/A NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
4618N/A
4618N/A XCTAssertEqualObjects(result, @"123456");
4618N/A}
4618N/A
4618N/A- (void)testDecodeBase64NilReturnsNil {
4618N/A
4618N/A NSData *result = [FRAQRUtils decodeBase64:nil];
4618N/A
4618N/A XCTAssertNil(result);
4618N/A}
4618N/A
4618N/A- (void)testIsBase64ReturnsTrueIfStringIsValidBase64 {
4618N/A
4618N/A BOOL result = [FRAQRUtils isBase64:@"somethingTHATisvalid1244+"];
4618N/A
4618N/A XCTAssertTrue(result);
4618N/A}
4618N/A
4618N/A- (void)testIsBase64ReturnsFalseIfStringIsNotValidBase64 {
4618N/A
4618N/A BOOL result = [FRAQRUtils isBase64:@"somethingTHATisNOT%valid1244+"];
4618N/A
4618N/A XCTAssertFalse(result);
4618N/A}
4618N/A
4618N/A@end