mirror of
https://github.com/predis/predis.git
synced 2026-09-17 22:07:04 +00:00
Added ACL RESP3 integration tests (#1299)
This commit is contained in:
committed by
GitHub
parent
9b7963be8a
commit
41a79f5b49
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user