|
2 | 2 |
|
3 | 3 | namespace Tarantool\Tests\Integration;
|
4 | 4 |
|
| 5 | +use Tarantool\Exception\Exception; |
5 | 6 | use Tarantool\Tests\Assert;
|
6 | 7 |
|
7 | 8 | class ClientTest extends \PHPUnit_Framework_TestCase
|
@@ -77,4 +78,42 @@ public function testFlushSpaces()
|
77 | 78 |
|
78 | 79 | $this->assertSame(4, Utils::getTotalSelectCalls() - $total);
|
79 | 80 | }
|
| 81 | + |
| 82 | + public function testSpacesAreFlushedAfterSuccessfulAuthentication() |
| 83 | + { |
| 84 | + $client = Utils::createClient(); |
| 85 | + |
| 86 | + $client->getSpace('space_conn')->select(); |
| 87 | + $client->authenticate('user_foo', 'foo'); |
| 88 | + |
| 89 | + try { |
| 90 | + $client->getSpace('space_conn')->select(); |
| 91 | + } catch (Exception $e) { |
| 92 | + // this error means that the client tried to select 'space_conn' |
| 93 | + // from '_vspace' to get the space id instead of getting it directly |
| 94 | + // from the cache (otherwise it will be 'Read access denied' error) |
| 95 | + $this->assertSame("Space 'space_conn' does not exist", $e->getMessage()); |
| 96 | + |
| 97 | + return; |
| 98 | + } |
| 99 | + |
| 100 | + $this->fail(); |
| 101 | + } |
| 102 | + |
| 103 | + public function testSpacesAreNotFlushedAfterFailedAuthentication() |
| 104 | + { |
| 105 | + $client = Utils::createClient(); |
| 106 | + |
| 107 | + $client->getSpace('space_conn')->select(); |
| 108 | + $total = Utils::getTotalSelectCalls(); |
| 109 | + |
| 110 | + try { |
| 111 | + $client->authenticate('user_foo', 'incorrect_password'); |
| 112 | + } catch (Exception $e) { |
| 113 | + $this->assertSame("Incorrect password supplied for user 'user_foo'", $e->getMessage()); |
| 114 | + } |
| 115 | + |
| 116 | + $client->getSpace('space_conn')->select(); |
| 117 | + $this->assertSame(1, Utils::getTotalSelectCalls() - $total); |
| 118 | + } |
80 | 119 | }
|
0 commit comments