Skip to content

Commit

Permalink
test: tune ACCESS_DENIED check for new payload field (#94)
Browse files Browse the repository at this point in the history
We are going to add missing 'user' payload field for ACCESS_DENIED error
in Tarantool 3.1. This breaks current tests. Let's make corresponding
test take into account Tarantool version.

Need for tarantool/tarantool#9108
  • Loading branch information
nshy authored Apr 4, 2024
1 parent b3e9287 commit 1868ebe
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/Integration/BoxErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testExceptionWithErrorIsThrown() : void
try {
/*
* Triggers "AccessDeniedError", which includes the fields
* "object_type", "object_name" and "access_type".
* "object_type", "object_name", "access_type", "user" (since 3.1).
* See https://www.tarantool.io/en/doc/2.4/dev_guide/internals/box_protocol/#binary-protocol-responses-for-errors-extra.
*/
$this->client->evaluate("
Expand All @@ -58,11 +58,16 @@ public function testExceptionWithErrorIsThrown() : void
self::assertSame('AccessDeniedError', $error->getType());
self::assertSame("Write access to space '_priv' is denied for user 'user_with_no_privileges'", $error->getMessage());
self::assertSame(42, $error->getCode());
self::assertEquals([
$expectedFields = [
'object_type' => 'space',
'object_name' => '_priv',
'access_type' => 'Write',
], $error->getFields());
'user' => 'user_with_no_privileges',
];
if ($this->tarantoolVersionSatisfies('<= 3.0')) {
unset($expectedFields['user']);
}
self::assertEquals($expectedFields, $error->getFields());
self::assertNull($error->getPrevious());
}
}
Expand Down

0 comments on commit 1868ebe

Please sign in to comment.