ERROR trying to make login test: key must be at least 16 characters


#1

Hi,
I’m trying make test for login route and ever return this message:

'Error: key must be at least 16 characters long\nError: key must be at least 16 characters long\n

This is my test:

'use strict'

const User = use('App/Models/User');

const { test, trait } = use('Test/Suite')('Login')

trait("Test/ApiClient");
trait("DatabaseTransactions");

test('Login', async ({ client }) => {
  const payload = {
    username: "jackbauer",
    email: "jackbauer@fox.com",
    password: "jack123"
  }

  await User.create({ ...payload });

  const response = await client
    .post("/api/v1/auth/login")
    .send(payload)
    .end();

  console.log(response);

})

This is my AuthController:

  async login({ request, response, auth }) {
    const { email, password } = request.all();

    try {
      return await auth.attempt(email, password);
    } catch (error) {
      return response.status(500).json(error);
    }
  }

But, I realized that when we take auth from login, this works fine. Can someone explain me?