[Pkg-mozext-commits] [requestpolicy] 52/100: [refactoring] rename "rule type" to "rule action" (=allow/deny)
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 71bcb49c11d6093bd94d1a7537dc996248ecf802
Author: myrdd <myrdd at users.noreply.github.com>
Date: Sat Oct 4 04:38:54 2014 +0200
[refactoring] rename "rule type" to "rule action" (=allow/deny)
---
src/components/requestpolicyService.js | 24 ++---
src/content/menu.js | 60 ++++++------
src/content/settings/oldrules.html | 2 +-
src/content/settings/oldrules.js | 10 +-
src/content/settings/settings.css | 2 +-
src/content/settings/yourpolicy.html | 4 +-
src/content/settings/yourpolicy.js | 16 ++--
src/modules/PolicyManager.jsm | 42 ++++-----
src/modules/Ruleset.jsm | 166 ++++++++++++++++-----------------
tests/modules/Policy/test1.js | 12 +--
tests/modules/Policy/test2.js | 2 +-
tests/modules/Policy/test3.js | 2 +-
tests/modules/Policy/test4.js | 4 +-
tests/modules/Policy/test5.js | 4 +-
tests/xpcshell/test_policymanager.js | 64 ++++++-------
tests/xpcshell/test_policystorage.js | 20 ++--
16 files changed, 217 insertions(+), 217 deletions(-)
diff --git a/src/components/requestpolicyService.js b/src/components/requestpolicyService.js
index 294ad9e..d50aaa8 100644
--- a/src/components/requestpolicyService.js
+++ b/src/components/requestpolicyService.js
@@ -749,34 +749,34 @@ RequestPolicyService.prototype = {
},
addAllowRule : function(rawRule, noStore) {
- this._policyMgr.addRule(rp.mod.RULE_TYPE_ALLOW, rawRule,
+ this._policyMgr.addRule(rp.mod.RULE_ACTION_ALLOW, rawRule,
noStore);
},
addTemporaryAllowRule : function(rawRule) {
- this._policyMgr.addTemporaryRule(rp.mod.RULE_TYPE_ALLOW,
+ this._policyMgr.addTemporaryRule(rp.mod.RULE_ACTION_ALLOW,
rawRule);
},
removeAllowRule : function(rawRule) {
- this._policyMgr.removeRule(rp.mod.RULE_TYPE_ALLOW, rawRule);
+ this._policyMgr.removeRule(rp.mod.RULE_ACTION_ALLOW, rawRule);
},
addDenyRule : function(rawRule) {
- this._policyMgr.addRule(rp.mod.RULE_TYPE_DENY, rawRule);
+ this._policyMgr.addRule(rp.mod.RULE_ACTION_DENY, rawRule);
},
addTemporaryDenyRule : function(rawRule) {
- this._policyMgr.addTemporaryRule(rp.mod.RULE_TYPE_DENY, rawRule);
+ this._policyMgr.addTemporaryRule(rp.mod.RULE_ACTION_DENY, rawRule);
},
removeDenyRule : function(rawRule) {
- this._policyMgr.removeRule(rp.mod.RULE_TYPE_DENY, rawRule);
+ this._policyMgr.removeRule(rp.mod.RULE_ACTION_DENY, rawRule);
},
_allowOrigin : function(host, noStore) {
var ruleData = {"o":{"h":host}};
- this._policyMgr.addRule(rp.mod.RULE_TYPE_ALLOW, ruleData,
+ this._policyMgr.addRule(rp.mod.RULE_ACTION_ALLOW, ruleData,
noStore);
},
@@ -790,13 +790,13 @@ RequestPolicyService.prototype = {
temporarilyAllowOrigin : function(host) {
var ruleData = {"o": {"h" : host}};
- this._policyMgr.addTemporaryRule(rp.mod.RULE_TYPE_ALLOW,
+ this._policyMgr.addTemporaryRule(rp.mod.RULE_ACTION_ALLOW,
ruleData);
},
_allowDestination : function(host, noStore) {
var ruleData = {"d": {"h" : host}};
- this._policyMgr.addRule(rp.mod.RULE_TYPE_ALLOW, ruleData,
+ this._policyMgr.addRule(rp.mod.RULE_ACTION_ALLOW, ruleData,
noStore);
},
@@ -810,7 +810,7 @@ RequestPolicyService.prototype = {
temporarilyAllowDestination : function(host) {
var ruleData = {"d": {"h" : host}};
- this._policyMgr.addTemporaryRule(rp.mod.RULE_TYPE_ALLOW,
+ this._policyMgr.addTemporaryRule(rp.mod.RULE_ACTION_ALLOW,
ruleData);
},
@@ -820,7 +820,7 @@ RequestPolicyService.prototype = {
"o": {"h" : originIdentifier},
"d": {"h" : destIdentifier}
};
- this._policyMgr.addRule(rp.mod.RULE_TYPE_ALLOW, ruleData,
+ this._policyMgr.addRule(rp.mod.RULE_ACTION_ALLOW, ruleData,
noStore);
},
@@ -839,7 +839,7 @@ RequestPolicyService.prototype = {
"o": {"h" : originIdentifier},
"d": {"h" : destIdentifier}
};
- this._policyMgr.addTemporaryRule(rp.mod.RULE_TYPE_ALLOW,
+ this._policyMgr.addTemporaryRule(rp.mod.RULE_ACTION_ALLOW,
ruleData);
},
diff --git a/src/content/menu.js b/src/content/menu.js
index 2fcb3bf..4610121 100644
--- a/src/content/menu.js
+++ b/src/content/menu.js
@@ -272,8 +272,8 @@ requestpolicy.menu = {
_populateDetails : function() {
var policyMgr = this._rpService._policyMgr;
- const RULE_TYPE_ALLOW = rp.mod.RULE_TYPE_ALLOW;
- const RULE_TYPE_DENY = rp.mod.RULE_TYPE_DENY;
+ const RULE_ACTION_ALLOW = rp.mod.RULE_ACTION_ALLOW;
+ const RULE_ACTION_DENY = rp.mod.RULE_ACTION_DENY;
var origin = this._currentlySelectedOrigin;
var dest = this._currentlySelectedDest;
@@ -318,13 +318,13 @@ requestpolicy.menu = {
};
//if (this._rpService.isDefaultAllow()) {
if (this._isCurrentlySelectedDestAllowed ||
- (!policyMgr.ruleExists(RULE_TYPE_DENY, ruleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, destOnlyRuleData))) {
+ (!policyMgr.ruleExists(RULE_ACTION_DENY, ruleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, destOnlyRuleData))) {
// show "Block requests" if the destination was allowed
// OR if there's no blocking rule (i.e. the request was blocked "by default")
// -- this enables support for blacklisting.
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, ruleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, ruleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, ruleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemDenyOriginToDest(
this._addRulesList, ruleData);
@@ -333,8 +333,8 @@ requestpolicy.menu = {
this._addRulesList, ruleData);
}
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, destOnlyRuleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, destOnlyRuleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemDenyDest(
this._addRulesList, destOnlyRuleData);
@@ -344,13 +344,13 @@ requestpolicy.menu = {
}
}
if (this._isCurrentlySelectedDestBlocked ||
- (!policyMgr.ruleExists(RULE_TYPE_ALLOW, ruleData) &&
- !policyMgr.ruleExists(RULE_TYPE_ALLOW, destOnlyRuleData))) {
+ (!policyMgr.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData))) {
// show "Allow requests" if the destination was blocked
// OR if there's no allow-rule (i.e. the request was allowed "by default")
// -- this enables support for whitelisting.
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, ruleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, ruleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, ruleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemAllowOriginToDest(
this._addRulesList, ruleData);
@@ -359,8 +359,8 @@ requestpolicy.menu = {
this._addRulesList, ruleData);
}
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, destOnlyRuleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, destOnlyRuleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemAllowDest(
this._addRulesList, destOnlyRuleData);
@@ -609,7 +609,7 @@ requestpolicy.menu = {
/* This function iterates through all requests of a destBase, looks for
* properties and returns them.
*/
- _extractRequestProperties : function(request, ruleType) {
+ _extractRequestProperties : function(request, ruleAction) {
var properties = {
numRequests : 0,
numDefaultPolicyRequests : 0,
@@ -617,13 +617,13 @@ requestpolicy.menu = {
numBlockedRequests : 0
};
- var ruleTypeCounter = 0;
+ var ruleActionCounter = 0;
for (var destIdent in request) {
for (var destUri in request[destIdent]) {
for (var i in request[destIdent][destUri]) {
++properties.numRequests;
- ++ruleTypeCounter;
+ ++ruleActionCounter;
//rp.mod.Logger.dump("reason: "+ request[destIdent][destUri].resultReason
// + " -- default: "+request[destIdent][destUri].isDefaultPolicyUsed());
if ( request[destIdent][destUri][i].isDefaultPolicyUsed() ) {
@@ -633,13 +633,13 @@ requestpolicy.menu = {
}
}
- switch (ruleType) {
- case rp.mod.RULE_TYPE_ALLOW:
- properties.numAllowedRequests = ruleTypeCounter;
+ switch (ruleAction) {
+ case rp.mod.RULE_ACTION_ALLOW:
+ properties.numAllowedRequests = ruleActionCounter;
break;
- case rp.mod.RULE_TYPE_DENY:
- properties.numBlockedRequests = ruleTypeCounter;
+ case rp.mod.RULE_ACTION_DENY:
+ properties.numBlockedRequests = ruleActionCounter;
break;
default:
@@ -657,7 +657,7 @@ requestpolicy.menu = {
var result = [];
for (var destBase in requests) {
var properties = this._extractRequestProperties(requests[destBase],
- rp.mod.RULE_TYPE_DENY);
+ rp.mod.RULE_ACTION_DENY);
result.push(new rp.mod.Destination(destBase, properties));
//rp.mod.Logger.dump("destBase : "+destBase);
//rp.mod.Logger.vardump(properties, "properties");
@@ -683,7 +683,7 @@ requestpolicy.menu = {
}
var properties = this._extractRequestProperties(requests[destBase],
- rp.mod.RULE_TYPE_ALLOW);
+ rp.mod.RULE_ACTION_ALLOW);
result.push(new rp.mod.Destination(destBase, properties));
}
return result;
@@ -1100,8 +1100,8 @@ requestpolicy.menu = {
_populateDetailsAddSubdomainAllowRules : function(list) {
var policyMgr = this._rpService._policyMgr;
- const RULE_TYPE_ALLOW = rp.mod.RULE_TYPE_ALLOW;
- const RULE_TYPE_DENY = rp.mod.RULE_TYPE_DENY;
+ const RULE_ACTION_ALLOW = rp.mod.RULE_ACTION_ALLOW;
+ const RULE_ACTION_DENY = rp.mod.RULE_ACTION_DENY;
var origin = this._currentlySelectedOrigin;
@@ -1136,8 +1136,8 @@ requestpolicy.menu = {
'h': destHost
}
};
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, ruleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, ruleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, ruleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemAllowOriginToDest(list, ruleData);
}
@@ -1149,8 +1149,8 @@ requestpolicy.menu = {
'h': destHost
}
};
- if (!policyMgr.ruleExists(RULE_TYPE_ALLOW, destOnlyRuleData) &&
- !policyMgr.ruleExists(RULE_TYPE_DENY, destOnlyRuleData)) {
+ if (!policyMgr.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !policyMgr.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
if (!this._privateBrowsingEnabled) {
var item = this._addMenuItemAllowDest(list, destOnlyRuleData);
}
diff --git a/src/content/settings/oldrules.html b/src/content/settings/oldrules.html
index 3994052..0ca6940 100644
--- a/src/content/settings/oldrules.html
+++ b/src/content/settings/oldrules.html
@@ -83,7 +83,7 @@
<div class="policydata">
<table id="policy-user">
<colgroup>
- <col class="type">
+ <col class="rule-action">
<col class="origin">
<col class="destination">
</colgroup>
diff --git a/src/content/settings/oldrules.js b/src/content/settings/oldrules.js
index 0221773..514336e 100644
--- a/src/content/settings/oldrules.js
+++ b/src/content/settings/oldrules.js
@@ -39,14 +39,14 @@ function populateRuleTable() {
}
}
-function addRulesTableRow(table, type, origin, dest, ruleData) {
- var typeClass = type == 'allow' ? 'allow' : 'block';
- var ruleType = type == 'allow' ? _('allow') : _('block');
+function addRulesTableRow(table, ruleAction, origin, dest, ruleData) {
+ var actionClass = ruleAction == 'allow' ? 'allow' : 'block';
+ var action = ruleAction == 'allow' ? _('allow') : _('block');
- var row = $('<tr>').addClass(typeClass).appendTo(table);
+ var row = $('<tr>').addClass(actionClass).appendTo(table);
row.append(
- $('<td>').text(ruleType),
+ $('<td>').text(action),
$('<td>').text(origin),
$('<td>').text(dest)
);
diff --git a/src/content/settings/settings.css b/src/content/settings/settings.css
index 9766201..9d84cb5 100644
--- a/src/content/settings/settings.css
+++ b/src/content/settings/settings.css
@@ -187,7 +187,7 @@ table.settings tr:not(:first-child) {
margin-left: 0;
}
-#addrule .rule-type {
+#addrule .rule-action {
font-weight: bold;
}
diff --git a/src/content/settings/yourpolicy.html b/src/content/settings/yourpolicy.html
index 1629562..8d9ba6d 100644
--- a/src/content/settings/yourpolicy.html
+++ b/src/content/settings/yourpolicy.html
@@ -46,7 +46,7 @@
<li class="input-label">
<label data-string="policy"></label>
</li>
- <li class="rule-type">
+ <li class="rule-action">
<label class="allow">
<span data-string="allow"></span>
<input type="radio" name="allowdeny" id="allowrule" value="allow" checked="checked"/>
@@ -96,7 +96,7 @@
<div class="policydata">
<table id="policy-user">
<colgroup>
- <col class="type">
+ <col class="rule-action">
<col class="origin">
<col class="destination">
<col class="ruleset">
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index 6a11131..05e0147 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -83,9 +83,9 @@ function addRules(entries, source, filter, readOnly) {
function deleteRule(event) {
var anchor = $(event.target);
- var ruleType = anchor.data('requestpolicyRuleType');
+ var ruleAction = anchor.data('requestpolicyRuleAction');
var ruleData = anchor.data('requestpolicyRuleData');
- if (ruleType == 'allow') {
+ if (ruleAction == 'allow') {
rpService.removeAllowRule(ruleData);
} else {
rpService.removeDenyRule(ruleData);
@@ -101,15 +101,15 @@ function clearRulesTable(table) {
}
}
-function addRulesTableRow(table, type, origin, dest, ruleData, source, readOnly) {
+function addRulesTableRow(table, ruleAction, origin, dest, ruleData, source, readOnly) {
- var typeClass = type == 'allow' ? 'allow' : 'block';
- var ruleType = type == 'allow' ? _('allow') : _('block');
+ var actionClass = ruleAction == 'allow' ? 'allow' : 'block';
+ var action = ruleAction == 'allow' ? _('allow') : _('block');
- var row = $('<tr>').addClass(typeClass).appendTo(table);
+ var row = $('<tr>').addClass(actionClass).appendTo(table);
row.append(
- $('<td>').text(ruleType),
+ $('<td>').text(action),
$('<td>').text(origin),
$('<td>').text(dest),
$('<td>').text(source)
@@ -118,7 +118,7 @@ function addRulesTableRow(table, type, origin, dest, ruleData, source, readOnly)
if (!readOnly) {
var anchor = $('<a>');
anchor.text('x').addClass('deleterule');
- anchor.data('requestpolicyRuleType', type);
+ anchor.data('requestpolicyRuleAction', action);
anchor.data('requestpolicyRuleData', ruleData);
anchor.click(deleteRule);
row.append($('<td>').append(anchor));
diff --git a/src/modules/PolicyManager.jsm b/src/modules/PolicyManager.jsm
index e675955..9d50157 100644
--- a/src/modules/PolicyManager.jsm
+++ b/src/modules/PolicyManager.jsm
@@ -299,24 +299,24 @@ PolicyManager.prototype = {
return failures;
},
- _assertRuleType: function(ruleType) {
- if (ruleType != rp.mod.RULE_TYPE_ALLOW &&
- ruleType != rp.mod.RULE_TYPE_DENY) {
- throw "Invalid rule type: " + ruleType;
+ _assertRuleAction : function(ruleAction) {
+ if (ruleAction != rp.mod.RULE_ACTION_ALLOW &&
+ ruleAction != rp.mod.RULE_ACTION_DENY) {
+ throw "Invalid rule type: " + ruleAction;
}
},
- ruleExists : function(ruleType, ruleData) {
- this._assertRuleType(ruleType);
+ ruleExists : function(ruleAction, ruleData) {
+ this._assertRuleAction(ruleAction);
for (var name in this._userRulesets) {
- if (this._userRulesets[name].rawRuleset.ruleExists(ruleType, ruleData)) {
+ if (this._userRulesets[name].rawRuleset.ruleExists(ruleAction, ruleData)) {
return true;
}
}
for (var listName in this._subscriptionRulesets) {
var rulesets = this._subscriptionRulesets[listName];
for (var name in rulesets) {
- if (rulesets[name].rawRuleset.ruleExists(ruleType, ruleData)) {
+ if (rulesets[name].rawRuleset.ruleExists(ruleAction, ruleData)) {
return true;
}
}
@@ -324,14 +324,14 @@ PolicyManager.prototype = {
return false;
},
- addRule : function(ruleType, ruleData, noStore) {
- dprint("PolicyManager::addRule " + ruleType + " "
+ addRule : function(ruleAction, ruleData, noStore) {
+ dprint("PolicyManager::addRule " + ruleAction + " "
+ rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
//this._userRulesets["user"].ruleset.print();
- this._assertRuleType(ruleType);
+ this._assertRuleAction(ruleAction);
// TODO: check rule format validity
- this._userRulesets["user"].rawRuleset.addRule(ruleType, ruleData,
+ this._userRulesets["user"].rawRuleset.addRule(ruleAction, ruleData,
this._userRulesets["user"].ruleset);
// TODO: only save if we actually added a rule. This will require
@@ -354,14 +354,14 @@ PolicyManager.prototype = {
this._userRulesets["user"].rawRuleset, "user.json");
},
- addTemporaryRule : function(ruleType, ruleData) {
- dprint("PolicyManager::addTemporaryRule " + ruleType + " "
+ addTemporaryRule : function(ruleAction, ruleData) {
+ dprint("PolicyManager::addTemporaryRule " + ruleAction + " "
+ rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
//this._userRulesets["temp"].ruleset.print();
- this._assertRuleType(ruleType);
+ this._assertRuleAction(ruleAction);
// TODO: check rule format validity
- this._userRulesets["temp"].rawRuleset.addRule(ruleType, ruleData,
+ this._userRulesets["temp"].rawRuleset.addRule(ruleAction, ruleData,
this._userRulesets["temp"].ruleset);
//this._userRulesets["temp"].ruleset.print();
@@ -369,18 +369,18 @@ PolicyManager.prototype = {
notifyRulesChanged();
},
- removeRule : function(ruleType, ruleData, noStore) {
- dprint("PolicyManager::removeRule " + ruleType + " "
+ removeRule : function(ruleAction, ruleData, noStore) {
+ dprint("PolicyManager::removeRule " + ruleAction + " "
+ rp.mod.Ruleset.rawRuleToCanonicalString(ruleData));
//this._userRulesets["user"].ruleset.print();
//this._userRulesets["temp"].ruleset.print();
- this._assertRuleType(ruleType);
+ this._assertRuleAction(ruleAction);
// TODO: check rule format validity
// TODO: use noStore
- this._userRulesets["user"].rawRuleset.removeRule(ruleType, ruleData,
+ this._userRulesets["user"].rawRuleset.removeRule(ruleAction, ruleData,
this._userRulesets["user"].ruleset);
- this._userRulesets["temp"].rawRuleset.removeRule(ruleType, ruleData,
+ this._userRulesets["temp"].rawRuleset.removeRule(ruleAction, ruleData,
this._userRulesets["temp"].ruleset);
// TODO: only save if we actually removed a rule. This will require
diff --git a/src/modules/Ruleset.jsm b/src/modules/Ruleset.jsm
index c566a3c..b2a9a15 100644
--- a/src/modules/Ruleset.jsm
+++ b/src/modules/Ruleset.jsm
@@ -23,8 +23,8 @@
var EXPORTED_SYMBOLS = [
"Ruleset",
"RawRuleset",
- "RULE_TYPE_ALLOW",
- "RULE_TYPE_DENY"
+ "RULE_ACTION_ALLOW",
+ "RULE_ACTION_DENY"
];
if (!rp) {
@@ -34,8 +34,8 @@ if (!rp) {
Components.utils.import("resource://requestpolicy/DomainUtil.jsm", rp.mod);
Components.utils.import("resource://requestpolicy/Logger.jsm", rp.mod);
-const RULE_TYPE_ALLOW = 1;
-const RULE_TYPE_DENY = 2;
+const RULE_ACTION_ALLOW = 1;
+const RULE_ACTION_DENY = 2;
function dprint(msg) {
@@ -148,21 +148,21 @@ RawRuleset.prototype = {
return [rules, r];
},
- _addEntryToRuleset : function(entry, ruleType, policy) {
+ _addEntryToRuleset : function(entry, ruleAction, policy) {
// TODO: add an "entryPart" format verifier/normalizer.
// notes: 'pathPre' => path prefix (must start with "/")
var o = entry["o"];
var d = entry["d"];
var rules, r;
- //dprint("_addEntryToRuleset: " + o + " " + d + " " + ruleType);
+ //dprint("_addEntryToRuleset: " + o + " " + d + " " + ruleAction);
if (o && d) {
[rules, r] = this._addEntryHelper(o, policy);
r.initDestinations();
[rules, r] = this._addEntryHelper(d, r.destinations);
- //r.destinationRuleType = ruleType;
- if (ruleType == RULE_TYPE_ALLOW) {
+ //r.destinationRuleAction = ruleAction;
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -170,8 +170,8 @@ RawRuleset.prototype = {
} else if (o && !d) {
[rules, r] = this._addEntryHelper(o, policy);
- //r.originRuleType = ruleType;
- if (ruleType == RULE_TYPE_ALLOW) {
+ //r.originRuleAction = ruleAction;
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowOrigin = true;
} else {
r.denyOrigin = true;
@@ -179,8 +179,8 @@ RawRuleset.prototype = {
} else if (!o && d) {
[rules, r] = this._addEntryHelper(d, policy);
- //r.destinationRuleType = ruleType;
- if (ruleType == RULE_TYPE_ALLOW) {
+ //r.destinationRuleAction = ruleAction;
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -192,15 +192,15 @@ RawRuleset.prototype = {
}
},
- ruleExists : function(ruleType, ruleData) {
- var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
- ruleType == RULE_TYPE_DENY ? "deny" : "";
- if (!typeStr) {
- throw "Invalid ruleType: " + ruleType;
+ ruleExists : function(ruleAction, ruleData) {
+ var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ if (!actionStr) {
+ throw "Invalid ruleAction: " + ruleAction;
}
var ruleStr = Ruleset.rawRuleToCanonicalString(ruleData);
- var entries = this._entries[typeStr];
+ var entries = this._entries[actionStr];
for (var i in entries) {
var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
if (ruleStr == curRuleStr) {
@@ -214,25 +214,25 @@ RawRuleset.prototype = {
* Adds the rule to the entries of this |RawRuleset| instance as well as the
* |Ruleset| optionally provided as the policy argument.
*
- * @param ruleType RULE_TYPE_ALLOW|RULE_TYPE_DENY
+ * @param ruleAction RULE_ACTION_ALLOW|RULE_ACTION_DENY
* @param ruleData
*/
- addRule : function(ruleType, ruleData, policy) {
+ addRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("addRule: adding entry");
- var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
- ruleType == RULE_TYPE_DENY ? "deny" : "";
- if (!typeStr) {
- throw "Invalid ruleType: " + ruleType;
+ var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ if (!actionStr) {
+ throw "Invalid ruleAction: " + ruleAction;
}
// Only add the raw policy entry if it doesn't already exist.
- if (!this.ruleExists(ruleType, ruleData)) {
- this._entries[typeStr].push(ruleData);
+ if (!this.ruleExists(ruleAction, ruleData)) {
+ this._entries[actionStr].push(ruleData);
}
if (policy) {
- this._addEntryToRuleset(ruleData, ruleType, policy);
+ this._addEntryToRuleset(ruleData, ruleAction, policy);
}
},
@@ -249,7 +249,7 @@ RawRuleset.prototype = {
// return rules.get(entryPart["s"], entryPart["port"]);
// },
- _removeEntryFromRuleset : function(entry, ruleType, policy) {
+ _removeEntryFromRuleset : function(entry, ruleAction, policy) {
// TODO: add an "entryPart" format verifier/normalizer.
// notes: 'pathPre' => path prefix (must start with "/")
var o = entry["o"];
@@ -287,16 +287,16 @@ RawRuleset.prototype = {
return;
}
- // if (r.destinationRuleType == ruleType) {
- // r.destinationRuleType = null;
+ // if (r.destinationRuleAction == ruleAction) {
+ // r.destinationRuleAction = null;
// }
//dprint("_removeEntryFromRuleset: got rule to alter: " + r.toString());
- if (ruleType == RULE_TYPE_ALLOW) {
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleType == RULE_TYPE_DENY) {
+ } else if (ruleAction == RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
- throw "Invalid rule type: " + ruleType;
+ throw "Invalid rule type: " + ruleAction;
}
} else if (o && !d) {
@@ -314,15 +314,15 @@ RawRuleset.prototype = {
return;
}
- // if (r.originRuleType == ruleType) {
- // r.originRuleType = null;
+ // if (r.originRuleAction == ruleAction) {
+ // r.originRuleAction = null;
// }
- if (ruleType == RULE_TYPE_ALLOW) {
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowOrigin = null;
- } else if (ruleType == RULE_TYPE_DENY) {
+ } else if (ruleAction == RULE_ACTION_DENY) {
r.denyOrigin = null;
} else {
- throw "Invalid rule type: " + ruleType;
+ throw "Invalid rule type: " + ruleAction;
}
} else if (!o && d) {
@@ -340,15 +340,15 @@ RawRuleset.prototype = {
return;
}
- // if (r.destinationRuleType == ruleType) {
- // r.destinationRuleType = null;
+ // if (r.destinationRuleAction == ruleAction) {
+ // r.destinationRuleAction = null;
// }
- if (ruleType == RULE_TYPE_ALLOW) {
+ if (ruleAction == RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleType == RULE_TYPE_DENY) {
+ } else if (ruleAction == RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
- throw "Invalid rule type: " + ruleType;
+ throw "Invalid rule type: " + ruleAction;
}
} else {
@@ -361,19 +361,19 @@ RawRuleset.prototype = {
* Removes the rule from the entries of this |RawRuleset| instance as well as the
* |Ruleset| optionally provided as the policy argument.
*
- * @param ruleType RULE_TYPE_ALLOW|RULE_TYPE_DENY
+ * @param ruleAction RULE_ACTION_ALLOW|RULE_ACTION_DENY
* @param ruleData
*/
- removeRule : function(ruleType, ruleData, policy) {
+ removeRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("removeRule: removing entry");
- var typeStr = ruleType == RULE_TYPE_ALLOW ? "allow" :
- ruleType == RULE_TYPE_DENY ? "deny" : "";
- if (!typeStr) {
- throw "Invalid ruleType: " + ruleType;
+ var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ if (!actionStr) {
+ throw "Invalid ruleAction: " + ruleAction;
}
var ruleStr = Ruleset.rawRuleToCanonicalString(ruleData);
- var entries = this._entries[typeStr];
+ var entries = this._entries[actionStr];
var removeIndex = false;
for (var i in entries) {
var curRuleStr = Ruleset.rawRuleToCanonicalString(entries[i]);
@@ -391,11 +391,11 @@ RawRuleset.prototype = {
if (begin.length + end.length + 1 != entries.length) {
throw "Bad slicing (Probably bad math or not reading the docs).";
}
- this._entries[typeStr] = begin.concat(end);
+ this._entries[actionStr] = begin.concat(end);
}
if (policy) {
- this._removeEntryFromRuleset(ruleData, ruleType, policy);
+ this._removeEntryFromRuleset(ruleData, ruleAction, policy);
}
},
@@ -406,17 +406,17 @@ RawRuleset.prototype = {
toRuleset : function(name) {
var policy = new Ruleset(name);
- for (var typeStr in this._entries) {
- //dprint("typeStr: " + typeStr);
- if (typeStr != "allow" && typeStr != "deny") {
- dwarn("Invalid entry type: " + typeStr);
+ for (var actionStr in this._entries) {
+ //dprint("actionStr: " + actionStr);
+ if (actionStr != "allow" && actionStr != "deny") {
+ dwarn("Invalid entry type: " + actionStr);
continue;
}
- var ruleType = typeStr == "allow" ? RULE_TYPE_ALLOW : RULE_TYPE_DENY;
- var entryArray = this._entries[typeStr];
+ var ruleAction = actionStr == "allow" ? RULE_ACTION_ALLOW : RULE_ACTION_DENY;
+ var entryArray = this._entries[actionStr];
for (var i in entryArray) {
//dprint("toRuleset: adding entry");
- this._addEntryToRuleset(entryArray[i], ruleType, policy);
+ this._addEntryToRuleset(entryArray[i], ruleAction, policy);
}
}
@@ -549,9 +549,9 @@ Rule.prototype = {
port : null,
path : null,
- // Either null, RULE_TYPE_ALLOW, or RULE_TYPE_DENY.
- // originRuleType : null,
- // destinationRuleType : null,
+ // Either null, RULE_ACTION_ALLOW, or RULE_ACTION_DENY.
+ // originRuleAction : null,
+ // destinationRuleAction : null,
allowOrigin : null,
denyOrigin : null,
@@ -564,8 +564,8 @@ Rule.prototype = {
toString : function() {
return "[Rule " + this.scheme + " " + this.port + " " + this.path + " "
// TODO
- // + "originRuleType:" + this.originRuleType + " "
- // + "destinationRuleType:" + this.destinationRuleType + " "
+ // + "originRuleAction:" + this.originRuleAction + " "
+ // + "destinationRuleAction:" + this.destinationRuleAction + " "
+ "allowOrigin:" + this.allowOrigin + " "
+ "denyOrigin:" + this.denyOrigin + " "
+ "allowDestination:" + this.allowDestination + " "
@@ -914,14 +914,14 @@ Ruleset.prototype = {
//dprint("DENY origin by rule " + entry + " " + rule);
matchedDenyRules.push(["origin", entry, rule]);
}
- // switch(rule.originRuleType) {
- // case RULE_TYPE_ALLOW:
+ // switch(rule.originRuleAction) {
+ // case RULE_ACTION_ALLOW:
// if (ruleMatchedOrigin) {
// dprint("ALLOW origin by rule " + entry + " " + rule);
// matchedAllowRules.push(["origin", entry, rule]);
// }
// break;
- // case RULE_TYPE_DENY:
+ // case RULE_ACTION_DENY:
// if (ruleMatchedOrigin) {
// dprint("DENY origin by rule " + entry + " " + rule);
// matchedDenyRules.push(["origin", entry, rule]);
@@ -947,14 +947,14 @@ Ruleset.prototype = {
matchedDenyRules.push(["origin-to-dest", entry, rule, destEntry, destRule]);
}
- // switch(destRule.destinationRuleType) {
- // case RULE_TYPE_ALLOW:
+ // switch(destRule.destinationRuleAction) {
+ // case RULE_ACTION_ALLOW:
// if (destRule.isMatch(dest)) {
// dprint("ALLOW origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
// matchedAllowRules.push(["origin-to-dest", entry, rule, destEntry, destRule]);
// }
// break;
- // case RULE_TYPE_DENY:
+ // case RULE_ACTION_DENY:
// if (destRule.isMatch(dest)) {
// dprint("DENY origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
// matchedDenyRules.push(["origin-to-dest", entry, rule, destEntry, destRule]);
@@ -984,14 +984,14 @@ Ruleset.prototype = {
//dprint("DENY dest by rule " + entry + " " + rule);
matchedDenyRules.push(["dest", entry, rule]);
}
- // switch(rule.destinationRuleType) {
- // case RULE_TYPE_ALLOW:
+ // switch(rule.destinationRuleAction) {
+ // case RULE_ACTION_ALLOW:
// if (rule.isMatch(dest)) {
// dprint("ALLOW dest by rule " + entry + " " + rule);
// matchedAllowRules.push(["dest", entry, rule]);
// }
// break;
- // case RULE_TYPE_DENY:
+ // case RULE_ACTION_DENY:
// if (rule.isMatch(dest)) {
// dprint("DENY dest by rule " + entry + " " + rule);
// matchedDenyRules.push(["dest", entry, rule]);
@@ -1031,26 +1031,26 @@ Ruleset._matchToRawRuleHelper = function(rawRule, originOrDest, entry, rule) {
*/
Ruleset.matchToRawRule = function(match) {
// The matches are in the format
- // [typeStr, entry, rule]
+ // [actionStr, entry, rule]
// or
- // [typeStr, originEntry, originRule, destEntry, destRule]
+ // [actionStr, originEntry, originRule, destEntry, destRule]
// as returned by calls to |Ruleset.check()|.
var rawRule = {};
var entry, rule, destEntry, destRule;
- var typeStr = match[0];
+ var actionStr = match[0];
- if (typeStr == "origin") {
- [typeStr, entry, rule] = match;
+ if (actionStr == "origin") {
+ [actionStr, entry, rule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
- } else if (typeStr == "dest") {
- [typeStr, entry, rule] = match;
+ } else if (actionStr == "dest") {
+ [actionStr, entry, rule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "d", entry, rule);
- } else if (typeStr == "origin-to-dest") {
- [typeStr, entry, rule, destEntry, destRule] = match;
+ } else if (actionStr == "origin-to-dest") {
+ [actionStr, entry, rule, destEntry, destRule] = match;
Ruleset._matchToRawRuleHelper(rawRule, "o", entry, rule);
Ruleset._matchToRawRuleHelper(rawRule, "d", destEntry, destRule);
} else {
- throw "[matchToRawRule] Invalid match type: " + typeStr
+ throw "[matchToRawRule] Invalid match type: " + actionStr
+ " from match: " + match;
}
diff --git a/tests/modules/Policy/test1.js b/tests/modules/Policy/test1.js
index 944d072..b5d77c7 100644
--- a/tests/modules/Policy/test1.js
+++ b/tests/modules/Policy/test1.js
@@ -4,13 +4,13 @@ var policy = new Ruleset();
dprint("== Allow all requests from origin www.foo.com ==");
var host = policy.addHost("www.foo.com");
var r = host.rules.add();
-r.originRuleType = RULE_TYPE_ALLOW;
+r.originRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Deny all requests to destination www.foo.com ==");
var host = policy.addHost("www.foo.com");
var r = host.rules.add();
-r.destinationRuleType = RULE_TYPE_DENY;
+r.destinationRuleAction = RULE_ACTION_DENY;
dprint("=======");
dprint("== Allow all requests from https://www.foo.com to https://* ==");
@@ -18,7 +18,7 @@ var host = policy.addHost("www.foo.com");
var r = host.rules.add("https");
r.initDestinations();
var destRule = r.destinations.rules.add("https");
-destRule.destinationRuleType = RULE_TYPE_ALLOW;
+destRule.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Allow all requests from *.foo.com to *.bar.com ==");
@@ -27,19 +27,19 @@ var r = host.rules.add();
r.initDestinations();
var barHost = r.destinations.addHost("*.bar.com");
var destRule = barHost.rules.add();
-destRule.destinationRuleType = RULE_TYPE_ALLOW;
+destRule.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Allow all requests to https:// ==");
var r = policy.rules.add("https");
-r.destinationRuleType = RULE_TYPE_ALLOW;
+r.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Allow all requests to https://localhost:8888/baz ==");
var host = policy.addHost("localhost");
var r = host.rules.add("https", 8888);
r.path = "/baz";
-r.destinationRuleType = RULE_TYPE_ALLOW;
+r.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
diff --git a/tests/modules/Policy/test2.js b/tests/modules/Policy/test2.js
index b538f1e..0c9bada 100644
--- a/tests/modules/Policy/test2.js
+++ b/tests/modules/Policy/test2.js
@@ -5,7 +5,7 @@ dprint("== Allow all requests to https://localhost:8888/baz ==");
var host = policy.addHost("localhost");
var r = host.rules.add("https", 8888);
r.path = "/baz";
-r.destinationRuleType = RULE_TYPE_ALLOW;
+r.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
diff --git a/tests/modules/Policy/test3.js b/tests/modules/Policy/test3.js
index b339773..7d6dfd2 100644
--- a/tests/modules/Policy/test3.js
+++ b/tests/modules/Policy/test3.js
@@ -5,7 +5,7 @@ dprint("== Allow all requests from https://localhost:8888/baz ==");
var host = policy.addHost("localhost");
var r = host.rules.add("https", 8888);
r.path = "/baz";
-r.originRuleType = RULE_TYPE_ALLOW;
+r.originRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
diff --git a/tests/modules/Policy/test4.js b/tests/modules/Policy/test4.js
index 735f3b1..b459397 100644
--- a/tests/modules/Policy/test4.js
+++ b/tests/modules/Policy/test4.js
@@ -7,7 +7,7 @@ var r = host.rules.add();
r.initDestinations();
barHost = r.destinations.addHost("*.bar.com");
var destRule = barHost.rules.add();
-destRule.destinationRuleType = RULE_TYPE_ALLOW;
+destRule.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Deny all requests from https://*.foo.com to http://*.bar.com ==");
@@ -16,7 +16,7 @@ var r = host.rules.add("https");
r.initDestinations();
barHost = r.destinations.addHost("*.bar.com");
var destRule = barHost.rules.add("http");
-destRule.destinationRuleType = RULE_TYPE_DENY;
+destRule.destinationRuleAction = RULE_ACTION_DENY;
dprint("=======");
diff --git a/tests/modules/Policy/test5.js b/tests/modules/Policy/test5.js
index 0a74c89..03b5491 100644
--- a/tests/modules/Policy/test5.js
+++ b/tests/modules/Policy/test5.js
@@ -5,7 +5,7 @@ dprint("== Allow all requests to https://127.0.0.1:8888/baz ==");
var host = policy.addHost("127.0.0.1");
var r = host.rules.add("https", 8888);
r.path = "/baz";
-r.destinationRuleType = RULE_TYPE_ALLOW;
+r.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
dprint("== Allow all requests from [::1] to https://[a:b::c] ==");
@@ -14,7 +14,7 @@ var r = host.rules.add();
r.initDestinations();
var destHost = r.destinations.addHost("a:b::c");
var destRule = destHost.rules.add("https");
-destRule.destinationRuleType = RULE_TYPE_ALLOW;
+destRule.destinationRuleAction = RULE_ACTION_ALLOW;
dprint("=======");
diff --git a/tests/xpcshell/test_policymanager.js b/tests/xpcshell/test_policymanager.js
index e9000db..5234c5c 100644
--- a/tests/xpcshell/test_policymanager.js
+++ b/tests/xpcshell/test_policymanager.js
@@ -104,7 +104,7 @@ function test_1() {
print("Starting: " + i);
var rawRule = rules[i];
// Add a rule we just added.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -112,7 +112,7 @@ function test_1() {
do_check_eq(result.matchedAllowRules.length, 1);
// Remove the rule we just added.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -124,7 +124,7 @@ function test_1() {
do_check_false(result.isAllowed());
// Remove the same rule twice in a row.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -136,7 +136,7 @@ function test_1() {
}
// Add the original allow rule back.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -148,7 +148,7 @@ function test_1() {
do_check_true(result.isAllowed());
// Add the same rule details but as a deny rule.
- manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addRule(RULE_ACTION_DENY, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -160,7 +160,7 @@ function test_1() {
do_check_true(result.isAllowed());
// Add the same rule again.
- manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_true(result.isDenied());
@@ -168,7 +168,7 @@ function test_1() {
do_check_eq(result.matchedDenyRules.length, 1);
// Add same rule as an allow rule.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -180,8 +180,8 @@ function test_1() {
do_check_true(result.isAllowed());
// Remove both rules.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -219,7 +219,7 @@ function test_2() {
print("Starting: " + i);
var rawRule = rules[i];
// Add a rule we just added.
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -227,7 +227,7 @@ function test_2() {
do_check_eq(result.matchedAllowRules.length, 1);
// Remove the rule we just added.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -239,7 +239,7 @@ function test_2() {
do_check_false(result.isAllowed());
// Remove the same rule twice in a row.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -251,7 +251,7 @@ function test_2() {
}
// Add the original allow rule back.
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -263,7 +263,7 @@ function test_2() {
do_check_true(result.isAllowed());
// Add the same rule details but as a deny rule.
- manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_DENY, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -275,7 +275,7 @@ function test_2() {
do_check_true(result.isAllowed());
// Add the same rule again.
- manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_true(result.isDenied());
@@ -283,7 +283,7 @@ function test_2() {
do_check_eq(result.matchedDenyRules.length, 1);
// Add same rule as an allow rule.
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -295,8 +295,8 @@ function test_2() {
do_check_true(result.isAllowed());
// Remove both rules.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -336,8 +336,8 @@ function test_2() {
print("Starting: " + i);
var rawRule = rules[i];
// Add a rule as both persistent and temporary.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -345,7 +345,7 @@ function test_2() {
do_check_eq(result.matchedAllowRules.length, 2);
// Remove the rule we just added.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -357,7 +357,7 @@ function test_2() {
do_check_false(result.isAllowed());
// Remove the same rule twice in a row.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
@@ -369,8 +369,8 @@ function test_2() {
}
// Add the original allow rules back.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -382,8 +382,8 @@ function test_2() {
do_check_true(result.isAllowed());
// Add the same rule details but as a deny rule.
- manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
- manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addRule(RULE_ACTION_DENY, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_DENY, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -395,8 +395,8 @@ function test_2() {
do_check_true(result.isAllowed());
// Add the same rule again.
- manager.addRule(RULE_TYPE_DENY, rawRule, noStore);
- manager.addTemporaryRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.addRule(RULE_ACTION_DENY, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_true(result.isDenied());
@@ -404,8 +404,8 @@ function test_2() {
do_check_eq(result.matchedDenyRules.length, 2);
// Add same rule as an allow rule.
- manager.addRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.addTemporaryRule(RULE_TYPE_ALLOW, rawRule, noStore);
+ manager.addRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.addTemporaryRule(RULE_ACTION_ALLOW, rawRule, noStore);
for (var i in manager._rulesets) {
print("print ruleset: " + i);
@@ -417,8 +417,8 @@ function test_2() {
do_check_true(result.isAllowed());
// Remove both rules.
- manager.removeRule(RULE_TYPE_ALLOW, rawRule, noStore);
- manager.removeRule(RULE_TYPE_DENY, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_ALLOW, rawRule, noStore);
+ manager.removeRule(RULE_ACTION_DENY, rawRule, noStore);
result = manager.checkRequest(origin, dest);
do_check_false(result.isDenied());
diff --git a/tests/xpcshell/test_policystorage.js b/tests/xpcshell/test_policystorage.js
index 531d488..6f21250 100644
--- a/tests/xpcshell/test_policystorage.js
+++ b/tests/xpcshell/test_policystorage.js
@@ -79,8 +79,8 @@ function test_2() {
// Add all of the rules as allow rules.
for (var name in Iterator(rules, true)) {
// Do it twice to trigger bugs/check for duplicates.
- rawRuleset.addRule(RULE_TYPE_ALLOW, rules[name]);
- rawRuleset.addRule(RULE_TYPE_ALLOW, rules[name]);
+ rawRuleset.addRule(RULE_ACTION_ALLOW, rules[name]);
+ rawRuleset.addRule(RULE_ACTION_ALLOW, rules[name]);
}
// Write it to a file and read it back.
@@ -93,8 +93,8 @@ function test_2() {
// Add all of the rules as deny rules.
for (var name in Iterator(rules, true)) {
// Do it twice to trigger bugs/check for duplicates.
- rawRuleset.addRule(RULE_TYPE_DENY, rules[name]);
- rawRuleset.addRule(RULE_TYPE_DENY, rules[name]);
+ rawRuleset.addRule(RULE_ACTION_DENY, rules[name]);
+ rawRuleset.addRule(RULE_ACTION_DENY, rules[name]);
}
// Write it to a file and read it back.
@@ -105,7 +105,7 @@ function test_2() {
do_check_eq(rawRuleset._entries["deny"].length, 3);
// Remove one of the deny rules.
- rawRuleset.removeRule(RULE_TYPE_DENY, rules["origin"]);
+ rawRuleset.removeRule(RULE_ACTION_DENY, rules["origin"]);
// Write it to a file and read it back.
RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
@@ -117,8 +117,8 @@ function test_2() {
// Remove all of the deny rules.
for (var name in Iterator(rules, true)) {
// Do it twice to trigger bugs/check for duplicates.
- rawRuleset.removeRule(RULE_TYPE_DENY, rules[name]);
- rawRuleset.removeRule(RULE_TYPE_DENY, rules[name]);
+ rawRuleset.removeRule(RULE_ACTION_DENY, rules[name]);
+ rawRuleset.removeRule(RULE_ACTION_DENY, rules[name]);
}
// Write it to a file and read it back.
@@ -129,7 +129,7 @@ function test_2() {
do_check_eq(rawRuleset._entries["deny"].length, 0);
// Remove one of the allow rules.
- rawRuleset.removeRule(RULE_TYPE_ALLOW, rules["dest"]);
+ rawRuleset.removeRule(RULE_ACTION_ALLOW, rules["dest"]);
// Write it to a file and read it back.
RulesetStorage.saveRawRulesetToFile(rawRuleset, filename);
@@ -141,8 +141,8 @@ function test_2() {
// Remove all of the allow rules.
for (var name in Iterator(rules, true)) {
// Do it twice to trigger bugs/check for duplicates.
- rawRuleset.removeRule(RULE_TYPE_ALLOW, rules[name]);
- rawRuleset.removeRule(RULE_TYPE_ALLOW, rules[name]);
+ rawRuleset.removeRule(RULE_ACTION_ALLOW, rules[name]);
+ rawRuleset.removeRule(RULE_ACTION_ALLOW, rules[name]);
}
// Write it to a file and read it back.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list