diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 52eebab..75a999b 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -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: . diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 5bc60f5..a97edeb 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -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 diff --git a/composer.json b/composer.json index a0d0822..8f6c600 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,8 @@ "color": "#fff" }, "optional-dependencies": [ - "flarum/suspend" + "flarum/suspend", + "flarum/gdpr" ] }, "flagrow": { @@ -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": { diff --git a/tests/integration/api/BioTest.php b/tests/integration/api/BioTest.php index c5386cf..f8853b3 100644 --- a/tests/integration/api/BioTest.php +++ b/tests/integration/api/BioTest.php @@ -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; diff --git a/tests/integration/api/GdprIntegrationTest.php b/tests/integration/api/GdprIntegrationTest.php new file mode 100644 index 0000000..2860bc9 --- /dev/null +++ b/tests/integration/api/GdprIntegrationTest.php @@ -0,0 +1,78 @@ +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); + } +}