Skip to content

Commit

Permalink
chore: prep for flarum/gdpr (#60)
Browse files Browse the repository at this point in the history
* chore: prep for flarum/gdpr

* Apply fixes from StyleCI

* chore: test on php8+

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
imorland and StyleCIBot authored Nov 3, 2024
1 parent c1c1ba8 commit 3fcd7d4
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@1.x
with:
enable_backend_testing: true
enable_phpstan: true
php_versions: '["8.0", "8.1", "8.2", "8.3"]'

backend_directory: .
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
with:
enable_bundlewatch: false
enable_prettier: true
Expand Down
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
78 changes: 78 additions & 0 deletions tests/integration/api/GdprIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/*
* This file is part of fof/user-bio.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

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' => '[email protected]',
'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 3fcd7d4

Please sign in to comment.