Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Deleting and updating docs for firestore security rules in local emulator

Using the local emulator, I'm trying to test a rule for my delete & update which looks like this:

match /posts/{postId} {
  allow read: if true;
  allow create: if true;
  allow delete, update: if (resource.data.user.uid == request.auth.uid)
}

In my test file, I write the path of the exact location of the existing doc that I'm trying to perform for example a delete on:

  it("If creator, Allow delete/update items in the post/comment collection", async () => {
    const db = firebase
      .initializeTestApp({ projectId: MY_PROJECT_ID, auth: myAuth })
      .firestore();
    const testDoc = db
      .collection("general")
      .doc("spaces")
      .collection("spaces")
      .doc("9LbUetZxWeL1ln5hv9ug")
      .collection("posts")
      .doc("RtUnezdAgXUfWmRSPpkF");
    await firebase.assertSucceeds(testDoc.delete());
  });

However when I run this test, it gives me this error. However, I know this doc exists and so does the user.uid I am looking to grab in my resource. Is there something wrong in how I'm trying to use this emulator?

I also saw that if I go into my local emulator firestore database, I can hard-code a file, specifically call route my test to it, then it works. enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It looks like no user is signed in when you run the test.

Since your security rules check request.auth.uid, they reject the operation when request.auth is null. Check myAuth.currentUser.uid before running the test to ensure it has a value.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda