Skip to content

Commit

Permalink
Merge pull request #36 from privacy-scaling-explorations/feat/public_…
Browse files Browse the repository at this point in the history
…data

Feat/public data
  • Loading branch information
ctrlc03 authored May 15, 2023
2 parents 5a45a68 + 5110c11 commit 846053f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 35 deletions.
3 changes: 2 additions & 1 deletion packages/actions/src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const commonTerms = {
verifyContribution: "verifycontribution",
checkAndPrepareCoordinatorForFinalization: "checkAndPrepareCoordinatorForFinalization",
finalizeCircuit: "finalizeCircuit",
finalizeCeremony: "finalizeCeremony"
finalizeCeremony: "finalizeCeremony",
downloadCircuitArtifacts: "downloadCircuitArtifacts"
}
}
2 changes: 1 addition & 1 deletion packages/actions/src/helpers/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@ export const finalizeCeremony = async (functions: Functions, ceremonyId: string)
await cf({
ceremonyId
})
}
}
2 changes: 1 addition & 1 deletion packages/actions/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,4 +533,4 @@ export type CeremonyArtifacts = {
export type ContributionDocumentReferenceAndData = {
uid: string
data: ContributionDocument
}
}
14 changes: 2 additions & 12 deletions packages/actions/test/unit/contribute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ describe("Contribute", () => {
})
/// @note running on emulator gives a different error
if (envType === TestingEnvironment.PRODUCTION) {
it("should fail when not authenticated", async () => {
it("should succeed when not authenticated", async () => {
await signOut(userAuth)
await expect(getOpenedCeremonies(userFirestore)).to.be.rejectedWith(
"Missing or insufficient permissions."
)
await expect(getOpenedCeremonies(userFirestore)).to.be.fulfilled
})
}
it("should allow to retrieve all opened ceremonies", async () => {
Expand Down Expand Up @@ -133,14 +131,6 @@ describe("Contribute", () => {
fakeCircuitsData.fakeCircuitSmallNoContributors
)
})
if (envType === TestingEnvironment.PRODUCTION) {
it("should fail when not authenticated", async () => {
await signOut(userAuth)
await expect(
getCeremonyCircuits(userFirestore, fakeCeremoniesData.fakeCeremonyOpenedFixed.uid)
).to.be.rejectedWith("Missing or insufficient permissions.")
})
}
it("should return the circuits for the specified ceremony", async () => {
// auth
await signInWithEmailAndPassword(userAuth, users[0].data.email, passwords[0])
Expand Down
14 changes: 1 addition & 13 deletions packages/actions/test/unit/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ describe("Database", () => {
])
expect(query.docs.length).to.be.gt(0)
})
it("should revert when not logged in", async () => {
await signOut(userAuth)
await expect(
queryCollection(userFirestore, commonTerms.collections.ceremonies.name, [
where(commonTerms.collections.ceremonies.fields.state, "==", CeremonyState.OPENED)
])
).to.be.rejected
})
})

describe("getAllCollectionDocs", () => {
Expand All @@ -120,10 +112,6 @@ describe("Database", () => {
const collection = await getAllCollectionDocs(userFirestore, commonTerms.collections.ceremonies.name)
expect(collection.length).to.be.gt(0)
})
it("should revert when not logged in", async () => {
await signOut(userAuth)
await expect(getAllCollectionDocs(userFirestore, commonTerms.collections.ceremonies.name)).to.be.rejected
})
})

describe("fromQueryToFirebaseDocumentInfo", () => {
Expand Down Expand Up @@ -152,7 +140,7 @@ describe("Database", () => {
await expect(getDocumentById(userFirestore, commonTerms.collections.users.name, users[0].uid)).to.be
.rejected
})
it("should an authenticated user to get a ceremonies document", async () => {
it("should an authenticated user to get a ceremony document", async () => {
await signInWithEmailAndPassword(userAuth, users[0].data.email, passwords[0])
const userDoc = await getDocumentById(
userFirestore,
Expand Down
6 changes: 3 additions & 3 deletions packages/actions/test/unit/security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ describe("Security", () => {
getDocumentById(userFirestore, commonTerms.collections.users.name, users[0].uid)
).to.be.rejectedWith("Missing or insufficient permissions.")
})
/// @note unauthenticated users should not be able to access any data
it("should prevent unauthenticated users from accessing the ceremonies collection", async () => {
/// @note unauthenticated users should be allowed to access ceremonies data
it("should allow unauthenticated users from accessing the ceremonies collection", async () => {
await expect(
queryCollection(userFirestore, commonTerms.collections.ceremonies.name, [
where(commonTerms.collections.ceremonies.fields.description, "!=", "")
])
).to.be.rejectedWith("Missing or insufficient permissions.")
).to.be.fulfilled
})
}
// make sure to sign out
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/test/unit/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
cleanUpMockUsers,
sleep,
cleanUpRecursively,
mockCeremoniesCleanup
mockCeremoniesCleanup,
} from "../utils/index"
import { fakeCeremoniesData, fakeCircuitsData, fakeUsersData } from "../data/samples"
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ service cloud.firestore {
// applies to the ceremonies collection and nested collections
match /ceremonies/{ceremonyId=**} {
// any authenticated user can read
allow read: if request.auth != null;
allow read: if true;
// only coordinator can create, and update ceremonies
allow create, update:
if request.auth != null &&
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/functions/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,4 @@ export const completeMultiPartUpload = functions
logAndThrowError(makeError(commonError.code, commonError.message, additionalDetails))
}
}
})
})
2 changes: 1 addition & 1 deletion packages/backend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ export type FinalizeCircuitData = {
circuitId: string
bucketName: string
beacon: string
}
}

0 comments on commit 846053f

Please sign in to comment.