-
Notifications
You must be signed in to change notification settings - Fork 7
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
Undefined token in Api Tests #45
Comments
Default application uses Faker to populate the database with some data. The data are originally random though until you change seed script it will have
And here are default methods with those default emails/passwords to have API tokens. If you modify migrations/seeds you obviously need to make some changes in the login trait. The actual changes are application specific. |
/**
* @param string $username
* @param string $password
*
* @return string
*/
private function requestOAuthToken(string $username, string $password): string
{
/** @var ResponseInterface $response */
$response = $this->post('/token', [
'grant_type' => 'password',
'username' => $username,
'password' => $password,
]);
assert($response->getStatusCode() == 200);
assert(($token = json_decode((string)$response->getBody())) !== false);
$value = $token->access_token;
assert(empty($value) === false);
return $value;
} tested out $token was not assigned assert(($token = json_decode((string)$response->getBody())) !== false); and therefore getAdminOAuthToken failed |
What are the inputs (username, password)? Does it work with the default app? |
both default faker seeded username and password and; replacing assert(($token = json_decode((string)$response->getBody())) !== false); with $token = json_decode((string)$response->getBody());
assert($token !== false); in OAuthLoginTrait |
|
Hi @neomerx.
I found the OAuthLoginTrait does not properly returning token based on corresponding role of user, says "admin", etc...
The text was updated successfully, but these errors were encountered: