callback/callback-ios — Issue #34: [PGWhitelist processWhitelist] IP adresses handling
Author: stbland
Created: 2011-11-30 12:26:14+00:00
State: open

Theses tests fail with version 1.2.0 (not tested before) :

```objective-c
@interface PGWhitelistTests : SenTestCase {
}
```

```objective-c
- (void) testIpExactMatch
{
NSArray* allowedHosts = [NSArray arrayWithObjects:
@"162.168.1.1",
@"162.168.2.1",
nil];

PGWhitelist* whitelist = [[PGWhitelist alloc] initWithArray:allowedHosts];

STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"http://mydomain.com"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.1.1"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.2.1"]], nil);
STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.3.1"]], nil);

[whitelist release];
}

- (void) testIpWildcardMatch
{
NSArray* allowedHosts = [NSArray arrayWithObjects:
@"162.168.1.*",
@"162.168.2.*",
nil];

PGWhitelist* whitelist = [[PGWhitelist alloc] initWithArray:allowedHosts];

STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"http://mydomain.com"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.1.1"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.1.2"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.2.1"]], nil);
STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.2.2"]], nil);
STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"http://192.168.3.1"]], nil);

[whitelist release];
}

@end
```