Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied when running the test #53

Open
tciuro opened this issue Jul 8, 2013 · 4 comments
Open

Permission denied when running the test #53

tciuro opened this issue Jul 8, 2013 · 4 comments

Comments

@tciuro
Copy link

tciuro commented Jul 8, 2013

Hi,

I've tried to follow the instructions, but I keep on getting a "Permission denied" error:

Macintosh:foo tito$ npm test
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No readme data.

> [email protected] test /Users/tito/Desktop/FooDevelopment/foo
> tests/*-test.js

sh: tests/connect-test.js: Permission denied
npm ERR! weird error 126
npm ERR! not ok code 0
Macintosh:foo tito$ 

I'm not sure what's wrong. This is what tests/connect-test.js looks like:

var APIeasy = require('api-easy');
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')
  .post('/connection')
  .expect(200)
.export(module);

The permissions look like this

-rw-r--r--   1 tito  staff  2311 Jul  7 20:39 connect-test.js

Any ideas? Thanks!

@indexzero
Copy link
Contributor

Maybe you don't have permission to listen on that port? What is the code you're testing?

@tciuro
Copy link
Author

tciuro commented Jul 9, 2013

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.

@tciuro
Copy link
Author

tciuro commented Jul 9, 2013

I'm having no trouble at all performing the invocation from the browser. Weird...

@tciuro
Copy link
Author

tciuro commented Jul 9, 2013

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 [email protected] No repository field.
npm WARN package.json [email protected] No readme data.

> [email protected] 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants