27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
const ROOT = '038326b6-954a-48a7-a85f-efd83f62b82a';
|
|
const COMPANY = '9951229e-eea5-4376-96f4-78989bc3a506';
|
|
const DEPT = 'ee2f39ac-fe52-4cfb-b4e3-4ae1d114c916';
|
|
const USER = '01900000-0000-7000-8000-000000000001';
|
|
|
|
export default {
|
|
fetch(request) {
|
|
const url = new URL(request.url);
|
|
if (url.origin !== 'https://organization.example.test') throw new Error('Redirect must never be followed');
|
|
if (request.headers.get('X-Baron-Key-ID') !== 'fixture-key-id' || request.headers.get('X-Baron-Key-Secret') !== 'fixture-key-secret') {
|
|
throw new Error('Expected organization integration credentials');
|
|
}
|
|
if (url.pathname === '/redirect') return Response.redirect('https://must-not-follow.example.test/', 302);
|
|
if (url.searchParams.get('tenantId') !== ROOT || url.searchParams.get('exposure') !== 'identifiers') {
|
|
throw new Error('Unexpected organization query');
|
|
}
|
|
return Response.json({
|
|
schemaVersion: 'baron.org-context.v2', scope: { tenantId: ROOT },
|
|
tree: { id: ROOT, name: '한맥가족', type: 'COMPANY_GROUP', children: [
|
|
{ id: COMPANY, name: '총괄기획실&기술개발센터', type: 'COMPANY', children: [
|
|
{ id: DEPT, name: 'IS3', type: 'COMPANY', members: [{ id: USER, isPrimary: true }] }
|
|
] }
|
|
] }
|
|
});
|
|
}
|
|
};
|