50c0ec176c
* add scopes to service auth impl * add error to getServiceAuth * send scoped tokens from pds * clean up privileged access scopes & allow simple service auth tokens for app passwords * integration into ozone * fix up bsky tests * cleanup xrpc-server tests * fix up tests & types * one more test * fix read after write tests * fix mod auth test * convert scopes to be a single method name * add scope check callback for auth verifier * pds changes only * fix feed generation tests * use scope for ozone service profile * dont verify scopes on pds yet * tidy * tidy imports * changeset * add tests * tidy * another changeset * scope -> lxm * tidy * clean up scope references * update nonce size * pr feedback * trim trailing slash * nonce -> jti * fix xrpc-server test * allow service auth on uploadBlob * fix build error * changeset * build, tidy * xrpc-server: update lxm claim check error * appview: temporarily permit labeler service calls to omit lxm claim * xrpc-server: fix test * changeset * fix merged tests --------- Co-authored-by: Devin Ivy <devinivy@gmail.com>
117 lines
3.4 KiB
TypeScript
117 lines
3.4 KiB
TypeScript
import {
|
|
SeedClient,
|
|
TestNetwork,
|
|
basicSeed,
|
|
TestOzone,
|
|
ModeratorClient,
|
|
} from '@atproto/dev-env'
|
|
import { AtpAgent } from '@atproto/api'
|
|
import { AtUri } from '@atproto/syntax'
|
|
import {
|
|
REASONOTHER,
|
|
REASONSPAM,
|
|
} from '../src/lexicon/types/com/atproto/moderation/defs'
|
|
import { forSnapshot } from './_util'
|
|
import { ids } from '../src/lexicon/lexicons'
|
|
|
|
describe('admin get record view', () => {
|
|
let network: TestNetwork
|
|
let ozone: TestOzone
|
|
let agent: AtpAgent
|
|
let sc: SeedClient
|
|
let modClient: ModeratorClient
|
|
|
|
beforeAll(async () => {
|
|
network = await TestNetwork.create({
|
|
dbPostgresSchema: 'ozone_admin_get_record',
|
|
})
|
|
ozone = network.ozone
|
|
agent = ozone.getClient()
|
|
sc = network.getSeedClient()
|
|
modClient = ozone.getModClient()
|
|
await basicSeed(sc)
|
|
await network.processAll()
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await network.close()
|
|
})
|
|
|
|
beforeAll(async () => {
|
|
await sc.createReport({
|
|
reportedBy: sc.dids.bob,
|
|
reasonType: REASONSPAM,
|
|
subject: {
|
|
$type: 'com.atproto.repo.strongRef',
|
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
},
|
|
})
|
|
await sc.createReport({
|
|
reportedBy: sc.dids.carol,
|
|
reasonType: REASONOTHER,
|
|
reason: 'defamation',
|
|
subject: {
|
|
$type: 'com.atproto.repo.strongRef',
|
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
},
|
|
})
|
|
await modClient.emitEvent({
|
|
event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
|
|
subject: {
|
|
$type: 'com.atproto.repo.strongRef',
|
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
},
|
|
})
|
|
await network.bsky.ctx.dataplane.takedownRecord({
|
|
recordUri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
})
|
|
})
|
|
|
|
it('gets a record by uri, even when taken down.', async () => {
|
|
const result = await agent.api.tools.ozone.moderation.getRecord(
|
|
{ uri: sc.posts[sc.dids.alice][0].ref.uriStr },
|
|
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetRecord) },
|
|
)
|
|
expect(forSnapshot(result.data)).toMatchSnapshot()
|
|
})
|
|
|
|
it('gets a record by uri and cid.', async () => {
|
|
const result = await agent.api.tools.ozone.moderation.getRecord(
|
|
{
|
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
cid: sc.posts[sc.dids.alice][0].ref.cidStr,
|
|
},
|
|
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetRecord) },
|
|
)
|
|
expect(forSnapshot(result.data)).toMatchSnapshot()
|
|
})
|
|
|
|
it('fails when record does not exist.', async () => {
|
|
const promise = agent.api.tools.ozone.moderation.getRecord(
|
|
{
|
|
uri: AtUri.make(
|
|
sc.dids.alice,
|
|
'app.bsky.feed.post',
|
|
'badrkey',
|
|
).toString(),
|
|
},
|
|
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetRecord) },
|
|
)
|
|
await expect(promise).rejects.toThrow('Record not found')
|
|
})
|
|
|
|
it('fails when record cid does not exist.', async () => {
|
|
const promise = agent.api.tools.ozone.moderation.getRecord(
|
|
{
|
|
uri: sc.posts[sc.dids.alice][0].ref.uriStr,
|
|
cid: sc.posts[sc.dids.alice][1].ref.cidStr, // Mismatching cid
|
|
},
|
|
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetRecord) },
|
|
)
|
|
await expect(promise).rejects.toThrow('Record not found')
|
|
})
|
|
})
|