StaticCredentialsTest.php 966 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace YdbPlatform\Ydb\Test;
  3. use PHPUnit\Framework\TestCase;
  4. use YdbPlatform\Ydb\Auth\Implement\AccessTokenAuthentication;
  5. use YdbPlatform\Ydb\Auth\Implement\StaticAuthentication;
  6. use YdbPlatform\Ydb\Logger\SimpleStdLogger;
  7. use YdbPlatform\Ydb\Ydb;
  8. class StaticCredentialsTest extends TestCase
  9. {
  10. public function testGetAuthToken()
  11. {
  12. $config = [
  13. // Database path
  14. 'database' => '/local',
  15. // Database endpoint
  16. 'endpoint' => 'localhost:2136',
  17. // Auto discovery (dedicated server only)
  18. 'discovery' => false,
  19. // IAM config
  20. 'iam_config' => [
  21. 'insecure' => true,
  22. ],
  23. 'credentials' => new StaticAuthentication('testuser', 'test_password')
  24. ];
  25. $ydb = new Ydb($config, new SimpleStdLogger(7));
  26. $ydb->table()->query("SELECT 1;");
  27. self::assertNotEquals("", $ydb->token());
  28. }
  29. }