Skip to content

Commit

Permalink
AuthProvider.test: add test with no auth provider
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbCaudill committed Nov 1, 2023
1 parent a6be8e5 commit f7f8e19
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/automerge-repo/test/AuthProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("AuthProvider", () => {

describe("authentication", () => {
const setup = async (
authProvider: AuthProvider | Record<string, AuthProvider>
authProvider?: AuthProvider | Record<string, AuthProvider>
) => {
if (authProvider instanceof AuthProvider)
authProvider = {
Expand All @@ -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<TestDoc>()
Expand Down Expand Up @@ -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()
})
})

Expand Down

0 comments on commit f7f8e19

Please sign in to comment.