Skip to content

Fix SecretAttachment Model tests (encryption pattern violations) #179

@kevalyq

Description

@kevalyq

Problem

5 Model unit tests in tests/Feature/Models/SecretAttachmentTest.php failing due to improper encryption pattern in test setup.

Root Cause

Secret::create() and SecretAttachment::create() do NOT follow explicit property assignment pattern required for EncryptedWithDek cast.

Required: $model = new Model(); $model->tenant_id = $tenantId; $model->encrypted_field = $value; $model->save();

Current (broken): Model::create(['tenant_id' => ..., 'encrypted_field' => ...]);

Failing Tests

  1. secret attachment uses UUID primary key
  2. secret attachment encrypts filename with EncryptedWithDek cast
  3. secret attachment belongs to secret
  4. secret attachment belongs to user (uploaded_by)
  5. secret attachment has download_url accessor

Solution

Replace all ::create() calls with explicit property assignment pattern.

Impact

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions