Skip to content

Commit 8570cbf

Browse files
author
Илья
committed
Set token extension from json to txt
1 parent e505b5c commit 8570cbf

File tree

4 files changed

+4
-40
lines changed

4 files changed

+4
-40
lines changed

src/Auth/ReadFromJsonCredentials.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ public function getTokenInfo(): TokenInfo
2626
if(!file_exists($this->fileName)){
2727
throw new \Exception("File $this->fileName is not exists");
2828
}
29-
$data = json_decode(file_get_contents($this->fileName), true);
30-
if(!isset($data["token"])){
31-
throw new \Exception("File $this->fileName does not contain a token");
32-
}
33-
return new TokenInfo($data["token"], $this->readInterval, 1);
29+
$token = preg_filter('/\s+|\n/', "", file_get_contents($this->fileName));
30+
return new TokenInfo($token, $this->readInterval, 1);
3431
}
3532

3633
public function getName(): string

tests/CheckReadTokenFileTest.php

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,12 @@ public function testReadTokenFile(){
1919
// Auto discovery (dedicated server only)
2020
'discovery' => false,
2121

22-
'credentials' => new ReadFromJsonCredentials("./tests/token.json")
22+
'credentials' => new ReadFromJsonCredentials("./tests/token.txt")
2323
];
2424

2525
$ydb = new Ydb($config);
2626
self::assertEquals('test-example-token',
2727
$ydb->iam()->token()
2828
);
29-
30-
31-
}
32-
33-
private function getYdbResult(array $config) : array
34-
{
35-
$table = $ydb->table();
36-
37-
$session = $table->createSession();
38-
39-
$session->createTable(
40-
'episodes',
41-
YdbTable::make()
42-
->addColumn('series_id', 'UINT64')
43-
->addColumn('title', 'UTF8')
44-
->addColumn('episode_id', 'UINT64')
45-
->addColumn('season_id', 'UINT64')
46-
->primaryKey('series_id')
47-
);
48-
49-
$session->transaction(function($session) {
50-
return $session->query('
51-
UPSERT INTO `episodes` (series_id, season_id, episode_id, title)
52-
VALUES (2, 6, 1, "TBD");');
53-
});
54-
55-
$result = $session->query('select `series_id`, `season_id`, `episode_id`, `title` from `episodes`;');
56-
return [$result->rowCount(), $result->rows()[0]["season_id"],
57-
$result->rows()[0]["episode_id"],
58-
$result->rows()[0]["series_id"],
59-
$result->rows()[0]["title"]];
6029
}
6130
}

tests/token.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/token.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test-example-token

0 commit comments

Comments
 (0)