diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-20 15:37:14 +0000 |
---|---|---|
committer | Samuel Newman <mozzius@protonmail.com> | 2024-03-20 15:37:14 +0000 |
commit | d24ffba01d7aa5a505b4e3d319dfecffc3d039ca (patch) | |
tree | 4e860ca6a6dd038f41bba1839d180177b70c877b /jest/test-pds.ts | |
parent | 2fa26ceedc1c7f6f3c4a1bdeab621b34c24bcb17 (diff) | |
parent | 023e12bb4ec1dade373c810a13d8bba6d96a22be (diff) | |
download | voidsky-d24ffba01d7aa5a505b4e3d319dfecffc3d039ca.tar.zst |
Merge remote-tracking branch 'origin/main' into samuel/alf-login
Diffstat (limited to 'jest/test-pds.ts')
-rw-r--r-- | jest/test-pds.ts | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/jest/test-pds.ts b/jest/test-pds.ts index 51d964394..b70a9abf0 100644 --- a/jest/test-pds.ts +++ b/jest/test-pds.ts @@ -72,6 +72,7 @@ export async function createServer( const phoneParams = phoneRequired ? { phoneVerificationRequired: true, + phoneVerificationProvider: 'twilio', twilioAccountSid: 'ACXXXXXXX', twilioAuthToken: 'AUTH', twilioServiceSid: 'VAXXXXXXXX', @@ -95,6 +96,35 @@ export async function createServer( }) mockTwilio(testNet.pds) + // add the test mod authority + if (!phoneRequired) { + const agent = new BskyAgent({service: pdsUrl}) + const res = await agent.api.com.atproto.server.createAccount({ + email: 'mod-authority@test.com', + handle: 'mod-authority.test', + password: 'hunter2', + }) + agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`) + await agent.api.app.bsky.actor.profile.create( + {repo: res.data.did}, + { + displayName: 'Dev-env Moderation', + description: `The pretend version of mod.bsky.app`, + }, + ) + + await agent.api.app.bsky.labeler.service.create( + {repo: res.data.did, rkey: 'self'}, + { + policies: { + labelValues: ['!hide', '!warn'], + labelValueDefinitions: [], + }, + createdAt: new Date().toISOString(), + }, + ) + } + const pic = fs.readFileSync( path.join(__dirname, '..', 'assets', 'default-avatar.png'), ) @@ -455,13 +485,13 @@ async function getPort(start = 3000) { } export const mockTwilio = (pds: TestPds) => { - if (!pds.ctx.twilio) return + if (!pds.ctx.phoneVerifier) return - pds.ctx.twilio.sendCode = async (_number: string) => { + pds.ctx.phoneVerifier.sendCode = async (_number: string) => { // do nothing } - pds.ctx.twilio.verifyCode = async (_number: string, code: string) => { + pds.ctx.phoneVerifier.verifyCode = async (_number: string, code: string) => { return code === '000000' } } |