-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |