public function SimpleOauthAuthenticationTest::getTokenValueProvider in Simple OAuth (OAuth2) & OpenID Connect 8
File
- tests/
src/ Unit/ Authentication/ Provider/ SimpleOauthAuthenticationTest.php, line 38
Class
- SimpleOauthAuthenticationTest
- Class SimpleOauthAuthenticationTest.
Namespace
Drupal\Tests\simple_oauth\Unit\Authentication\ProviderCode
public function getTokenValueProvider() {
$data = [];
// 1. Authentication header.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$request->headers
->set('Authorization', 'Bearer ' . $token);
$data[] = [
$request,
$token,
];
// 2. Authentication header. Fail: wrong token.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$request->headers
->set('Authorization', 'Bearer fail--' . $token);
$data[] = [
$request,
'fail--' . $token,
];
// 3. Authentication header. Fail: no token.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$data[] = [
$request,
NULL,
];
// 4. Form encoded parameter.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$request
->setMethod(Request::METHOD_POST);
$request->headers
->set('Content-Type', 'application/x-www-form-urlencoded');
$request->request
->set('access_token', $token);
$data[] = [
$request,
$token,
];
// 5. Form encoded parameter. Fail: missing content type.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$request
->setMethod(Request::METHOD_POST);
$request->request
->set('access_token', $token);
$data[] = [
$request,
NULL,
];
// 6. Form encoded parameter. Fail: missing token.
$request = new Request();
$request
->setMethod(Request::METHOD_POST);
$request->headers
->set('Content-Type', 'application/x-www-form-urlencoded');
$data[] = [
$request,
NULL,
];
// 7. Form encoded parameter. Fail: wrong method.
$token = $this
->getRandomGenerator()
->name();
$request = new Request();
$request
->setMethod(Request::METHOD_GET);
$request->headers
->set('Content-Type', 'application/x-www-form-urlencoded');
$request->request
->set('access_token', $token);
$data[] = [
$request,
NULL,
];
return $data;
}