mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 14:17:18 +00:00
fix(api): avoid lazy loading nested server secrets
This commit is contained in:
1 parent
13172849e1
commit
99f60228ad
5 files changed
+28
-58
No files matched your search
@@ -11,6 +11,7 @@ use App\Models\Service;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -550,6 +551,23 @@ describe('GET /api/v1/databases sensitive field gating', function () {
|
||||
]);
|
||||
});
|
||||
|
||||
test('read token database list does not lazy load nested server relations', function () {
|
||||
$token = makeApiToken($this->user, $this->team, ['read']);
|
||||
|
||||
$preventedLazyLoading = Model::preventsLazyLoading();
|
||||
Model::preventLazyLoading();
|
||||
|
||||
try {
|
||||
$response = $this->withoutExceptionHandling()->withHeaders([
|
||||
'Authorization' => 'Bearer '.$token,
|
||||
])->getJson('/api/v1/databases');
|
||||
} finally {
|
||||
Model::preventLazyLoading($preventedLazyLoading);
|
||||
}
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
||||
test('read token does not leak postgres_password or db urls', function () {
|
||||
$token = makeApiToken($this->user, $this->team, ['read']);
|
||||
|
||||
|
||||
Reference in new issue
Block a user