keithwhor / nodal

API Services Made Easy With Node.js
http://www.nodaljs.com/
MIT License
4.51k stars 209 forks source link

Testing access_tokens endpoint #305

Open troyconquer opened 8 years ago

troyconquer commented 8 years ago

Hi there,

I'm having an issue getting my integration test to run - and I may be doing something wrong. I noticed #300 could be related.

Try to run:

...
    it('Should return an HTTP 200', done => {
      let body = {
        "grant_type": "password",
        "username": "test@emails.com",
        "password": "password"
      }

      this.endpoint("/v1/access_tokens").post(body, (status, headers, body, json) => {

        //returns 400
        expect(status).to.equal(200);
        done();

      });

    });
...

access_token.js

...
  static login(params, callback) {

    //grant_type is not set..
    if (params.body.grant_type !== 'password') {
      return callback(new Error('Must supply grant_type'));
    }

    User.query()
      .where({username: params.body.username})
...

Hope I'm missing something silly. Halp?

Thanks,

Troy

keithwhor commented 8 years ago

Aha. These could be related. It'll take a few days for me to dig into this and https://github.com/keithwhor/nodal/issues/300, but will let you know when I do.

eperiou commented 7 years ago

Is this user in the database already?