Release / release-apk (push) Successful in 8m58s
Release / release-docker (push) Successful in 3m47s
CI / docker (push) Successful in 7s
CI / lint-backend (push) Successful in 1m44s
CI / lint-mobile (push) Failing after 18m59s
CI / test-backend (push) Successful in 2m12s
CI / test-mobile (push) Successful in 8m50s
CI / build-backend (push) Successful in 45s
Backend : resource_previews (000024), GET /files/:id/preview (JPEG
512, images pur Go, PDF page 1 via pdftoppm + poppler au Dockerfile,
cache régénéré sur changement, 404 NO_PREVIEW sinon), POST /export
{password 8+} -> zip AES-256 streamé (fichiers vifs possédés +
manifest.json avec faits, metadata-only sans octets). Deps :
alexmullins/zip, x/image directs. Tests service + handlers + migrations.
Mobile : vignettes distantes (une requête/session puis cache WebP
versionné, garde tried, icône sinon), FileThumbnail cloud-only,
export (mot de passe jamais persisté, cache + partage FileProvider),
bouton Partager ACTION_SEND. Impression papier reportée V4. FR/EN.
Contrat docs/api-v1.md, V3.md (S7 livré, V3 close), AGENTS.md,
VERSION 1.2.0 + CHANGELOG.
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package handlers_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/kazier/backend/repository"
|
|
)
|
|
|
|
// TestExportEndpoint : POST /export exige un mot de passe 8+ (400 sinon) et
|
|
// streame un zip (200 + application/zip).
|
|
func TestExportEndpoint(t *testing.T) {
|
|
r, _, repo := setup(t)
|
|
device := repository.NewID()
|
|
token, _ := registerAndLogin(t, r, repo, testUserUsername(device, "ex"), "export-test-password", device)
|
|
|
|
for _, body := range []string{`{}`, `{"password":"court"}`, `not-json`} {
|
|
rec, _ := doRequest(t, r, http.MethodPost, "/api/v1/export", token, []byte(body), "application/json")
|
|
expectError(t, rec, http.StatusBadRequest, "INVALID_REQUEST", "export-400:"+body)
|
|
}
|
|
|
|
rec, _ := doRequest(t, r, http.MethodPost, "/api/v1/export", token, []byte(`{"password":"motdepasse-8"}`), "application/json")
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("export: attendu 200, got %d %s", rec.Code, rec.Body.String())
|
|
}
|
|
if ct := rec.Header().Get("Content-Type"); ct != "application/zip" {
|
|
t.Fatalf("content-type = %q", ct)
|
|
}
|
|
if cd := rec.Header().Get("Content-Disposition"); cd == "" {
|
|
t.Fatal("content-disposition manquant")
|
|
}
|
|
if rec.Body.Len() == 0 {
|
|
t.Fatal("zip vide")
|
|
}
|
|
if rec.Body.Bytes()[0] != 'P' || rec.Body.Bytes()[1] != 'K' {
|
|
t.Fatal("pas une archive zip (signature PK manquante)")
|
|
}
|
|
}
|