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>
140 lines
3.2 KiB
TypeScript
140 lines
3.2 KiB
TypeScript
import { AtUri, AtpAgent } from '@atproto/api'
|
|
import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
|
|
import { ids } from '../../src/lexicon/lexicons'
|
|
|
|
describe('bsky actor likes feed views', () => {
|
|
let network: TestNetwork
|
|
let agent: AtpAgent
|
|
let pdsAgent: AtpAgent
|
|
let sc: SeedClient
|
|
|
|
// account dids, for convenience
|
|
let alice: string
|
|
let bob: string
|
|
let carol: string
|
|
|
|
beforeAll(async () => {
|
|
network = await TestNetwork.create({
|
|
dbPostgresSchema: 'bsky_views_actor_likes',
|
|
})
|
|
agent = network.bsky.getClient()
|
|
pdsAgent = network.pds.getClient()
|
|
sc = network.getSeedClient()
|
|
await basicSeed(sc)
|
|
await network.processAll()
|
|
alice = sc.dids.alice
|
|
bob = sc.dids.bob
|
|
carol = sc.dids.carol
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await network.close()
|
|
})
|
|
|
|
it('returns posts liked by actor', async () => {
|
|
const {
|
|
data: { feed: bobLikes },
|
|
} = await agent.api.app.bsky.feed.getActorLikes(
|
|
{ actor: sc.accounts[bob].handle },
|
|
{
|
|
headers: await network.serviceHeaders(
|
|
bob,
|
|
ids.AppBskyFeedGetActorLikes,
|
|
),
|
|
},
|
|
)
|
|
|
|
expect(bobLikes).toHaveLength(3)
|
|
|
|
await expect(
|
|
agent.api.app.bsky.feed.getActorLikes(
|
|
{ actor: sc.accounts[bob].handle },
|
|
{
|
|
headers: await network.serviceHeaders(
|
|
carol,
|
|
ids.AppBskyFeedGetActorLikes,
|
|
),
|
|
},
|
|
),
|
|
).rejects.toThrow('Profile not found')
|
|
})
|
|
|
|
it('viewer has blocked author of liked post(s)', async () => {
|
|
const bobBlocksAlice = await pdsAgent.api.app.bsky.graph.block.create(
|
|
{
|
|
repo: bob, // bob blocks alice
|
|
},
|
|
{
|
|
subject: alice,
|
|
createdAt: new Date().toISOString(),
|
|
},
|
|
sc.getHeaders(bob),
|
|
)
|
|
|
|
await network.processAll()
|
|
|
|
const {
|
|
data: { feed },
|
|
} = await agent.api.app.bsky.feed.getActorLikes(
|
|
{ actor: sc.accounts[bob].handle },
|
|
{
|
|
headers: await network.serviceHeaders(
|
|
bob,
|
|
ids.AppBskyFeedGetActorLikes,
|
|
),
|
|
},
|
|
)
|
|
|
|
expect(
|
|
feed.every((item) => {
|
|
return item.post.author.did !== alice
|
|
}),
|
|
).toBe(true)
|
|
|
|
// unblock
|
|
await pdsAgent.api.app.bsky.graph.block.delete(
|
|
{ repo: bob, rkey: new AtUri(bobBlocksAlice.uri).rkey },
|
|
sc.getHeaders(bob),
|
|
)
|
|
})
|
|
|
|
it('liked post author has blocked viewer', async () => {
|
|
const aliceBlockBob = await pdsAgent.api.app.bsky.graph.block.create(
|
|
{
|
|
repo: alice, // alice blocks bob
|
|
},
|
|
{
|
|
subject: bob,
|
|
createdAt: new Date().toISOString(),
|
|
},
|
|
sc.getHeaders(alice),
|
|
)
|
|
|
|
await network.processAll()
|
|
|
|
const {
|
|
data: { feed },
|
|
} = await agent.api.app.bsky.feed.getActorLikes(
|
|
{ actor: sc.accounts[bob].handle },
|
|
{
|
|
headers: await network.serviceHeaders(
|
|
bob,
|
|
ids.AppBskyFeedGetActorLikes,
|
|
),
|
|
},
|
|
)
|
|
|
|
expect(
|
|
feed.every((item) => {
|
|
return item.post.author.did !== alice
|
|
}),
|
|
).toBe(true)
|
|
|
|
// unblock
|
|
await pdsAgent.api.app.bsky.graph.block.delete(
|
|
{ repo: alice, rkey: new AtUri(aliceBlockBob.uri).rkey },
|
|
sc.getHeaders(alice),
|
|
)
|
|
})
|
|
})
|