Make tokens, created by client credentials grant to live forever

This commit is contained in:
ErickSkrauch
2019-12-06 18:31:04 +03:00
parent 6fb32ec76d
commit f0a73f2b7a
8 changed files with 113 additions and 29 deletions

View File

@@ -21,19 +21,20 @@ class AuthenticationResultTest extends TestCase {
}
public function testGetAsResponse() {
$token = Yii::$app->tokens->create();
$time = time() + 3600;
$token = Yii::$app->tokens->create(['exp' => $time]);
$jwt = (string)$token;
$model = new AuthenticationResult($token);
$result = $model->formatAsOAuth2Response();
$this->assertSame($jwt, $result['access_token']);
$this->assertEqualsWithDelta(3600, $result['expires_in'], 1);
$this->assertSame(3600, $result['expires_in']);
$this->assertArrayNotHasKey('refresh_token', $result);
$model = new AuthenticationResult($token, 'refresh_token');
$result = $model->formatAsOAuth2Response();
$this->assertSame($jwt, $result['access_token']);
$this->assertEqualsWithDelta(3600, $result['expires_in'], 1);
$this->assertSame(3600, $result['expires_in']);
$this->assertSame('refresh_token', $result['refresh_token']);
}