Changes to Universal Port:

* Add tests
* Introduce requestRole helper
* Always honor admin=no
* Welcome guests anywhere admin privileges aren't required
This commit is contained in:
Nicholas Dudfield
2014-11-10 11:07:54 +07:00
committed by Tom Ritchford
parent aaf98082e9
commit 91871b418b
11 changed files with 712 additions and 175 deletions

View File

@@ -2,10 +2,27 @@
// Configuration for unit tests: to be locally customized as needed.
//
var extend = require('extend');
var path = require("path");
var extend = require('extend');
var testconfig = require("./testconfig.js");
//
// Helpers
//
function lines () {
return Array.prototype.slice.call(arguments).join('\n');
};
function for_each_item (o, f) {
for (var k in o) {
if (o.hasOwnProperty(k)) {
f(k, o[k], o);
}
}
};
exports.accounts = testconfig.accounts;
exports.server_default = "alpha";
@@ -21,8 +38,6 @@ exports.default_server_config = {
// For testing, you might choose to target a persistent server at alternate ports.
//
var lines = function() {return Array.prototype.slice.call(arguments).join('\n')}
exports.servers = {
// A local test server.
"alpha" : {
@@ -58,6 +73,20 @@ exports.servers = {
'node_db': lines('type=memory',
'path=integration')
},
'uniport_tests' : {
// rippled.cfg
'node_db': lines('type=memory', 'path=integration'),
// We let testutils.build_setup connect normally, and use the Remote to
// determine when the server is ready, so we must configure it, even though
// we don't otherwise use it in the test.
'websocket_ip': "127.0.0.1",
'websocket_port': 6432,
'websocket_ssl': false,
'trusted' : true,
}
};
@@ -66,6 +95,71 @@ exports.servers.debug = extend({
debug_logfile: "debug.log"
}, exports.servers.alpha);
exports.uniport_test_ports = {
'port_admin_http':
{'admin': 'allow', 'port': 6434, 'protocol': 'http'},
'port_admin_http_and_https':
{'admin': 'allow', 'port': 6437, 'protocol': 'http,https'},
'port_admin_https':
{'admin': 'allow', 'port': 6435, 'protocol': 'https'},
'port_admin_ws':
{'admin': 'allow', 'port': 6432, 'protocol': 'ws'},
'port_admin_ws_and_wss':
{'admin': 'allow', 'port': 6436, 'protocol': 'ws,wss'},
'port_admin_wss':
{'admin': 'allow', 'port': 6433, 'protocol': 'wss'},
'port_http':
{'admin': 'no', 'port': 6440, 'protocol': 'http'},
'port_http_and_https':
{'admin': 'no', 'port': 6443, 'protocol': 'http,https'},
'port_https':
{'admin': 'no', 'port': 6441, 'protocol': 'https'},
'port_https_and_http_and_peer':
{'admin': 'no', 'port': 6450, 'protocol': 'https,peer,http'},
'port_passworded_admin_http':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6446, 'protocol': 'http'},
'port_passworded_admin_http_and_https':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6449, 'protocol': 'http,https'},
'port_passworded_admin_https':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6447, 'protocol': 'https'},
'port_passworded_admin_ws':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6444, 'protocol': 'ws'},
'port_passworded_admin_ws_and_wss':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6448, 'protocol': 'ws,wss'},
'port_passworded_admin_wss':
{'admin': 'allow', 'admin_password': 'p', 'admin_user': 'u',
'port': 6445, 'protocol': 'wss'},
'port_ws':
{'admin': 'no', 'port': 6438, 'protocol': 'ws'},
'port_ws_and_wss':
{'admin': 'no', 'port': 6442, 'protocol': 'ws,wss'},
'port_wss':
{'admin': 'no', 'port': 6439, 'protocol': 'wss'}
};
(function() {
var server_config = exports.servers.uniport_tests;
var test_ports = exports.uniport_test_ports;
// [server]
server_config.server = Object.keys(test_ports).join('\n');
// [port_*]
for_each_item(test_ports, function(port_name, options) {
var opt_line = ['ip=127.0.0.1'];
for_each_item(options, function(k, v) {opt_line.push(k+'='+v);});
server_config[port_name] = opt_line.join('\n');
});
}());
exports.http_servers = {
// A local test server
"zed" : {