diff --git a/app/Services/Migrators/GoogleAuthMigrator.php b/app/Services/Migrators/GoogleAuthMigrator.php index 2c4d0d7e..fcb15896 100644 --- a/app/Services/Migrators/GoogleAuthMigrator.php +++ b/app/Services/Migrators/GoogleAuthMigrator.php @@ -45,7 +45,7 @@ public function migrate(mixed $migrationPayload) : Collection $parameters['otp_type'] = GAuthValueMapping::OTP_TYPE[OtpType::name($otp_parameters->getType())]; $parameters['service'] = $otp_parameters->getIssuer(); $parameters['account'] = str_replace($parameters['service'] . ':', '', $otp_parameters->getName()); - $parameters['secret'] = Base32::encodeUpper($otp_parameters->getSecret()); + $parameters['secret'] = $this->toBase32($otp_parameters->getSecret()); $parameters['algorithm'] = GAuthValueMapping::ALGORITHM[Algorithm::name($otp_parameters->getAlgorithm())]; $parameters['digits'] = GAuthValueMapping::DIGIT_COUNT[DigitCount::name($otp_parameters->getDigits())]; $parameters['counter'] = $parameters['otp_type'] === TwoFAccount::HOTP ? $otp_parameters->getCounter() : null; @@ -73,4 +73,11 @@ public function migrate(mixed $migrationPayload) : Collection return collect($twofaccounts); } + + /** + * Encode into uppercase Base32 + */ + protected function toBase32(string $str) { + return Base32::encodeUpper($str); + } } diff --git a/app/Services/QrCodeService.php b/app/Services/QrCodeService.php index aa195cbc..9ce5cb72 100644 --- a/app/Services/QrCodeService.php +++ b/app/Services/QrCodeService.php @@ -29,7 +29,7 @@ public static function encode(string $data) Log::info('data encoded to QR code'); - return $qrcode->render($data); + return $qrcode->render('stringToEncode'); } /** diff --git a/phpunit.xml b/phpunit.xml index 8063dae4..a4a687a3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -34,6 +34,7 @@ + diff --git a/tests/Api/v1/Controllers/GroupControllerTest.php b/tests/Api/v1/Controllers/GroupControllerTest.php index aadf3847..ad33aa6f 100644 --- a/tests/Api/v1/Controllers/GroupControllerTest.php +++ b/tests/Api/v1/Controllers/GroupControllerTest.php @@ -473,4 +473,20 @@ public function test_destroy_group_resets_user_preferences() $this->assertEquals(0, $this->user->preferences['defaultGroup']); $this->assertEquals(0, $this->user->preferences['activeGroup']); } + + /** + * @test + */ + public function test_twofaccount_is_released_on_group_destroy() + { + $this->actingAs($this->user, 'api-guard') + ->json('DELETE', '/api/v1/groups/' . $this->userGroupA->id) + ->assertNoContent(); + + $this->twofaccountA->refresh(); + $this->twofaccountB->refresh(); + + $this->assertNull($this->twofaccountA->group_id); + $this->assertNull($this->twofaccountB->group_id); + } } diff --git a/tests/Api/v1/Controllers/QrCodeControllerTest.php b/tests/Api/v1/Controllers/QrCodeControllerTest.php index 3a8d8d08..38f687a4 100644 --- a/tests/Api/v1/Controllers/QrCodeControllerTest.php +++ b/tests/Api/v1/Controllers/QrCodeControllerTest.php @@ -61,7 +61,7 @@ public function test_show_qrcode_returns_base64_image() ]) ->assertOk(); - $this->assertStringStartsWith('data:image/png;base64', $response->getData()->qrcode); + $this->assertStringStartsWith('data:image/svg+xml;base64', $response->getData()->qrcode); } /** diff --git a/tests/Feature/Services/QrCodeServiceTest.php b/tests/Feature/Services/QrCodeServiceTest.php index 80a8061d..d75a2376 100644 --- a/tests/Feature/Services/QrCodeServiceTest.php +++ b/tests/Feature/Services/QrCodeServiceTest.php @@ -17,7 +17,7 @@ class QrCodeServiceTest extends FeatureTestCase { private const STRING_TO_ENCODE = 'stringToEncode'; - private const STRING_ENCODED = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAABnRSTlMA/wD/AP83WBt9AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADOklEQVR4nO3dMW7kMBAAwdPh/v/ldeBLFRCYBkm7KveaEBoMBhT1fD6fPzDt7+4F8DMJi4SwSAiLhLBICIuEsEgIi4SwSAiLhLBICIuEsEgIi4SwSPxb/YPneYp1jHs7Z7a6/tXzam+/P7WeXVafgx2LhLBICIuEsEgIi4SwSAiLxPIc682u9xOn5lKnzZNueZ5v7FgkhEVCWCSERUJYJIRFQlgkxuZYb6bmIlNznanzUrfPmer127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GgtMVoiLz4NCjxwYXRoIGNsYXNzPSJxci1maW5kZXItZG90IGRhcmsgcXJjb2RlIiBmaWxsPSIjMDAwIiBkPSJNNCA0IGgxIHYxIGgtMVogTTUgNCBoMSB2MSBoLTFaIE02IDQgaDEgdjEgaC0xWiBNMTggNCBoMSB2MSBoLTFaIE0xOSA0IGgxIHYxIGgtMVogTTIwIDQgaDEgdjEgaC0xWiBNNCA1IGgxIHYxIGgtMVogTTUgNSBoMSB2MSBoLTFaIE02IDUgaDEgdjEgaC0xWiBNMTggNSBoMSB2MSBoLTFaIE0xOSA1IGgxIHYxIGgtMVogTTIwIDUgaDEgdjEgaC0xWiBNNCA2IGgxIHYxIGgtMVogTTUgNiBoMSB2MSBoLTFaIE02IDYgaDEgdjEgaC0xWiBNMTggNiBoMSB2MSBoLTFaIE0xOSA2IGgxIHYxIGgtMVogTTIwIDYgaDEgdjEgaC0xWiBNNCAxOCBoMSB2MSBoLTFaIE01IDE4IGgxIHYxIGgtMVogTTYgMTggaDEgdjEgaC0xWiBNNCAxOSBoMSB2MSBoLTFaIE01IDE5IGgxIHYxIGgtMVogTTYgMTkgaDEgdjEgaC0xWiBNNCAyMCBoMSB2MSBoLTFaIE01IDIwIGgxIHYxIGgtMVogTTYgMjAgaDEgdjEgaC0xWiIvPg0KPC9zdmc+DQo='; private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW'; diff --git a/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php b/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php index 447d1b69..55e96ff5 100644 --- a/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php +++ b/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php @@ -4,14 +4,8 @@ use App\Events\GroupDeleting; use App\Listeners\DissociateTwofaccountFromGroup; -use App\Models\Group; -use App\Models\TwoFAccount; use Illuminate\Support\Facades\Event; -use Mockery\MockInterface; use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\PreserveGlobalState; -use PHPUnit\Framework\Attributes\RequiresPhp; -use PHPUnit\Framework\Attributes\RunInSeparateProcess; use Tests\TestCase; /** @@ -20,27 +14,6 @@ #[CoversClass(DissociateTwofaccountFromGroup::class)] class DissociateTwofaccountFromGroupTest extends TestCase { - /** - * @test - */ - #[RunInSeparateProcess] - #[PreserveGlobalState(false)] - #[RequiresPhp('< 8.3.0')] - public function test_twofaccount_is_released_on_group_deletion() - { - $this->mock('alias:' . TwoFAccount::class, function (MockInterface $twoFAccount) { - $twoFAccount->shouldReceive('where->update') - ->once() - ->andReturn(1); - }); - - $group = Group::factory()->make(); - $event = new GroupDeleting($group); - $listener = new DissociateTwofaccountFromGroup(); - - $this->assertNull($listener->handle($event)); - } - /** * @test */ diff --git a/tests/Unit/MigratorTest.php b/tests/Unit/MigratorTest.php index 4a8459d7..0fc7bae4 100644 --- a/tests/Unit/MigratorTest.php +++ b/tests/Unit/MigratorTest.php @@ -18,12 +18,8 @@ use Illuminate\Support\Facades\Storage; use Mockery; use Mockery\MockInterface; -use ParagonIE\ConstantTime\Base32; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\PreserveGlobalState; -use PHPUnit\Framework\Attributes\RequiresPhp; -use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\Attributes\UsesClass; use Tests\Data\MigrationTestData; use Tests\Data\OtpTestData; @@ -142,6 +138,20 @@ public function setUp() : void $this->fakeTwofaccount->id = TwoFAccount::FAKE_ID; } + /** + * Clean up the testing environment before the next test. + * + * @return void + * + * @throws \Mockery\Exception\InvalidCountException + */ + protected function tearDown() : void + { + $this->forgetMock(SettingService::class); + + parent::tearDown(); + } + /** * @test */ @@ -332,17 +342,14 @@ public static function migrationWithInvalidAccountsProvider() /** * @test */ - #[RunInSeparateProcess] - #[PreserveGlobalState(false)] - #[RequiresPhp('< 8.3.0')] public function test_migrate_gauth_returns_fake_accounts() { - $this->mock('alias:' . Base32::class, function (MockInterface $baseEncoder) { - $baseEncoder->shouldReceive('encodeUpper') + $migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) { + $migrator->shouldAllowMockingProtectedMethods()->shouldReceive('toBase32') ->andThrow(new \Exception()); }); - $migrator = new GoogleAuthMigrator(); + /** @disregard Undefined function */ $accounts = $migrator->migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI); $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts); @@ -352,6 +359,8 @@ public function test_migrate_gauth_returns_fake_accounts() // in the migration payload) so we do not use get() to retrieve items $this->assertEquals($this->fakeTwofaccount->id, $accounts->first()->id); $this->assertEquals($this->fakeTwofaccount->id, $accounts->last()->id); + + $this->forgetMock(GoogleAuthMigrator::class); } /** @@ -548,9 +557,4 @@ public static function encryptedMigrationDataProvider() ], ]; } - - protected function tearDown() : void - { - Mockery::close(); - } } diff --git a/tests/Unit/TwoFAccountModelTest.php b/tests/Unit/TwoFAccountModelTest.php index 50c0798c..c3501b61 100644 --- a/tests/Unit/TwoFAccountModelTest.php +++ b/tests/Unit/TwoFAccountModelTest.php @@ -11,9 +11,6 @@ use Mockery\MockInterface; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\PreserveGlobalState; -use PHPUnit\Framework\Attributes\RequiresPhp; -use PHPUnit\Framework\Attributes\RunInSeparateProcess; use Tests\ModelTestCase; /** @@ -63,6 +60,7 @@ public function test_sensitive_attributes_are_stored_encrypted(string $attribute ]); $this->assertEquals('STRING==', Crypt::decryptString($twofaccount->getAttributes()[$attribute])); + $this->forgetMock(SettingService::class); } /** @@ -98,6 +96,7 @@ public function test_sensitive_attributes_are_returned_clear(string $attribute) $twofaccount = TwoFAccount::factory()->make(); $this->assertEquals($twofaccount->getAttributes()[$attribute], $twofaccount->$attribute); + $this->forgetMock(SettingService::class); } /** @@ -118,14 +117,12 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr $twofaccount = TwoFAccount::factory()->make(); $this->assertEquals(__('errors.indecipherable'), $twofaccount->$attribute); + $this->forgetMock(SettingService::class); } /** * @test */ - #[RunInSeparateProcess] - #[PreserveGlobalState(false)] - #[RequiresPhp('< 8.3.0')] public function test_secret_is_uppercased_and_padded_at_setup() { $settingService = $this->mock(SettingService::class, function (MockInterface $settingService) { @@ -134,7 +131,7 @@ public function test_secret_is_uppercased_and_padded_at_setup() ->andReturn(false); }); - $helpers = $this->mock('alias:' . Helpers::class, function (MockInterface $helpers) { + $helpers = $this->mock(Helpers::class, function (MockInterface $helpers) { $helpers->shouldReceive('PadToBase32Format') ->andReturn('YYYY===='); }); @@ -144,6 +141,7 @@ public function test_secret_is_uppercased_and_padded_at_setup() ]); $this->assertEquals('YYYY====', $twofaccount->secret); + $this->forgetMock(SettingService::class); } /**