true]); }); it('does not store protected secrets as plaintext in cache on put', function () { $key = 'filesystems.disks.s3.secret'; ConfigCacheService::put($key, 'plainsecret'); $raw = Cache::get(ConfigCacheService::CACHE_KEY.$key); expect($raw)->not->toBeNull(); expect($raw)->not->toBe('plainsecret'); // The cached blob must decrypt back to the original secret. expect(decrypt($raw))->toBe('plainsecret'); // Callers still receive the plaintext. expect(ConfigCacheService::get($key))->toBe('plainsecret'); }); it('does not store protected secrets as plaintext in cache on get miss', function () { $key = 'filesystems.disks.s3.key'; ConfigCacheService::put($key, 'plainkey'); // Drop the cache entry to force get() through its miss path. Cache::forget(ConfigCacheService::CACHE_KEY.$key); $returned = ConfigCacheService::get($key); expect($returned)->toBe('plainkey'); $raw = Cache::get(ConfigCacheService::CACHE_KEY.$key); expect($raw)->not->toBeNull(); expect($raw)->not->toBe('plainkey'); expect(decrypt($raw))->toBe('plainkey'); }); it('stores non-protected keys as plaintext and returns them intact', function () { $key = 'app.name'; ConfigCacheService::put($key, 'MyInstance'); $raw = Cache::get(ConfigCacheService::CACHE_KEY.$key); expect($raw)->toBe('MyInstance'); expect(ConfigCacheService::get($key))->toBe('MyInstance'); });