Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Tests does not call authorize inside validators #59

Open
rbartholomay opened this issue Nov 8, 2019 · 0 comments
Open

Tests does not call authorize inside validators #59

rbartholomay opened this issue Nov 8, 2019 · 0 comments
Labels

Comments

@rbartholomay
Copy link

Hi!

I use the authorize method inside a model and it runs fine. But when i run my tests, the method will not be called. If icall my route via a rest client i can see the console.log('authorize') , when run test the method will not called.

class StoreRemoteSystem {
  /**
   * Define the Validation-Rule (Object)
   */
  get rules() {
    return {
      name: 'required|string|max:80',
      description: 'string|max:254',
      protocol: 'required|string|max:20',
      host: 'string|string|max:254',
      port: 'required|integer',
      username: 'required|max:254',
      password: 'required|max:254',
      domain: 'alphaNumeric|max:254',
      database: 'max:254'
    };
  }

  async authorize() {
    console.log('authorize');

    const canStore = this.ctx.auth.user.can_update_credentials;

    if (!canStore) {
      this.ctx.response.unauthorized('Not authorized');
      return false;
    }

    return true;
  }

the test:

test('Get a list of all stored users', async ({ assert, client }) => {
  const response = await client
    .get('/users')
    .loginVia(user.email, 'Start12#', 'basic')
    .end();

  response.assertStatus(200);
}).timeout(30000);

Bug, or did i miss something?

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

No branches or pull requests

1 participant