Files
mtusi2026lab7/evidence/lab7/unit-tests.txt
T

25 KiB

$ cd app && npm test && npm run lint && npm run build
 
> app@0.0.1 test
> vitest run --reporter=verbose
 
The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
 
RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab7/app
 
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > accepts png and reports its size 194ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > accepts jpeg and reports its size 9ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > accepts progressive jpeg and reports its size 5ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > rejects truncated files on finish 6ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > rejects a flipped byte inside IDAT by checksum 0ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > rejects a pixel bomb right after IHDR, before any IDAT 28ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > applies the pixel limit to JPEG frame headers 1ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > rejects foreign formats and trailing data after IEND 1ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > accepts padded and noise PNGs of exact sizes 8ms
✓ src/attachments/image/image-inspector.spec.ts > ImageInspector > tolerates trailing data after JPEG EOI 1ms
✓ src/openbao/openbao.client.spec.ts > OpenBaoClient (HTTPS + mTLS auth/cert) > authenticates via auth/cert, renews token, reads KV v2, and surfaces 503 sealed errors 135ms
✓ src/openbao/openbao.client.spec.ts > OpenBaoClient (HTTPS + mTLS auth/cert) > rejects untrusted CA certificates (verify-full) 18ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > accepts valid PNG and JPEG files, also concurrently 58ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > rejects a PNG with a garbage zlib stream 8ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > rejects a JPEG without scan data 6ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > rejects a progressive JPEG without scan data 4ms
{"timestamp":"2026-11-26T16:01:35.851Z","severity":"WARN","service.name":"messenger","service.instance.id":"rep-254061ff41df","event":"security.tls_reload_failed","message":"TLS material reload failed (sighup): Error","reason":"sighup"}
✓ src/security/tls-material.spec.ts > TlsMaterialManager > enforces exact DNS SAN allowlist and rejects wrong or lookalike identities 25ms
{"timestamp":"2026-11-26T16:01:35.875Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-254061ff41df","event":"security.tls_reloaded","message":"TLS material reloaded (sighup)","reason":"sighup","changed":true,"evicted_sockets":0,"server_serial":"1001","client_serial":"1002","crl_revoked_count":0}
{"timestamp":"2026-11-26T16:01:35.937Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-254061ff41df","event":"security.tls_reloaded","message":"TLS material reloaded (sighup)","reason":"sighup","changed":true,"evicted_sockets":0,"server_serial":"1001","client_serial":"1002","crl_revoked_count":1}
✓ src/security/tls-material.spec.ts > TlsMaterialManager > hot-reloads rotated server cert, parses revoked serials from ca.crl, and rejects revoked certs on new & active connections 169ms
✓ src/auth/password-hasher.service.spec.ts > PasswordHasherService > hashes passwords with explicit Argon2id PHC format and unique salts 549ms
✓ src/auth/password-hasher.service.spec.ts > PasswordHasherService > handles unknown users and malformed hashes via dummy verify without throwing 479ms
✓ src/worker/pipelines.spec.ts > renderVariants > renders the v1 contract geometry and formats 168ms
✓ src/worker/pipelines.spec.ts > renderVariants > applies EXIF orientation before fitting 91ms
✓ src/worker/pipelines.spec.ts > renderVariants > composites transparent pixels onto white 59ms
✓ src/worker/pipelines.spec.ts > renderVariants > is deterministic for the same input and version 130ms
✓ src/worker/pipelines.spec.ts > renderVariants > honours an aborted job deadline before starting a render 7ms
✓ src/worker/pipelines.spec.ts > renderVariants > produces a different v2 thumbnail 221ms
✓ src/jobs/broker.client.spec.ts > BrokerClient least-privilege consumer & producer modes > consumer mode uses AMQPS EXTERNAL, ZERO confirmChannel, passive checkQueue, and plain channel for queueDepth 212ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > accepts the heaviest valid input: 40 MP RGBA 16-bit 1903ms
✓ src/jobs/broker.client.spec.ts > BrokerClient least-privilege consumer & producer modes > producer mode uses confirmChannel + passive checkExchange and refuses consume() 50ms
✓ src/attachments/image/image-decoder.spec.ts > ImageDecoder > drops an aborted waiter from the queue without running its decode 102ms
✓ src/auth/password-hasher.service.spec.ts > PasswordHasherService > transparently upgrades weaker Argon2id and legacy $scrypt$ hashes on login 1180ms
[Nest] 237422 - 11/26/2026, 7:01:38 PM WARN [MessagesCacheService] Cache read failed, serving PostgreSQL: redis down
✓ src/worker/worker.module.spec.ts > WorkerModule least-privilege isolation > excludes RedisModule and OutboxRelay and loads without Redis or S3_PUBLIC_ENDPOINT env 1387ms
✓ src/messages/cache/messages-cache.service.spec.ts > MessagesCacheService fallback > loads from the authoritative source when Redis read fails 41ms
✓ src/auth/password-hasher.service.spec.ts > PasswordHasherService > sheds excess concurrent hashing load with HTTP 429 and Retry-After 324ms
[Nest] 237422 - 11/26/2026, 7:01:38 PM WARN [MessagesCacheService] Cache fill failed: redis down
✓ src/messages/cache/messages-cache.service.spec.ts > MessagesCacheService fallback > falls back after bounded lock contention 126ms
✓ src/messages/cache/messages-cache.service.spec.ts > MessagesCacheService fallback > returns the authoritative page when cache write fails 2ms
✓ src/telemetry/tracing.spec.ts > trace context helpers > serialises the active span context as job message fields 12ms
✓ src/telemetry/tracing.spec.ts > trace context helpers > restores the remote parent from job message fields 6ms
✓ src/telemetry/tracing.spec.ts > trace context helpers > reads AMQP headers delivered as buffers 1ms
✓ src/telemetry/tracing.spec.ts > trace context helpers > ignores malformed trace context 1ms
✓ src/telemetry/tracing.spec.ts > trace context helpers > classifies errors without leaking their messages 1ms
✓ src/jobs/fit-inside.spec.ts > fitInside > fits 320x200 into 256 as [256,160] 18ms
✓ src/jobs/fit-inside.spec.ts > fitInside > fits 1000x335 into 256 as [256,85] 1ms
✓ src/jobs/fit-inside.spec.ts > fitInside > fits 100x50 into 256 as [100,50] 0ms
✓ src/jobs/fit-inside.spec.ts > fitInside > fits 10000x1 into 256 as [256,1] 0ms
✓ src/jobs/fit-inside.spec.ts > fitInside > fits 1x10000 into 256 as [1,256] 0ms
✓ src/config/app-config.schema.spec.ts > app-config.schema (Lab 7 security floors) > enforces Argon2id minimum floors (>= 19456 KiB, t >= 2, p >= 1) 41ms
✓ src/config/app-config.schema.spec.ts > app-config.schema (Lab 7 security floors) > strictly forbids BAO_TOKEN and VAULT_TOKEN when BAO_ENABLED=true 4ms
✓ src/config/app-config.schema.spec.ts > app-config.schema (Lab 7 security floors) > accepts zero-secret OpenBao env for API, Worker (no Redis/public S3), and Migrator 12ms
✓ src/config/app-config.schema.spec.ts > app-config.schema (Lab 7 security floors) > refuses plaintext S3 endpoints when TLS_ENABLED=true 8ms
✓ src/telemetry/logger.spec.ts > StructuredLogger trace_sampled > marks a log written inside a sampled trace 34ms
✓ src/telemetry/logger.spec.ts > StructuredLogger trace_sampled > keeps IDs but reports false inside a sampled-out trace 8ms
✓ src/telemetry/logger.spec.ts > StructuredLogger trace_sampled > writes none of the three fields without a valid span context 4ms
✓ src/telemetry/http.spec.ts > routeTemplate > turns Fastify params into low-cardinality templates 7ms
✓ src/telemetry/http.spec.ts > routeTemplate > groups requests that matched no route 1ms
✓ src/telemetry/http.spec.ts > normalizeMethod > keeps standard methods and folds the rest 1ms
✓ src/telemetry/http.spec.ts > isTracedRoute > skips probes, internal endpoints and unmatched requests 1ms
{"timestamp":"2026-01-01T00:00:30.000Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-b29a509c8fbe","event":"job.processed","message":"job succeeded","messenger.job.id":"e1f5ca5c-7f37-4d2b-b7c3-5caa57e6fb97","messenger.attachment.id":"905d96b5-6eb5-495c-bfa7-07049ae7b660","messenger.job.attempt":1,"messenger.job.outcome":"succeeded","duration_ms":18}
{"timestamp":"2026-01-01T00:00:02.000Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-b29a509c8fbe","event":"job.processed","message":"job superseded","messenger.job.id":"745bda7c-9545-4a11-bb74-4ccfd374670a","messenger.attachment.id":"52d9345f-27a6-4563-9a0b-c39fe3c0fc17","messenger.job.attempt":1,"messenger.job.outcome":"superseded","duration_ms":1}
✓ src/worker/job-processor.service.spec.ts > JobProcessor time-to-ready boundary > records time-to-ready at the ready commit, before post-commit work 75ms
✓ src/worker/job-processor.service.spec.ts > JobProcessor time-to-ready boundary > writes no time-to-ready sample for a superseded commit 7ms
✓ src/health/health.service.spec.ts > HealthService > reports liveness and readiness when dependencies are healthy 8ms
✓ src/health/health.service.spec.ts > HealthService > rejects readiness when a dependency is unavailable 10ms
✓ src/health/health.service.spec.ts > HealthService > rejects readiness when Redis alone is unavailable 1ms
✓ src/health/health.service.spec.ts > HealthService > keeps liveness healthy while draining 3ms
✓ src/health/health.service.spec.ts > HealthService > answers not-ready during drain without probing dependencies 2ms
✓ src/health/health.service.spec.ts > HealthService > fails readiness within the budget when a dependency hangs 22ms
{"timestamp":"2026-11-26T16:01:40.127Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_bootstrapped","message":"OpenBao secrets loaded for api","role":"api","kv_version":1,"ttl_seconds":300}
{"timestamp":"2026-11-26T16:01:40.141Z","severity":"WARN","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_unavailable","message":"OpenBao refresh failed; continuing in bounded degraded mode with cached credentials","op":"refresh","status_code":503,"sealed":true,"error_name":"OpenBaoHttpError"}
{"timestamp":"2026-11-26T16:01:40.142Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_recovered","message":"OpenBao connectivity recovered"}
{"timestamp":"2026-11-26T16:01:40.142Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_reauthenticated","message":"OpenBao service re-authenticated","ttl_seconds":300}
{"timestamp":"2026-11-26T16:01:40.154Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.secret_rotated","message":"Secret rotated for scope db","scope":"db","kv_version":2,"reason":"sighup"}
{"timestamp":"2026-11-26T16:01:40.161Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_token_renewed","message":"OpenBao service token renewed","ttl_seconds":300}
{"timestamp":"2026-11-26T16:01:40.165Z","severity":"INFO","service.name":"messenger","service.instance.id":"rep-71e26b45d31f","event":"security.openbao_reauthenticated","message":"OpenBao service re-authenticated","ttl_seconds":300}
✓ src/openbao/runtime-secrets.service.spec.ts > RuntimeSecretsStore > strictly forbids static BAO_TOKEN or VAULT_TOKEN when BAO_ENABLED=true 16ms
✓ src/openbao/runtime-secrets.service.spec.ts > RuntimeSecretsStore > handles secret rotation, 403 re-auth, 503 sealed bounded degradation, and recovery without writing to process.env 51ms
✓ src/openbao/runtime-secrets.service.spec.ts > RuntimeSecretsStore > loads env fallback cleanly when BAO_ENABLED=false 5ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > computes nearest-rank percentiles from observed latencies 6ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > keeps snapshots isolated from callers and later observations 1ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > bounds retained samples but keeps cumulative count and maximum 2ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > ignores invalid latency observations 1ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > adds byte counters and ignores invalid amounts 1ms
✓ src/metrics/metrics.service.spec.ts > MetricsService > tracks memory peaks until reset 18ms
✓ src/messages/idempotency/idempotency.repository.spec.ts > IdempotencyRepository expired-key cleanup > deletes only rows older than the configured TTL 14ms
✓ src/auth/login-rate-limiter.service.spec.ts > LoginRateLimiterService > shares per-username and per-IP counters across API replicas and hashes username keys 21ms
✓ src/auth/login-rate-limiter.service.spec.ts > LoginRateLimiterService > enforces registration per-IP rate limit and fails closed (503) on Redis failure 4ms
✓ src/auth/login-rate-limiter.service.spec.ts > LoginRateLimiterService > extracts LB-set X-Forwarded-For with clean fallback 1ms
✓ src/attachments/upload-slots.spec.ts > UploadSlots > caps one user without starving others, and frees slots after work 12ms
✓ src/attachments/upload-slots.spec.ts > UploadSlots > applies the replica-wide cap across users 1ms
✓ src/attachments/upload-slots.spec.ts > UploadSlots > releases a slot when the work fails 2ms
✓ src/jobs/job-message.spec.ts > parseJobMessage > accepts the contract example 20ms
✓ src/jobs/job-message.spec.ts > parseJobMessage > rejects an extra property 2ms
✓ src/jobs/job-message.spec.ts > parseJobMessage > rejects attempt 0 1ms
✓ src/jobs/job-message.spec.ts > parseJobMessage > rejects a wrong type 1ms
✓ src/jobs/job-message.spec.ts > parseJobMessage > rejects non-JSON 1ms
✓ src/common/validation/code-point-length.spec.ts > CodePointLength > counts Unicode code points instead of UTF-16 units 5ms
✓ src/common/validation/code-point-length.spec.ts > CodePointLength > applies to BMP text boundaries 3ms
✓ src/common/validation/code-point-length.spec.ts > CodePointLength > rejects empty and non-string values 1ms
✓ src/auth/session.repository.spec.ts > SessionRepository & CurrentUserGuard > stores SHA-256 hashed Bearer tokens and never writes raw tokens to Redis 17ms
✓ src/auth/session.repository.spec.ts > SessionRepository & CurrentUserGuard > rejects expired and malformed session records 5ms
✓ src/auth/session.repository.spec.ts > SessionRepository & CurrentUserGuard > enforces Bearer token in CurrentUserGuard and ignores X-User-Id 9ms
✓ src/config/instance-id.spec.ts > instance-id (opaque replica alias) > generates a stable process-singleton opaque alias without exposing os.hostname() 28ms
✓ src/config/instance-id.spec.ts > instance-id (opaque replica alias) > persists the opaque alias to disk for stop-one.sh matching 8ms
✓ src/telemetry/redact.spec.ts > redact > masks bearer and basic credentials 6ms
✓ src/telemetry/redact.spec.ts > redact > masks credentials embedded in connection strings 1ms
✓ src/telemetry/redact.spec.ts > redact > masks presigned URL credentials and signatures 0ms
✓ src/telemetry/redact.spec.ts > redact > masks OpenBao tokens, vault headers, PHC hashes, and secret fields 1ms
✓ src/telemetry/redact.spec.ts > redact > masks password-like fields and private keys 0ms
✓ src/telemetry/redact.spec.ts > redact > keeps ordinary diagnostic text intact 0ms
[Nest] 238681 - 11/26/2026, 7:01:42 PM WARN [ApiExceptionFilter] Dependency outage on POST /api/v1/auth/sessions: password authentication failed for user messenger_api
✓ src/common/errors/api-exception.filter.spec.ts > ApiExceptionFilter (Lab 7 error normalization) > maps Fastify body-too-large errors cleanly to 413 payload_too_large without leaking internals 9ms
✓ src/common/errors/api-exception.filter.spec.ts > ApiExceptionFilter (Lab 7 error normalization) > maps PG 28P01 auth rotation errors to 503 unavailable without leaking secrets 5ms
✓ src/common/errors/api-exception.filter.spec.ts > ApiExceptionFilter (Lab 7 error normalization) > emits 429 rate_limited with integer Retry-After >= 1 2ms
✓ src/messages/messages.repository.spec.ts > MessagesRepository > returns rows in response shape 11ms
✓ src/messages/cache/messages-cache.metrics.spec.ts > MessagesCacheService metrics > records a miss and a hit for a protected page fill 9ms
✓ src/jobs/backoff.spec.ts > retryDelayMs > uses equal jitter 5ms
✓ src/jobs/backoff.spec.ts > retryDelayMs > never exceeds the cap and grows monotonically at random 0.5 2ms
✓ src/jobs/errors.spec.ts > classifyError > classifies unsupported sharp input as permanent invalid_image 10ms
✓ src/jobs/errors.spec.ts > classifyError > classifies the pixel limit as permanent image_too_large 1ms
✓ src/jobs/errors.spec.ts > classifyError > classifies object storage outages as transient 2ms
✓ src/jobs/errors.spec.ts > classifyError > classifies a job timeout as transient processing_timeout 1ms
✓ src/metrics/metrics.controller.spec.ts > MetricsController > verifies Bearer metrics_token from RuntimeSecretsStore in constant time 10ms
✓ src/common/http/cursor.spec.ts > decodeCursor > accepts valid instants and normalizes them to canonical milliseconds 8ms
✓ src/common/http/cursor.spec.ts > decodeCursor > rejects calendar dates that the platform parser rolls over 2ms
✓ src/common/http/cursor.spec.ts > decodeCursor > rejects out-of-range and malformed timestamps 2ms
✓ src/common/http/cursor.spec.ts > decodeCursor > rejects a cursor from another scope, a malformed id, and non-cursor input 1ms
[Nest] 238646 - 11/26/2026, 7:01:45 PM WARN [AttachmentsService] Compensation of attachment e6ea2637-3804-452b-8d26-25395d13ac13 deferred: Connection terminated unexpectedly
✓ src/attachments/attachments.service.spec.ts > AttachmentsService compensation > keeps the object and answers 202 when the job commit reply was lost 30ms
✓ src/attachments/attachments.service.spec.ts > AttachmentsService compensation > deletes nothing while PostgreSQL is unreachable 8ms
✓ src/attachments/attachments.service.spec.ts > AttachmentsService compensation > deletes the object only after claiming the pending row 4ms
✓ src/messages/messages.service.spec.ts > MessagesService idempotency expiry race > does not let a stale expiry decision delete a replacement claim 8ms
 
Test Files 35 passed (35)
Tests 120 passed (120)
Start at 19:01:34
Duration 11.61s (transform 3.88s, setup 0ms, import 41.00s, tests 9.33s, environment 12ms)
 
 
> app@0.0.1 lint
> oxlint src/ test/
 
Found 0 warnings and 0 errors.
Finished in 27ms on 147 files with 96 rules using 8 threads.
 
> app@0.0.1 build
> nest build