Open tciuro opened 11 years ago
Maybe you don't have permission to listen on that port? What is the code you're testing?
It's a node.js server that's working fine (I'm actually testing it with Objective-C and Chrome's Dev HTTP Client utility. I'm running on port 8080 without issues:
9 Jul 00:09:02 - [nodemon] starting `node app.js localhost 8080`
Express HTTP server listening on port 8080
Assuming that the server is running fine, the above code would report a 403 as opposed to permission denied, right? Or is this permission denied the result of an HTTP 403? (which the server returns if no authentication has succeeded)
Thank you.
I'm having no trouble at all performing the invocation from the browser. Weird...
OK, somehow I got it to work (I've tried so many things I'm not sure what made it work.) This is the dummy test I setup in place:
function showStats(req, res) {
log.info('GET /admin/stats');
var someValue = '12345';
res.writeHead(200, {
'Content-Type': 'application/json',
});
res.write(JSON.stringify({
someValue: someValue
}));
return res.end();
}
module.exports.initialize = function (app) {
app.get('/admin/stats', showStats);
};
This is the test:
var APIeasy = require('api-easy'),
assert = require('assert');
var suite = APIeasy.describe('your/awesome/api');
suite.discuss('When using your awesome API')
.discuss('and your awesome resource')
.use('localhost', 8080)
.setHeader('Content-Type', 'application/json')
.get('/admin/stats')
.expect(200)
.export(module);
When I call npm test, I get the following:
Macintosh:fooTest tito$ npm test
npm WARN package.json fooTest@0.0.1 No repository field.
npm WARN package.json fooTest@0.0.1 No readme data.
> fooTest@0.0.1 test /Users/tito/Desktop/fooTest
> vows test/*-test.js
✗
When using your awesome API and your awesome resource A GET to /admin/stats
✗ should respond with 200
» expected 200,
got 400 (==) // api-easy.js:290
✗ Broken » 1 broken (1.330s)
npm ERR! weird error 1
npm ERR! not ok code 0
Macintosh:fooTest tito$
How in the world is it getting a 400? It's impossible! Again, if I invoke it via http://localhost:8080/admin/stats I get back:
{
"someValue":"12345"
}
Even Charles proxy shows that the response is a 200. What gives?
Hi,
I've tried to follow the instructions, but I keep on getting a "Permission denied" error:
I'm not sure what's wrong. This is what tests/connect-test.js looks like:
The permissions look like this
Any ideas? Thanks!