Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

test: init#28

Open
julienfroidefond wants to merge 4 commits into
masterfrom
test/init
Open

test: init#28
julienfroidefond wants to merge 4 commits into
masterfrom
test/init

Conversation

@julienfroidefond

Copy link
Copy Markdown
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

julienfroidefond commented Apr 8, 2021

Copy link
Copy Markdown
Owner Author

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

julienfroidefond commented Apr 8, 2021

Copy link
Copy Markdown
Owner Author

Code of the user I've tried :

const mockUserData = {
  username: "tester",
  email: "tester@strapi.com",
  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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants