public function PasswordGrantTest::testThatPasswordGrantLoginSendsBasicRequestCorrectly in Auth0 Single Sign On 8.2
Test that a basic password grant request includes the correct URL, body, and headers.
Throws
ApiException If username or password is missing.
File
- vendor/
auth0/ auth0-php/ tests/ API/ Authentication/ PasswordGrantTest.php, line 108
Class
- PasswordGrantTest
- Class PasswordGrantTest Tests the Authentication API class, specifically password grants.
Namespace
Auth0\Tests\API\AuthenticationCode
public function testThatPasswordGrantLoginSendsBasicRequestCorrectly() {
$api = new MockAuthenticationApi([
new Response(200),
]);
$api
->call()
->login_with_default_directory([
'username' => 'the_username',
'password' => 'the_password',
]);
$this
->assertEquals('https://test-domain.auth0.com/oauth/token', $api
->getHistoryUrl());
$request_headers = $api
->getHistoryHeaders();
$this
->assertArrayHasKey('Auth0-Client', $request_headers);
$this
->assertEquals(self::$expectedTelemetry, $request_headers['Auth0-Client'][0]);
$this
->assertArrayHasKey('Content-Type', $request_headers);
$this
->assertEquals('application/json', $request_headers['Content-Type'][0]);
$request_body = $api
->getHistoryBody();
$this
->assertEquals('the_username', $request_body['username']);
$this
->assertEquals('the_password', $request_body['password']);
$this
->assertEquals('password', $request_body['grant_type']);
$this
->assertEquals('__test_client_id__', $request_body['client_id']);
$this
->assertEquals('__test_client_secret__', $request_body['client_secret']);
}