Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
fix test-net-pipe-connect-errors for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Mar 1, 2012
1 parent 8cdbf01 commit 67b10f8
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions test/simple/test-net-pipe-connect-errors.js
Expand Up @@ -53,29 +53,34 @@ noEntSocketClient.on('error', function(err) {
});


// Trying to connect to a socket one has no access to should result in EACCES
var accessServer = net.createServer(function() {
assert.ok(false);
});
accessServer.listen(common.PIPE, function() {
fs.chmodSync(common.PIPE, 0);

var accessClient = net.createConnection(common.PIPE, function() {
// On Windows a chmod has no effect on named pipes
if (process.platform !== 'win32') {
// Trying to connect to a socket one has no access to should result in EACCES
var accessServer = net.createServer(function() {
assert.ok(false);
});
accessServer.listen(common.PIPE, function() {
fs.chmodSync(common.PIPE, 0);

accessClient.on('error', function(err) {
assert.equal(err.code, 'EACCES');
accessErrorFired = true;
accessServer.close();
var accessClient = net.createConnection(common.PIPE, function() {
assert.ok(false);
});

accessClient.on('error', function(err) {
assert.equal(err.code, 'EACCES');
accessErrorFired = true;
accessServer.close();
});
});
});
}


// Assert that all error events were fired
process.on('exit', function() {
assert.ok(notSocketErrorFired);
assert.ok(noEntErrorFired);
assert.ok(accessErrorFired);
if (process.platform !== 'win32') {
assert.ok(accessErrorFired);
}
});

0 comments on commit 67b10f8

Please sign in to comment.