Software Testing Engineering / API & CONTRACT TESTING / TST-023
Adversarial API Inputs
Explore concept graphLatihan soal
Real HTTP adversarial lab
Dari root repository dengan Node 24:
node generation/fixtures/TST-023/adversarial-api.mjsExpected stdout:
invalid-requests=21
stable-problem-details=verified
same-key-replay=201
different-payload-conflict=409
created-transfers=1
idempotency-records=1
unauthorized-mutations=0
runtime=local-node-http-onlyFixture menjalankan 13 kasus query GET invalid, 8 kasus POST invalid, first successful transfer, idempotent replay, key conflict dan inspeksi data GET. Tidak ada permintaan ke bank atau layanan produksi. Semua rejected request memiliki Problem Details yang diperiksa dan tidak membuat transfer.
Konsep 1 / 3
Reject negative pagination, huge limits, repeated keys and unsupported sort/filter before reading data.
Coba prediksi atau perbaiki
Can limit=9999999 be silently clamped under this lab contract?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Using parseInt on untrusted pagination strings.
Mengapa tidak bekerja: Trailing junk or unsafe numbers can be silently truncated.
Coba perbaiki: Validate the entire string, Number.isSafeInteger and range.
Periksa hasil sendiri
Hasil yang diharapkan: Every invalid query is HTTP 400 and no storage mutation occurs.
Kalau berbeda: Inspect duplicate getAll values and full-number regex.
Konsep 2 / 3
Reject oversized, malformed or forbidden JSON and wrong content types before any write.
Coba prediksi atau perbaiki
Can a handler write all JSON fields and remove bad keys afterward?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Persisting raw request JSON directly.
Mengapa tidak bekerja: Mass-assigned properties can contaminate state.
Coba perbaiki: Validate and project a safe DTO before any write.
Periksa hasil sendiri
Hasil yang diharapkan: 400/413/415 responses have stable Problem Details and zero inserts.
Kalau berbeda: Inspect when storage push and idempotency record insertion occur.
Konsep 3 / 3
Prove same-key exact replay preserves one record and same-key changed payload conflicts.
Coba prediksi atau perbaiki
Should changing amount under the same key return another 201?
Kalau jawabanmu berbeda
Kesalahan yang mungkin: Creating another record for every POST despite a repeated key.
Mengapa tidak bekerja: Lost network responses may trigger duplicate mutations.
Coba perbaiki: Store key and validated body fingerprint before allowing replay.
Periksa hasil sendiri
Hasil yang diharapkan: First 201 creates one record, repeated 201 creates none, changed body gets 409.
Kalau berbeda: Check fingerprint comparison before the write branch.
Lima soal input adversarial
Jawab tanpa melihat pembahasan dulu. Kamu bisa memperbaiki jawaban dan mencoba lagi. Kuis ini latihan mandiri dan tidak menyimpan skor atau progres.