Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test for authentication

  • Loading branch information...
commit 3ce4ceb4a3a62563a64c489524a29198490f1eed 1 parent fd70792
@substack authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 test/secret.js
View
37 test/secret.js
@@ -0,0 +1,37 @@
+var seaport = require('../');
+var test = require('tap').test;
+
+test('secret', function (t) {
+ t.plan(4);
+ var serverPort = Math.floor(Math.random() * 5e5 + 1e5);
+ var server = seaport.createServer({ secret : 'o_O' });
+ server.listen(serverPort);
+
+ var ports = [
+ seaport.connect(serverPort, { secret : 'o_O' }),
+ seaport.connect(serverPort, { secret : 'o_O' }),
+ ];
+
+ var t0 = Date.now();
+ ports[0].get('woo', function (ps) {
+ t.ok(Date.now() - t0 >= 100);
+ t.equal(ps.length, 1);
+ t.equal(ps[0].host, '127.0.0.1');
+ t.equal(ps[0].port, gotPort);
+ t.end();
+ });
+
+ var gotPort;
+ setTimeout(function () {
+ ports[1].service('woo', function (port, ready) {
+ gotPort = port;
+ setTimeout(ready, 50);
+ });
+ }, 50);
+
+ t.on('end', function () {
+ server.close();
+ ports[0].close();
+ ports[1].close();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.