aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/test')
-rw-r--r--src/node/test/call_test.js9
-rw-r--r--src/node/test/channel_test.js33
-rw-r--r--src/node/test/end_to_end_test.js7
-rw-r--r--src/node/test/health_test.js6
-rw-r--r--src/node/test/math_client_test.js6
-rw-r--r--src/node/test/server_test.js19
-rw-r--r--src/node/test/surface_test.js26
7 files changed, 67 insertions, 39 deletions
diff --git a/src/node/test/call_test.js b/src/node/test/call_test.js
index 942c31ac68..48d859a8ec 100644
--- a/src/node/test/call_test.js
+++ b/src/node/test/call_test.js
@@ -48,14 +48,17 @@ function getDeadline(timeout_secs) {
return deadline;
}
+var insecureCreds = grpc.Credentials.createInsecure();
+
describe('call', function() {
var channel;
var server;
before(function() {
server = new grpc.Server();
- var port = server.addHttp2Port('localhost:0');
+ var port = server.addHttp2Port('localhost:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
- channel = new grpc.Channel('localhost:' + port);
+ channel = new grpc.Channel('localhost:' + port, insecureCreds);
});
after(function() {
server.shutdown();
@@ -82,7 +85,7 @@ describe('call', function() {
});
});
it('should fail with a closed channel', function() {
- var local_channel = new grpc.Channel('hostname');
+ var local_channel = new grpc.Channel('hostname', insecureCreds);
local_channel.close();
assert.throws(function() {
new grpc.Call(channel, 'method');
diff --git a/src/node/test/channel_test.js b/src/node/test/channel_test.js
index 3e61d3bbc6..c991d7b25b 100644
--- a/src/node/test/channel_test.js
+++ b/src/node/test/channel_test.js
@@ -36,11 +36,13 @@
var assert = require('assert');
var grpc = require('bindings')('grpc.node');
+var insecureCreds = grpc.Credentials.createInsecure();
+
describe('channel', function() {
describe('constructor', function() {
it('should require a string for the first argument', function() {
assert.doesNotThrow(function() {
- new grpc.Channel('hostname');
+ new grpc.Channel('hostname', insecureCreds);
});
assert.throws(function() {
new grpc.Channel();
@@ -49,38 +51,49 @@ describe('channel', function() {
new grpc.Channel(5);
});
});
- it('should accept an object for the second parameter', function() {
+ it('should require a credential for the second argument', function() {
assert.doesNotThrow(function() {
- new grpc.Channel('hostname', {});
+ new grpc.Channel('hostname', insecureCreds);
});
assert.throws(function() {
new grpc.Channel('hostname', 5);
});
+ assert.throws(function() {
+ new grpc.Channel('hostname');
+ });
+ });
+ it('should accept an object for the third argument', function() {
+ assert.doesNotThrow(function() {
+ new grpc.Channel('hostname', insecureCreds, {});
+ });
+ assert.throws(function() {
+ new grpc.Channel('hostname', insecureCreds, 'abc');
+ });
});
it('should only accept objects with string or int values', function() {
assert.doesNotThrow(function() {
- new grpc.Channel('hostname', {'key' : 'value'});
+ new grpc.Channel('hostname', insecureCreds,{'key' : 'value'});
});
assert.doesNotThrow(function() {
- new grpc.Channel('hostname', {'key' : 5});
+ new grpc.Channel('hostname', insecureCreds, {'key' : 5});
});
assert.throws(function() {
- new grpc.Channel('hostname', {'key' : null});
+ new grpc.Channel('hostname', insecureCreds, {'key' : null});
});
assert.throws(function() {
- new grpc.Channel('hostname', {'key' : new Date()});
+ new grpc.Channel('hostname', insecureCreds, {'key' : new Date()});
});
});
});
describe('close', function() {
it('should succeed silently', function() {
- var channel = new grpc.Channel('hostname', {});
+ var channel = new grpc.Channel('hostname', insecureCreds, {});
assert.doesNotThrow(function() {
channel.close();
});
});
it('should be idempotent', function() {
- var channel = new grpc.Channel('hostname', {});
+ var channel = new grpc.Channel('hostname', insecureCreds, {});
assert.doesNotThrow(function() {
channel.close();
channel.close();
@@ -89,7 +102,7 @@ describe('channel', function() {
});
describe('getTarget', function() {
it('should return a string', function() {
- var channel = new grpc.Channel('localhost', {});
+ var channel = new grpc.Channel('localhost', insecureCreds, {});
assert.strictEqual(typeof channel.getTarget(), 'string');
});
});
diff --git a/src/node/test/end_to_end_test.js b/src/node/test/end_to_end_test.js
index 5d3baf823d..ea41dfc28c 100644
--- a/src/node/test/end_to_end_test.js
+++ b/src/node/test/end_to_end_test.js
@@ -57,14 +57,17 @@ function multiDone(done, count) {
};
}
+var insecureCreds = grpc.Credentials.createInsecure();
+
describe('end-to-end', function() {
var server;
var channel;
before(function() {
server = new grpc.Server();
- var port_num = server.addHttp2Port('0.0.0.0:0');
+ var port_num = server.addHttp2Port('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
- channel = new grpc.Channel('localhost:' + port_num);
+ channel = new grpc.Channel('localhost:' + port_num, insecureCreds);
});
after(function() {
server.shutdown();
diff --git a/src/node/test/health_test.js b/src/node/test/health_test.js
index bb700cc46c..be4ef1d251 100644
--- a/src/node/test/health_test.js
+++ b/src/node/test/health_test.js
@@ -54,9 +54,11 @@ describe('Health Checking', function() {
new health.Implementation(statusMap));
var healthClient;
before(function() {
- var port_num = healthServer.bind('0.0.0.0:0');
+ var port_num = healthServer.bind('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
healthServer.start();
- healthClient = new health.Client('localhost:' + port_num);
+ healthClient = new health.Client('localhost:' + port_num,
+ grpc.Credentials.createInsecure());
});
after(function() {
healthServer.shutdown();
diff --git a/src/node/test/math_client_test.js b/src/node/test/math_client_test.js
index f2751857ff..ef01870a4c 100644
--- a/src/node/test/math_client_test.js
+++ b/src/node/test/math_client_test.js
@@ -51,9 +51,11 @@ var server = require('../examples/math_server.js');
describe('Math client', function() {
before(function(done) {
- var port_num = server.bind('0.0.0.0:0');
+ var port_num = server.bind('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
- math_client = new math.Math('localhost:' + port_num);
+ math_client = new math.Math('localhost:' + port_num,
+ grpc.Credentials.createInsecure());
done();
});
after(function() {
diff --git a/src/node/test/server_test.js b/src/node/test/server_test.js
index 9c7bb465aa..a9df43909e 100644
--- a/src/node/test/server_test.js
+++ b/src/node/test/server_test.js
@@ -59,16 +59,11 @@ describe('server', function() {
it('should bind to an unused port', function() {
var port;
assert.doesNotThrow(function() {
- port = server.addHttp2Port('0.0.0.0:0');
+ port = server.addHttp2Port('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
});
assert(port > 0);
});
- });
- describe('addSecureHttp2Port', function() {
- var server;
- before(function() {
- server = new grpc.Server();
- });
it('should bind to an unused port with ssl credentials', function() {
var port;
var key_path = path.join(__dirname, '../test/data/server1.key');
@@ -77,16 +72,22 @@ describe('server', function() {
var pem_data = fs.readFileSync(pem_path);
var creds = grpc.ServerCredentials.createSsl(null, key_data, pem_data);
assert.doesNotThrow(function() {
- port = server.addSecureHttp2Port('0.0.0.0:0', creds);
+ port = server.addHttp2Port('0.0.0.0:0', creds);
});
assert(port > 0);
});
});
+ describe('addSecureHttp2Port', function() {
+ var server;
+ before(function() {
+ server = new grpc.Server();
+ });
+ });
describe('listen', function() {
var server;
before(function() {
server = new grpc.Server();
- server.addHttp2Port('0.0.0.0:0');
+ server.addHttp2Port('0.0.0.0:0', grpc.ServerCredentials.createInsecure());
});
after(function() {
server.shutdown();
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index 98f9b15bfc..dda2f8d127 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -47,6 +47,8 @@ var mathService = math_proto.lookup('math.Math');
var _ = require('lodash');
+var server_insecure_creds = grpc.ServerCredentials.createInsecure();
+
describe('File loader', function() {
it('Should load a proto file by default', function() {
assert.doesNotThrow(function() {
@@ -122,9 +124,9 @@ describe('Echo service', function() {
callback(null, call.request);
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(echo_service);
- client = new Client('localhost:' + port);
+ client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
});
after(function() {
@@ -166,10 +168,11 @@ describe('Generic client and server', function() {
callback(null, _.capitalize(call.request));
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
server.start();
var Client = grpc.makeGenericClientConstructor(string_service_attrs);
- client = new Client('localhost:' + port);
+ client = new Client('localhost:' + port,
+ grpc.Credentials.createInsecure());
});
after(function() {
server.shutdown();
@@ -214,9 +217,9 @@ describe('Echo metadata', function() {
});
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(test_service);
- client = new Client('localhost:' + port);
+ client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
});
after(function() {
@@ -335,9 +338,9 @@ describe('Other conditions', function() {
});
}
});
- port = server.bind('localhost:0');
+ port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(test_service);
- client = new Client('localhost:' + port);
+ client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
});
after(function() {
@@ -382,7 +385,8 @@ describe('Other conditions', function() {
};
var Client = surface_client.makeClientConstructor(test_service_attrs,
'TestService');
- misbehavingClient = new Client('localhost:' + port);
+ misbehavingClient = new Client('localhost:' + port,
+ grpc.Credentials.createInsecure());
});
it('should respond correctly to a unary call', function(done) {
misbehavingClient.unary(badArg, function(err, data) {
@@ -600,9 +604,9 @@ describe('Cancelling surface client', function() {
'fib': function(stream) {},
'sum': function(stream) {}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(mathService);
- client = new Client('localhost:' + port);
+ client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
});
after(function() {