Apache Cordova
  1. Apache Cordova
  2. CB-96

[PGWhitelist processWhitelist] IP adresses handling

    Details

      Description

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

      PGWhitelistTests.h
      @interface PGWhitelistTests : SenTestCase {
      }
      
      PGWhitelistTests.m
      #import "PGWhitelistTests.h"
      #import <PhoneGap/PGWhitelist.h>
      
      @implementation PGWhitelistTests
      
      - (void)setUp
      {
          [super setUp];   
      }
      
      - (void)tearDown
      {
          [super tearDown];
      }
      
      - (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
      

        Activity

          People

          • Assignee:
            Shazron Abdullah
            Reporter:
            STB Land
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 4h
              4h
              Remaining:
              Remaining Estimate - 4h
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development