keithwhor/nodal

Testing access_tokens endpoint

troyconquer opened this issue · 2 comments

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

Aha. These could be related. It'll take a few days for me to dig into this and #300, but will let you know when I do.

Is this user in the database already?