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

test: init #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

test: init #28

wants to merge 4 commits into from

Conversation

julienfroidefond
Copy link
Owner

initialisation of env and tests files + in comment the future test of tree

re #25

initialisation of env and tests files + in comment the future test of tree

re #25
@julienfroidefond
Copy link
Owner Author

julienfroidefond commented Apr 8, 2021

I'm driving crazy with the jwt mock .... I've tried to get a jwt from a user; KO (Forbidden / forbidden) I tried with the one I use everywhere, KO (Forbidden / Invalid credentials) .... Help @dalexanco ?

@julienfroidefond
Copy link
Owner Author

julienfroidefond commented Apr 8, 2021

Code of the user I've tried :

const mockUserData = {
  username: "tester",
  email: "[email protected]",
  provider: "local",
  password: "1234abc",
  confirmed: true,
  blocked: null,
};

const getJwt = async () => {
  const defaultRole = await strapi
    .query("role", "users-permissions")
    .findOne({ id: 1 }, []);

  const role = defaultRole ? defaultRole.id : null;
  /** Creates a new user an push to database */
  const user = await strapi.plugins["users-permissions"].services.user.add({
    ...mockUserData,
    role,
  });

  const jwt = strapi.plugins["users-permissions"].services.jwt.issue({
    id: user.id,
  });
  return jwt;
};

I think the route haven't policy; so this is not the right way. But I can't find the way to use super admin account or the doc jwt

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

Successfully merging this pull request may close these issues.

2 participants