Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function () {
FabricCAServices._parseURL(badURL3);
},
/InvalidURL: url must start with http or https./,
var goodHost = 'www.example.com';
var goodPort = 7054;
var goodURL = 'http://' + goodHost + ':' + goodPort;
var goodURLSecure = 'https://' + goodHost + ':' + goodPort;
var badHost = '';
var badURL = 'http://' + badHost + ':' + goodPort;
var badURL2 = 'httpD://' + goodHost + ':' + goodPort;
var badURL3 = 'httpsD://' + goodHost + ':' + goodPort;
var badURL4 = goodHost + ':' + goodPort;
t.plan(10);
//valid http endpoint
var endpointGood = FabricCAServices._parseURL(goodURL);
t.equals(endpointGood.protocol, 'http', 'Check that protocol is set correctly to \'http\'');
t.equals(endpointGood.hostname, goodHost, 'Check that hostname is set correctly');
t.equals(endpointGood.port, goodPort, 'Check that port is set correctly');
//valid https endpoint
var endpointGoodSecure = FabricCAServices._parseURL(goodURLSecure);
t.equals(endpointGoodSecure.protocol, 'https', 'Check that protocol is set correctly to \'https\'');
t.equals(endpointGoodSecure.hostname, goodHost, 'Check that hostname is set correctly');
t.equals(endpointGoodSecure.port, goodPort, 'Check that port is set correctly');
//check invalid endpoints
t.throws(
function () {
FabricCAServices._parseURL(badURL);
},
/InvalidURL: missing hostname./,
var badURL = 'http://' + badHost + ':' + goodPort;
var badURL2 = 'httpD://' + goodHost + ':' + goodPort;
var badURL3 = 'httpsD://' + goodHost + ':' + goodPort;
var badURL4 = goodHost + ':' + goodPort;
t.plan(10);
//valid http endpoint
var endpointGood = FabricCAServices._parseURL(goodURL);
t.equals(endpointGood.protocol, 'http', 'Check that protocol is set correctly to \'http\'');
t.equals(endpointGood.hostname, goodHost, 'Check that hostname is set correctly');
t.equals(endpointGood.port, goodPort, 'Check that port is set correctly');
//valid https endpoint
var endpointGoodSecure = FabricCAServices._parseURL(goodURLSecure);
t.equals(endpointGoodSecure.protocol, 'https', 'Check that protocol is set correctly to \'https\'');
t.equals(endpointGoodSecure.hostname, goodHost, 'Check that hostname is set correctly');
t.equals(endpointGoodSecure.port, goodPort, 'Check that port is set correctly');
//check invalid endpoints
t.throws(
function () {
FabricCAServices._parseURL(badURL);
},
/InvalidURL: missing hostname./,
'Throw error for missing hostname'
);
t.throws(
function () {
FabricCAServices._parseURL(badURL2);
function () {
FabricCAServices._parseURL(badURL);
},
/InvalidURL: missing hostname./,
function () {
FabricCAServices._parseURL(badURL2);
},
/InvalidURL: url must start with http or https./,