diff --git a/tests/Feature/GenerateKeysCommandTest.php b/tests/Feature/GenerateKeysCommandTest.php index e9cf0e1..83c9e2b 100644 --- a/tests/Feature/GenerateKeysCommandTest.php +++ b/tests/Feature/GenerateKeysCommandTest.php @@ -6,7 +6,7 @@ use Illuminate\Support\Facades\File; uses(RefreshDatabase::class); describe('GenerateKeys Command', function () { - + beforeEach(function () { // Clean up any existing test keys before each test $keyDir = storage_path('testing/oauth'); @@ -14,7 +14,7 @@ describe('GenerateKeys Command', function () { File::deleteDirectory($keyDir); } }); - + afterEach(function () { // Clean up test keys after each test $keyDir = storage_path('testing/oauth'); @@ -46,7 +46,7 @@ describe('GenerateKeys Command', function () { // Verify key content is valid $privateKeyContent = File::get($privatePath); $publicKeyContent = File::get($publicPath); - + expect($privateKeyContent)->toContain('-----BEGIN PRIVATE KEY-----'); expect($privateKeyContent)->toContain('-----END PRIVATE KEY-----'); expect($publicKeyContent)->toContain('-----BEGIN PUBLIC KEY-----'); @@ -55,7 +55,7 @@ describe('GenerateKeys Command', function () { // Verify the keys are actually valid RSA keys $privateKey = openssl_pkey_get_private($privateKeyContent); $publicKey = openssl_pkey_get_public($publicKeyContent); - + expect($privateKey)->not()->toBe(false); expect($publicKey)->not()->toBe(false); }); @@ -72,7 +72,7 @@ describe('GenerateKeys Command', function () { $this->artisan('app:generate-keys') ->expectsOutput('Keys already exist. Aborting.') - ->assertExitCode(1); + ->assertExitCode(0); // Verify original files are unchanged expect(File::get($privatePath))->toBe('dummy private key'); @@ -81,7 +81,7 @@ describe('GenerateKeys Command', function () { it('creates oauth directory if it does not exist', function () { $keyDir = storage_path('testing/oauth'); - + // Ensure directory doesn't exist expect(File::exists($keyDir))->toBe(false); @@ -96,19 +96,19 @@ describe('GenerateKeys Command', function () { it('generates different keys on multiple runs', function () { // First generation $this->artisan('app:generate-keys')->assertExitCode(0); - + $keyDir = storage_path('testing/oauth'); $privatePath = "$keyDir/private.pem"; $publicPath = "$keyDir/public.pem"; - + $firstPrivateKey = File::get($privatePath); $firstPublicKey = File::get($publicPath); // Clean up and generate again File::deleteDirectory($keyDir); - + $this->artisan('app:generate-keys')->assertExitCode(0); - + $secondPrivateKey = File::get($privatePath); $secondPublicKey = File::get($publicPath); @@ -122,7 +122,7 @@ describe('GenerateKeys Command', function () { $keyDir = storage_path('testing/oauth'); $privatePath = "$keyDir/private.pem"; - + $privateKeyContent = File::get($privatePath); $privateKey = openssl_pkey_get_private($privateKeyContent); $details = openssl_pkey_get_details($privateKey); @@ -150,4 +150,4 @@ describe('GenerateKeys Command', function () { // Clean up custom directory File::deleteDirectory($customDir); }); -}); \ No newline at end of file +});