atproto/packages/ozone/tests/get-config.test.ts
Daniel Holmgren 50c0ec176c
Service auth method binding (lxm) (#2663)
* 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>
2024-08-18 15:46:07 -04:00

56 lines
1.6 KiB
TypeScript

import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
import { AtpAgent } from '@atproto/api'
import { TOOLS_OZONE_TEAM } from '../src/lexicon'
import { ids } from '../src/lexicon/lexicons'
describe('get-config', () => {
let network: TestNetwork
let agent: AtpAgent
let sc: SeedClient
beforeAll(async () => {
network = await TestNetwork.create({
dbPostgresSchema: 'ozone_server_config',
})
agent = network.ozone.getClient()
sc = network.getSeedClient()
await basicSeed(sc)
await network.processAll()
})
afterAll(async () => {
await network.close()
})
const getConfig = async (role: 'moderator' | 'admin' | 'triage') => {
const { data } = await agent.api.tools.ozone.server.getConfig(
{},
{
headers: await network.ozone.modHeaders(
ids.ToolsOzoneServerGetConfig,
role,
),
},
)
return data
}
it('returns server config', async () => {
const moderatorConfig = await getConfig('moderator')
expect(moderatorConfig.appview?.url).toBe(network.ozone.ctx.cfg.appview.url)
expect(moderatorConfig.pds?.url).toBe(network.ozone.ctx.cfg.pds?.url)
expect(moderatorConfig.blobDivert?.url).toBe(
network.ozone.ctx.cfg.blobDivert?.url,
)
expect(moderatorConfig.chat?.url).toBe(undefined)
expect(moderatorConfig.viewer?.role).toEqual(
TOOLS_OZONE_TEAM.DefsRoleModerator,
)
})
it('returns the right role for the viewer', async () => {
const adminConfig = await getConfig('admin')
expect(adminConfig.viewer?.role).toBe(TOOLS_OZONE_TEAM.DefsRoleAdmin)
})
})