11/* *
2- @file BNCURLBlackList.Test .m
2+ @file BNCURLFilterTests .m
33 @package Branch-SDK-Tests
4- @brief BNCURLBlackList tests.
4+ @brief BNCURLFilter tests.
55
66 @author Edward Smith
77 @date February 14, 2018
88 @copyright Copyright © 2018 Branch. All rights reserved.
99*/
1010
1111#import " BNCTestCase.h"
12- #import " BNCURLFilterList .h"
12+ #import " BNCURLFilter .h"
1313#import " Branch.h"
1414
15- @interface BNCURLFilterList ()
16- @property (readwrite ) NSURL *blackListJSONURL ;
15+ @interface BNCURLFilter ()
16+ @property (readwrite ) NSURL *jsonURL ;
1717@end
1818
19- @interface BNCURLBlackListTest : BNCTestCase
19+ @interface BNCURLFilterTests : BNCTestCase
2020@end
2121
22- @implementation BNCURLBlackListTest
22+ @implementation BNCURLFilterTests
2323
2424- (void ) setUp {
25- [BNCPreferenceHelper preferenceHelper ].URLPatternList = nil ;
26- [BNCPreferenceHelper preferenceHelper ].URLListVersion = 0 ;
25+ [BNCPreferenceHelper preferenceHelper ].savedURLPatternList = nil ;
26+ [BNCPreferenceHelper preferenceHelper ].savedURLPatternListVersion = 0 ;
2727 [BNCPreferenceHelper preferenceHelper ].dropURLOpen = NO ;
2828}
2929
@@ -32,9 +32,9 @@ - (void) tearDown {
3232}
3333
3434- (void )testListDownLoad {
35- XCTestExpectation *expectation = [self expectationWithDescription: @" BlackList Download" ];
36- BNCURLFilterList *blackList = [BNCURLFilterList new ];
37- [blackList refreshBlackListFromServerWithCompletion : ^ (NSError *error, NSArray *list) {
35+ XCTestExpectation *expectation = [self expectationWithDescription: @" List Download" ];
36+ BNCURLFilter *filter = [BNCURLFilter new ];
37+ [filter updatePatternListWithCompletion : ^ (NSError *error, NSArray *list) {
3838 XCTAssertNil (error);
3939 XCTAssertTrue (list.count == 6 );
4040 [expectation fulfill ];
@@ -80,57 +80,57 @@ - (NSArray*) goodURLs {
8080
8181- (void )testBadURLs {
8282 // Test default list.
83- BNCURLFilterList *blackList = [BNCURLFilterList new ];
83+ BNCURLFilter *filter = [BNCURLFilter new ];
8484 for (NSString *string in self.badURLs ) {
8585 NSURL *URL = [NSURL URLWithString: string];
86- XCTAssertTrue ([blackList isBlackListedURL : URL], @" Checking '%@ '." , URL);
86+ XCTAssertTrue ([filter shouldIgnoreURL : URL], @" Checking '%@ '." , URL);
8787 }
8888}
8989
9090- (void ) testDownloadBadURLs {
9191 // Test download list.
92- XCTestExpectation *expectation = [self expectationWithDescription: @" BlackList Download" ];
93- BNCURLFilterList *blackList = [BNCURLFilterList new ];
94- blackList. blackListJSONURL = [NSURL URLWithString: @" https://cdn.branch.io/sdk/uriskiplist_tv1.json" ];
95- [blackList refreshBlackListFromServerWithCompletion : ^ (NSError *error, NSArray *list) {
92+ XCTestExpectation *expectation = [self expectationWithDescription: @" List Download" ];
93+ BNCURLFilter *filter = [BNCURLFilter new ];
94+ filter. jsonURL = [NSURL URLWithString: @" https://cdn.branch.io/sdk/uriskiplist_tv1.json" ];
95+ [filter updatePatternListWithCompletion : ^ (NSError *error, NSArray *list) {
9696 XCTAssertNil (error);
9797 XCTAssertTrue (list.count == 7 );
9898 [expectation fulfill ];
9999 }];
100100 [self awaitExpectations ];
101101 for (NSString *string in self.badURLs ) {
102102 NSURL *URL = [NSURL URLWithString: string];
103- XCTAssertTrue ([blackList isBlackListedURL : URL], @" Checking '%@ '." , URL);
103+ XCTAssertTrue ([filter shouldIgnoreURL : URL], @" Checking '%@ '." , URL);
104104 }
105105}
106106
107107- (void )testGoodURLs {
108108 // Test default list.
109- BNCURLFilterList *blackList = [BNCURLFilterList new ];
109+ BNCURLFilter *filter = [BNCURLFilter new ];
110110 for (NSString *string in self.goodURLs ) {
111111 NSURL *URL = [NSURL URLWithString: string];
112- XCTAssertFalse ([blackList isBlackListedURL : URL], @" Checking '%@ '" , URL);
112+ XCTAssertFalse ([filter shouldIgnoreURL : URL], @" Checking '%@ '" , URL);
113113 }
114114}
115115
116116- (void ) testDownloadGoodURLs {
117117 // Test download list.
118- XCTestExpectation *expectation = [self expectationWithDescription: @" BlackList Download" ];
119- BNCURLFilterList *blackList = [BNCURLFilterList new ];
120- blackList. blackListJSONURL = [NSURL URLWithString: @" https://cdn.branch.io/sdk/uriskiplist_tv1.json" ];
121- [blackList refreshBlackListFromServerWithCompletion : ^ (NSError *error, NSArray *list) {
118+ XCTestExpectation *expectation = [self expectationWithDescription: @" List Download" ];
119+ BNCURLFilter *filter = [BNCURLFilter new ];
120+ filter. jsonURL = [NSURL URLWithString: @" https://cdn.branch.io/sdk/uriskiplist_tv1.json" ];
121+ [filter updatePatternListWithCompletion : ^ (NSError *error, NSArray *list) {
122122 XCTAssertNil (error);
123123 XCTAssertTrue (list.count == 7 );
124124 [expectation fulfill ];
125125 }];
126126 [self awaitExpectations ];
127127 for (NSString *string in self.goodURLs ) {
128128 NSURL *URL = [NSURL URLWithString: string];
129- XCTAssertFalse ([blackList isBlackListedURL : URL], @" Checking '%@ '." , URL);
129+ XCTAssertFalse ([filter shouldIgnoreURL : URL], @" Checking '%@ '." , URL);
130130 }
131131}
132132
133- - (void ) testStandardBlackList {
133+ - (void ) testStandardList {
134134 BNCLogSetDisplayLevel (BNCLogLevelAll);
135135 Branch *branch = (Branch.branchKey .length ) ? Branch.getInstance : [Branch getInstance: @" key_live_foo" ];
136136 id serverInterfaceMock = OCMPartialMock (branch.serverInterface );
@@ -168,7 +168,7 @@ - (void) testStandardBlackList {
168168 [[BNCPreferenceHelper preferenceHelper ] synchronize ];
169169}
170170
171- - (void ) testUserBlackList {
171+ - (void ) testUserList {
172172 BNCLogSetDisplayLevel (BNCLogLevelAll);
173173 Branch *branch = (Branch.branchKey .length ) ? Branch.getInstance : [Branch getInstance: @" key_live_foo" ];
174174 [branch clearNetworkQueue ];
0 commit comments