Added ACL RESP3 integration tests (#1299)

This commit is contained in:
Vladyslav Vildanov
2023-05-19 08:47:45 +03:00
committed by GitHub
parent 9b7963be8a
commit 41a79f5b49
2 changed files with 73 additions and 0 deletions
+19
View File
@@ -66,6 +66,25 @@ abstract class PredisCommandTestCase extends PredisTestCase
return $client;
}
/**
* Returns a new RESP3 client instance.
*
* @param bool $flushDb
* @return Client
*/
public function getResp3Client(bool $flushDb = true): Client
{
$commands = $this->getCommandFactory();
if (!$commands->supports($id = $this->getExpectedId())) {
$this->markTestSkipped(
"The current command factory does not support command $id"
);
}
return $this->createClient(['protocol' => 3], null, $flushDb);
}
/**
* Verifies if the command implements the prefixable interface.
*
+54
View File
@@ -86,6 +86,18 @@ class ACL_Test extends PredisCommandTestCase
$this->assertEquals('OK', $redis->acl->setUser('Test'));
}
/**
* @group connected
* @return void
* @requiresRedisVersion >= 6.0.0
*/
public function testSetUserResp3(): void
{
$redis = $this->getResp3Client();
$this->assertEquals('OK', $redis->acl->setUser('Test'));
}
/**
* @group connected
* @return void
@@ -106,6 +118,22 @@ class ACL_Test extends PredisCommandTestCase
);
}
/**
* @group connected
* @return void
* @requiresRedisVersion >= 7.0.0
*/
public function testDryRunResp3(): void
{
$redis = $this->getResp3Client();
$this->assertEquals('OK', $redis->acl->setUser('Test', '+SET', '~*'));
$this->assertEquals(
'OK',
$redis->acl->dryRun('Test', 'SET', 'foo', 'bar')
);
}
/**
* @group connected
* @return void
@@ -132,6 +160,32 @@ class ACL_Test extends PredisCommandTestCase
}
}
/**
* @group connected
* @return void
* @requiresRedisVersion >= 6.0.0
*/
public function testGetUserResp3(): void
{
$redis = $this->getResp3Client();
$this->assertEquals(
'OK',
$redis->acl->setUser(
'alan',
'allkeys',
'+@string',
'+@set',
'-SADD',
'>alanpassword'
)
);
foreach (['flags', 'passwords', 'commands', 'keys', 'channels'] as $key) {
$this->assertArrayHasKey($key, $redis->acl->getUser('alan'));
}
}
/**
* @group connected
* @return void