Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DE650DDB3 for ; Tue, 6 Nov 2012 21:03:02 +0000 (UTC) Received: (qmail 55044 invoked by uid 500); 6 Nov 2012 21:03:02 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 54940 invoked by uid 500); 6 Nov 2012 21:03:02 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 54803 invoked by uid 500); 6 Nov 2012 21:03:02 -0000 Delivered-To: apmail-incubator-callback-commits@incubator.apache.org Received: (qmail 54772 invoked by uid 99); 6 Nov 2012 21:03:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 21:03:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 67C9044CE8; Tue, 6 Nov 2012 21:03:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [5/6] git commit: adding access whitelist api to config_parser Message-Id: <20121106210302.67C9044CE8@tyr.zones.apache.org> Date: Tue, 6 Nov 2012 21:03:02 +0000 (UTC) adding access whitelist api to config_parser Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/d774d5d2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/d774d5d2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/d774d5d2 Branch: refs/heads/cordova-client Commit: d774d5d2cac4605541c6d1ba166f9b6c9e25012c Parents: c7bc488 Author: Fil Maj Authored: Mon Nov 5 18:17:42 2012 -0800 Committer: Fil Maj Committed: Mon Nov 5 18:17:42 2012 -0800 ---------------------------------------------------------------------- spec/config_parser.spec.js | 36 ++++++++++++++++++++++++++++++++++++ src/config_parser.js | 24 ++++++++++++++++++++++++ templates/www/config.xml | 5 ++--- 3 files changed, 62 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/d774d5d2/spec/config_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js index 7afeedb..1791beb 100644 --- a/spec/config_parser.spec.js +++ b/spec/config_parser.spec.js @@ -63,4 +63,40 @@ describe('config.xml parser', function () { expect(fs.readFileSync(xml, 'utf-8')).toMatch(/one toke over the line<\/name>/); }); }); + + describe('access elements (whitelist)', function() { + var cfg; + + beforeEach(function() { + cfg = new config_parser(xml); + }); + + describe('getter', function() { + it('should get the (default) access element', function() { + expect(cfg.access.get()[0]).toEqual('*'); + }); + it('should return an array of all access origin uris via access()', function() { + expect(cfg.access.get() instanceof Array).toBe(true); + }); + }); + describe('setters', function() { + it('should allow removing a uri from the access list', function() { + cfg.access.remove('*'); + expect(cfg.access.get().length).toEqual(0); + }); + it('should write to disk after removing a uri', function() { + cfg.access.remove('*'); + expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(//); + }); + it('should allow adding a new uri to the access list', function() { + cfg.access.add('http://canucks.com'); + expect(cfg.access.get().length).toEqual(2); + expect(cfg.access.get().indexOf('http://canucks.com') > -1).toBe(true); + }); + it('should write to disk after adding a uri', function() { + cfg.access.add('http://cordova.io'); + expect(fs.readFileSync(xml, 'utf-8')).toMatch(/ - - - @@ -47,4 +44,6 @@ + +