Skip to content

Commit

Permalink
chore: prep for flarum/gdpr
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Nov 3, 2024
1 parent c1c1ba8 commit 523d69a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"color": "#fff"
},
"optional-dependencies": [
"flarum/suspend"
"flarum/suspend",
"flarum/gdpr"
]
},
"flagrow": {
Expand All @@ -67,7 +68,8 @@
"flarum/bbcode": "*",
"flarum/testing": "^1.0.0",
"flarum/phpstan": "*",
"flarum/suspend": "*"
"flarum/suspend": "*",
"flarum/gdpr": "dev-main"
},
"autoload-dev": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/BioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace FoF\UserBio\tests\integration\api;
namespace FoF\UserBio\Tests\integration\api;

use Carbon\Carbon;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
Expand Down
69 changes: 69 additions & 0 deletions tests/integration/api/GdprIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace FoF\UserBio\Tests\integration\api;

use Carbon\Carbon;
use Flarum\Gdpr\Models\ErasureRequest;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;

class GdprIntegrationTest extends TestCase
{
use RetrievesAuthorizedUsers;

public function setUp(): void
{
parent::setUp();

$this->extension('flarum-gdpr');
$this->extension('fof-user-bio');

$this->prepareDatabase([
'users' => [
$this->normalUser(),
[
'id' => 3,
'username' => 'normal2',
'password' => '$2y$10$LO59tiT7uggl6Oe23o/O6.utnF6ipngYjvMvaxo1TciKqBttDNKim', // BCrypt hash for "too-obscure"
'email' => 'normal2@machine.local',
'is_email_confirmed' => 1,
'last_seen_at' => Carbon::now()->subSecond(),
'bio' => 'This is a test bio for normal2.',
],
],
'gdpr_erasure' => [
['id' => 1, 'user_id' => 3, 'verification_token' => '123abc', 'status' => 'user_confirmed', 'reason' => 'I also want to be forgotten', 'created_at' => Carbon::now(), 'user_confirmed_at' => Carbon::now()],
],
]);
}

/**
* @test
*/
public function user_bio_is_anonimized()
{
$response = $this->send(
$this->request('PATCH', '/api/user-erasure-requests/1', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'processor_comment' => 'I have processed this request',
'meta' => [
'mode' => ErasureRequest::MODE_ANONYMIZATION,
],
],
],
],
])
);

$this->assertEquals(200, $response->getStatusCode());

$user = User::find(3);
$this->assertNotNull($user);
$this->assertEquals('Anonymous1', $user->username);
$this->assertNull($user->bio);
}
}

0 comments on commit 523d69a

Please sign in to comment.