From f7f8e196a0ba8f2a2e3176ff30220385c930d2b3 Mon Sep 17 00:00:00 2001 From: HerbCaudill Date: Wed, 1 Nov 2023 13:12:29 +0100 Subject: [PATCH] AuthProvider.test: add test with no auth provider --- .../automerge-repo/test/AuthProvider.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/automerge-repo/test/AuthProvider.test.ts b/packages/automerge-repo/test/AuthProvider.test.ts index 5d281b94e..95e1891fa 100644 --- a/packages/automerge-repo/test/AuthProvider.test.ts +++ b/packages/automerge-repo/test/AuthProvider.test.ts @@ -133,7 +133,7 @@ describe("AuthProvider", () => { describe("authentication", () => { const setup = async ( - authProvider: AuthProvider | Record + authProvider?: AuthProvider | Record ) => { if (authProvider instanceof AuthProvider) authProvider = { @@ -147,13 +147,13 @@ describe("AuthProvider", () => { const aliceRepo = new Repo({ network: [new MessageChannelNetworkAdapter(aliceToBob)], peerId: "alice" as PeerId, - authProvider: authProvider.alice, + ...(authProvider ? { authProvider: authProvider.alice } : {}), }) const bobRepo = new Repo({ network: [new MessageChannelNetworkAdapter(bobToAlice)], peerId: "bob" as PeerId, - authProvider: authProvider.bob, + ...(authProvider ? { authProvider: authProvider.bob } : {}), }) const aliceHandle = aliceRepo.create() @@ -198,16 +198,22 @@ describe("AuthProvider", () => { it("a maximally permissive auth provider authenticates everyone", async () => { const permissive = new AuthProvider() // AuthProvider is maximally permissive by default const { bobRepo, aliceHandle, teardown } = await setup(permissive) - await pause(50) + // bob has alice's document assert.notEqual(bobRepo.handles[aliceHandle.documentId], undefined) teardown() }) - it("a custom auth provider might just authenticate based on peerId", async () => { - // TODO + it("the maximally permissive auth provider is the same as no auth provider", async () => { + const { bobRepo, aliceHandle, teardown } = await setup() // no auth provider + await pause(50) + + // bob has alice's document + assert.notEqual(bobRepo.handles[aliceHandle.documentId], undefined) + + teardown() }) })