diff --git a/composer.lock b/composer.lock index 0840539..e6a4277 100644 --- a/composer.lock +++ b/composer.lock @@ -1643,16 +1643,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { @@ -1697,7 +1697,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { @@ -1705,7 +1705,7 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", @@ -2367,5 +2367,5 @@ "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Audit/Audit.php b/src/Audit/Audit.php index f7e5b1e..e4ed9db 100644 --- a/src/Audit/Audit.php +++ b/src/Audit/Audit.php @@ -38,15 +38,6 @@ public function setup(): void } $attributes = [ - new Document([ - '$id' => 'userInternalId', - 'type' => Database::VAR_STRING, - 'size' => Database::LENGTH_KEY, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [], - ]), new Document([ '$id' => 'userId', 'type' => Database::VAR_STRING, @@ -159,7 +150,6 @@ public function setup(): void /** * Add event log. * - * @param string $userInternalId * @param string $userId * @param string $event * @param string $resource @@ -174,12 +164,11 @@ public function setup(): void * @throws \Exception * @throws \Throwable */ - public function log(string $userInternalId, string $userId, string $event, string $resource, string $userAgent, string $ip, string $location, array $data = []): bool + public function log(string $userId, string $event, string $resource, string $userAgent, string $ip, string $location, array $data = []): bool { - Authorization::skip(function () use ($userId, $userInternalId, $event, $resource, $userAgent, $ip, $location, $data) { + Authorization::skip(function () use ($userId, $event, $resource, $userAgent, $ip, $location, $data) { $this->db->createDocument(Audit::COLLECTION, new Document([ '$permissions' => [], - 'userInternalId' => $userInternalId, 'userId' => $userId, 'event' => $event, 'resource' => $resource, diff --git a/tests/Audit/AuditTest.php b/tests/Audit/AuditTest.php index 535cad5..eb1b570 100644 --- a/tests/Audit/AuditTest.php +++ b/tests/Audit/AuditTest.php @@ -44,16 +44,15 @@ public function tearDown(): void public function createLogs(): void { - $userInternalIdId = '1'; $userId = 'userId'; $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'; $ip = '127.0.0.1'; $location = 'US'; $data = ['key1' => 'value1', 'key2' => 'value2']; - $this->assertTrue($this->audit->log($userInternalIdId, $userId, 'update', 'database/document/1', $userAgent, $ip, $location, $data)); - $this->assertTrue($this->audit->log($userInternalIdId, $userId, 'update', 'database/document/2', $userAgent, $ip, $location, $data)); - $this->assertTrue($this->audit->log($userInternalIdId, $userId, 'delete', 'database/document/2', $userAgent, $ip, $location, $data)); + $this->assertTrue($this->audit->log($userId, 'update', 'database/document/1', $userAgent, $ip, $location, $data)); + $this->assertTrue($this->audit->log($userId, 'update', 'database/document/2', $userAgent, $ip, $location, $data)); + $this->assertTrue($this->audit->log($userId, 'delete', 'database/document/2', $userAgent, $ip, $location, $data)); } public function testGetLogsByUser(): void @@ -158,18 +157,17 @@ public function testCleanup(): void $this->assertEquals(0, \count($logs)); // Add three sample logs - $userInternalIdId = '1'; $userId = 'userId'; $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'; $ip = '127.0.0.1'; $location = 'US'; $data = ['key1' => 'value1', 'key2' => 'value2']; - $this->assertEquals($this->audit->log($userInternalIdId, $userId, 'update', 'database/document/1', $userAgent, $ip, $location, $data), true); + $this->assertEquals($this->audit->log($userId, 'update', 'database/document/1', $userAgent, $ip, $location, $data), true); sleep(5); - $this->assertEquals($this->audit->log($userInternalIdId, $userId, 'update', 'database/document/2', $userAgent, $ip, $location, $data), true); + $this->assertEquals($this->audit->log($userId, 'update', 'database/document/2', $userAgent, $ip, $location, $data), true); sleep(5); - $this->assertEquals($this->audit->log($userInternalIdId, $userId, 'delete', 'database/document/2', $userAgent, $ip, $location, $data), true); + $this->assertEquals($this->audit->log($userId, 'delete', 'database/document/2', $userAgent, $ip, $location, $data), true); sleep(5); // DELETE logs older than 11 seconds and check that status is true