You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/07/15 18:36:14 UTC

ios commit: [CB-4095] Add some additional whitelist unit tests

Updated Branches:
  refs/heads/master bcece6fa4 -> 29023ad44


[CB-4095] Add some additional whitelist unit tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/29023ad4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/29023ad4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/29023ad4

Branch: refs/heads/master
Commit: 29023ad44b4d6cc77a75c3cf86e3eb72b0a48885
Parents: bcece6f
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Jul 15 12:35:37 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Jul 15 12:35:37 2013 -0400

----------------------------------------------------------------------
 CordovaLibTests/CDVWhitelistTests.m | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/29023ad4/CordovaLibTests/CDVWhitelistTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVWhitelistTests.m b/CordovaLibTests/CDVWhitelistTests.m
index b809972..bd53b3d 100644
--- a/CordovaLibTests/CDVWhitelistTests.m
+++ b/CordovaLibTests/CDVWhitelistTests.m
@@ -308,4 +308,32 @@
     STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://cordova.apache.org"]], nil);
 }
 
+- (void)testWildcardPlusScheme
+{
+    NSArray* allowedHosts = [NSArray arrayWithObjects:
+        @"http://*.apache.org",
+        nil];
+
+    CDVWhitelist* whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts];
+
+    STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://www.apache.org"]], nil);
+    STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"https://www.google.com"]], nil);
+    STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"ftp://cordova.apache.org"]], nil);
+    STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://cordova.apache.org"]], nil);
+    STAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"https://cordova.apache.org"]], nil);
+}
+
+- (void)testCredentials
+{
+    NSArray* allowedHosts = [NSArray arrayWithObjects:
+        @"http://*.apache.org",
+        @"http://www.google.com",
+        nil];
+
+    CDVWhitelist* whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts];
+
+    STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://user:pass@www.apache.org"]], nil);
+    STAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://user:pass@www.google.com"]], nil);
+}
+
 @end