0Pricing
Firebase Auth & Realtime Database Apps · Ders

Güvenlik Kurallarını Test Etme ve Hata Ayıklama

İstekleri simüle ederek, Rules Playground'u kullanarak, öykünücüyle otomatik testler yazarak ve reddetme iletilerini okuyarak Realtime Database kurallarınıza güven kazanın.

Güvenlik Kurallarını Test Etme ve Hata Ayıklama, CoddyKit'te ücretsiz bir Firebase Auth & Realtime Database Apps dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Firebase Auth & Realtime Database Apps öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Firebase Auth & Realtime Database Apps kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Why Test Your Rules

Security Rules are the only thing standing between your data and the open internet. A single mistake can expose private data or block legitimate users.

Testing rules is as important as testing code, and Firebase gives you several tools to do it.

The Rules Playground

The Firebase console includes a Rules Playground where you simulate a single read or write without touching real data.

  • Pick read or write
  • Set a path and auth state
  • See instantly whether it is allowed or denied

Simulating Auth State

In the simulator you can run as an unauthenticated user or supply a fake auth.uid and custom claims. This is how you verify that user-based access control behaves correctly.

Reading a Denial

When a request is denied, the simulator highlights the exact rule that evaluated to false. Use this to pinpoint why a legitimate request is being blocked.

The Local Emulator

For repeatable, automated testing, use the Firebase Local Emulator Suite. It runs the Realtime Database and its rules entirely on your machine, with no cloud costs.

firebase emulators:start --only database

Writing a Rules Test

The @firebase/rules-unit-testing library lets you assert that operations succeed or fail. This is the gold standard for rule confidence.

import { assertSucceeds, assertFails } from '@firebase/rules-unit-testing';

await assertSucceeds(authedDb.ref('users/alice').set({ name: 'Alice' }));
await assertFails(authedDb.ref('users/bob').set({ name: 'hax' }));

Test Both Directions

Good rule tests check both outcomes:

  • Authorized users can do allowed actions (no false denials)
  • Unauthorized users cannot do forbidden actions (no security holes)

Testing only the happy path hides the dangerous gaps.

Testing Validation Rules

Beyond access, test your .validate rules: confirm that malformed data is rejected and well-formed data is accepted.

await assertFails(db.ref('age').set('not-a-number'));
await assertSucceeds(db.ref('age').set(30));

Common Rule Bugs

Watch for these frequent mistakes:

  • Rules cascade: a true .read higher up overrides children
  • Forgetting that read and write rules are independent
  • Assuming auth is non-null without checking

Debugging with newData

Inside write rules, newData represents what the write would produce and data is the current value. Logging your reasoning about these in test cases clears up many confusing denials.

{
  "posts": {
    "$id": {
      ".write": "!data.exists() || data.child('owner').val() === auth.uid"
    }
  }
}

CI Integration

Run your emulator-based rule tests in continuous integration so a risky rule change is caught before it reaches production. This turns security into a regression-tested guarantee.

Quick Check

Test your understanding of rules testing.

Recap

You can now validate rules with confidence.

  • Use the Rules Playground for quick manual checks
  • Use the Local Emulator for repeatable runs
  • Write tests with assertSucceeds / assertFails
  • Cover both access and validation, both directions
  • Run rule tests in CI

Sıkça Sorulan Sorular

“Güvenlik Kurallarını Test Etme ve Hata Ayıklama” dersi ücretsiz mi?

Evet — “Güvenlik Kurallarını Test Etme ve Hata Ayıklama” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Firebase Auth & Realtime Database Apps kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Firebase Auth & Realtime Database Apps kursu toplamda 4 dersten oluşur.

“Güvenlik Kurallarını Test Etme ve Hata Ayıklama” dersinde ne öğreneceğim?

İstekleri simüle ederek, Rules Playground'u kullanarak, öykünücüyle otomatik testler yazarak ve reddetme iletilerini okuyarak Realtime Database kurallarınıza güven kazanın. Firebase Auth & Realtime Database Apps ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Firebase Auth & Realtime Database Apps öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Firebase Auth & Realtime Database Apps, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Güvenlik Kurallarını Test Etme ve Hata Ayıklama” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Firebase Auth & Realtime Database Apps dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Firebase Auth & Realtime Database Apps dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Güvenlik Kuralları Söz Dizimini Anlama
  2. Kullanıcı Tabanlı Erişim Denetimi
  3. Kurallarla Verileri Doğrulama
  4. Güvenlik Kurallarını Test Etme ve Hata Ayıklama
← Firebase Auth & Realtime Database Apps Sayfasına Dön