Skip to content

Commit da0e92d

Browse files
author
Adam Spiers
committed
fix(sds): fix typing and linting errors
1 parent b95362d commit da0e92d

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

packages/sds/tests/db.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TestNetworkNoAppView } from '@atproto/dev-env'
2-
// Importing from `dist` to circumvent circular dependency typing issues
3-
import { AccountDb } from '../dist/account-manager/db'
2+
import type { AccountDb } from '../../pds/dist/account-manager/db'
43

54
describe('db', () => {
65
let network: TestNetworkNoAppView

packages/sds/tests/organization-creation.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
import { TestNetwork } from '@atproto/dev-env'
2-
import { SdsAppContext } from '../src/sds-context'
2+
3+
interface MockSdsContext {
4+
authVerifier: {
5+
authorization: () => {
6+
auth: { credentials: { did: string } }
7+
}
8+
}
9+
accountManager: {
10+
createAccount: jest.Mock
11+
}
12+
sharedRepoManager: {
13+
grantAccess: jest.Mock
14+
}
15+
idResolver: {
16+
resolveIdentity: jest.Mock
17+
}
18+
}
319

420
describe('organization creation', () => {
521
let network: TestNetwork
6-
let ctx: SdsAppContext
22+
let ctx: MockSdsContext
723

824
beforeAll(async () => {
925
network = await TestNetwork.create({
@@ -34,7 +50,7 @@ describe('organization creation', () => {
3450
handle: 'test-org.sds.local',
3551
}),
3652
},
37-
} as any
53+
}
3854
})
3955

4056
afterAll(async () => {

packages/sds/tests/recovery.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import AtpAgent from '@atproto/api'
44
import { renameIfExists, rmIfExists } from '@atproto/common'
55
import { SeedClient, TestNetworkNoAppView, basicSeed } from '@atproto/dev-env'
66
import { verifyRepoCar } from '@atproto/repo'
7-
import { AppContext, scripts } from '../dist'
7+
import type { AppContext } from '../../pds/dist/context'
8+
import { scripts } from '../dist'
9+
import type { RecovererContextNoDb } from '../dist/scripts/sequencer-recovery/recoverer'
10+
import type { RotateKeysContext } from '../dist/scripts/rotate-keys'
811

912
describe('recovery', () => {
1013
let network: TestNetworkNoAppView
@@ -135,7 +138,10 @@ describe('recovery', () => {
135138
await restore([alice, bob, elli])
136139

137140
// run recovery operation
138-
await scripts['sequencer-recovery'](network.pds.ctx, ['0', '10', 'true'])
141+
await scripts['sequencer-recovery'](
142+
network.pds.ctx as unknown as RecovererContextNoDb,
143+
['0', '10', 'true'],
144+
)
139145

140146
// ensure alice's CAR is exactly the same as before the loss, including intermediate states based on tracked revs
141147
const startCarAfter = await getCar(alice, startRev)
@@ -165,7 +171,10 @@ describe('recovery', () => {
165171
})
166172

167173
it('rotates keys for users', async () => {
168-
await scripts['rotate-keys'](network.pds.ctx, [elli])
174+
await scripts['rotate-keys'](
175+
network.pds.ctx as unknown as RotateKeysContext,
176+
[elli],
177+
)
169178
const elliKey = await ctx.actorStore.keypair(elli)
170179

171180
const plcData = await ctx.plcClient.getDocumentData(elli)

packages/sds/tests/sds-auth-integration.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ describe('SDS Auth Integration', () => {
222222

223223
test('should handle admin permission inheritance', async () => {
224224
// Grant admin permissions
225-
const permissions: RepositoryPermissions = { admin: true }
225+
const permissions: RepositoryPermissions = {
226+
read: true,
227+
write: true,
228+
admin: true,
229+
}
226230
await permissionManager.grantAccess(
227231
testRepoDid,
228232
testUserDid,
@@ -254,7 +258,10 @@ describe('SDS Auth Integration', () => {
254258

255259
test('should handle write permission inheritance', async () => {
256260
// Grant write permissions
257-
const permissions: RepositoryPermissions = { write: true }
261+
const permissions: RepositoryPermissions = {
262+
read: true,
263+
write: true,
264+
}
258265
await permissionManager.grantAccess(
259266
testRepoDid,
260267
testUserDid,

packages/sds/tests/sds-endpoint-logic.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { TestNetworkWithSds } from '@atproto/dev-env'
22
import { InvalidRequestError } from '@atproto/xrpc-server'
3+
import type { DatabaseSchema } from '../src/account-manager/db/schema'
4+
import type { Database } from '../src/db'
35
import { SdsPermissionManager } from '../src/permission-manager'
46
import { RepositoryPermissions } from '../src/types'
57

@@ -17,7 +19,7 @@ describe('SDS Endpoint Logic', () => {
1719
dbPostgresSchema: 'sds_endpoint_logic_test',
1820
})
1921
permissionManager = new SdsPermissionManager(
20-
network.sds.ctx.accountManager.db,
22+
network.sds.ctx.accountManager.db as unknown as Database<DatabaseSchema>,
2123
)
2224
})
2325

packages/sds/tests/sds-endpoints-unit.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { TestNetworkWithSds } from '@atproto/dev-env'
2+
import type { DatabaseSchema } from '../src/account-manager/db/schema'
3+
import type { Database } from '../src/db'
24
import { SdsPermissionManager } from '../src/permission-manager'
35
import { RepositoryPermissions } from '../src/types'
46

@@ -15,7 +17,7 @@ describe('SDS Endpoints Unit Tests', () => {
1517
dbPostgresSchema: 'sds_endpoints_unit_test',
1618
})
1719
permissionManager = new SdsPermissionManager(
18-
network.sds.ctx.accountManager.db,
20+
network.sds.ctx.accountManager.db as unknown as Database<DatabaseSchema>,
1921
)
2022
})
2123

@@ -374,7 +376,7 @@ describe('SDS Endpoints Unit Tests', () => {
374376
})
375377

376378
test('should validate permission object structure', async () => {
377-
const invalidPermissions = [
379+
const invalidPermissions: unknown[] = [
378380
{ read: 'true', write: 'false' }, // String instead of boolean
379381
{ read: 1, write: 0 }, // Number instead of boolean
380382
{ read: null, write: undefined }, // Null/undefined instead of boolean
@@ -386,7 +388,7 @@ describe('SDS Endpoints Unit Tests', () => {
386388
await permissionManager.grantAccess(
387389
testRepoDid,
388390
testUserDid,
389-
_invalidPermissions,
391+
_invalidPermissions as RepositoryPermissions,
390392
testOwnerDid,
391393
)
392394

@@ -403,7 +405,7 @@ describe('SDS Endpoints Unit Tests', () => {
403405
write: true,
404406
admin: true,
405407
malicious: '"; DROP TABLE shared_repository_permissions; --',
406-
} as any
408+
} as unknown as RepositoryPermissions
407409

408410
try {
409411
await permissionManager.grantAccess(

0 commit comments

Comments
 (0)