Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add failing test for no key provided fail #24

Closed
wants to merge 1 commit into from

2 participants

@vvo
vvo commented

See #23

@mbrevoort

This failing cause of this issue should be fixed by this PR I just submitted #34 . Your test will still fail though because there's never a case when reject would be emitted on the client, only on the server and on service registration rather than connect.

@vvo vvo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2013
  1. @vvo

    Add failing test for issue #23

    vvo authored
This page is out of date. Refresh to see the latest.
Showing with 43 additions and 0 deletions.
  1. +43 −0 test/no_key_provided.js
View
43 test/no_key_provided.js
@@ -0,0 +1,43 @@
+var test = require('tap').test;
+var seaport = require('../');
+
+var crypto = require('crypto');
+var fs = require('fs');
+var keys = [
+ {
+ private : fs.readFileSync(__dirname + '/keys/beep'),
+ public : fs.readFileSync(__dirname + '/keys/beep.pem'),
+ },
+ {
+ private : fs.readFileSync(__dirname + '/keys/boop'),
+ public : fs.readFileSync(__dirname + '/keys/boop.pem'),
+ },
+];
+
+test('reject unauthorized hosts', function (t) {
+ t.plan(1);
+
+ var server = seaport.createServer({
+ authorized : [ keys[0] ],
+ public : keys[0].public,
+ private : keys[0].private,
+ });
+ server.listen(0);
+
+ server.on('register', function (service) {
+ t.fail('registered when it should have been rejected');
+ });
+
+ var ports = seaport.connect(server.address().port);
+ ports.once('reject', function (from, msg) {
+ t.equal(msg.type, 'address');
+ t.equal(msg.node, ports.doc.id);
+ });
+
+ var port = ports.register('http');
+
+ t.on('end', function () {
+ server.close();
+ ports.close();
+ });
+});
Something went wrong with that request. Please try again.