Skip to content

Commit 10b5fcb

Browse files
authored
Update RefreshTokenTest.php
1 parent 49b218b commit 10b5fcb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/RefreshTokenTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ class FakeCredentials extends Auth {
1414
*/
1515
protected $counter;
1616

17-
public function __construct(&$counter)
17+
protected $tokenLiveTime;
18+
19+
public function __construct(&$counter, &$tokenLiveTime)
1820
{
1921
$this->counter = &$counter;
22+
$this->tokenLiveTime = &$tokenLiveTime;
2023
}
2124

2225
public function getTokenInfo(): TokenInfo
@@ -25,7 +28,7 @@ public function getTokenInfo(): TokenInfo
2528
if ($this->counter==2){
2629
throw new \Exception("Some error");
2730
}
28-
return new TokenInfo(time()+10,time()+10);
31+
return new TokenInfo(time()+$this->tokenLiveTime,time()+$this->tokenLiveTime);
2932
}
3033

3134
public function getName(): string
@@ -46,6 +49,8 @@ public function test(){
4649

4750
$counter = 0;
4851

52+
$TOKEN_LIVE_TIME = 10;
53+
4954
$config = [
5055

5156
// Database path
@@ -82,9 +87,8 @@ public function test(){
8287
$token,
8388
MetaGetter::getMeta($session)["x-ydb-auth-ticket"][0]
8489
);
85-
8690
// Check that sdk used old token when failed refreshing
87-
usleep(2*1000*1000); // waiting 2 seconds
91+
usleep(TokenInfo::_PRIVATE_REFRESH_RATIO*$TOKEN_LIVE_TIME*1000*1000); // waiting 10% from token live time
8892
$session->query('select 1 as res');
8993
self::assertEquals(
9094
2,

0 commit comments

Comments
 (0)