This commit is contained in:
1 parent
172c3a5a0e
commit
922d24cac7
5 files changed
+157
-19
No files matched your search
@@ -43,6 +43,49 @@ test('walks descendants and resolves the actual company instead of classificatio
|
||||
assert.equal(organization.department, '설계부');
|
||||
assert.equal(organization.departmentPath, '설계부');
|
||||
});
|
||||
|
||||
test('uses the tenant immediately below the classification root as company even if descendants are typed COMPANY', () => {
|
||||
const data = payload();
|
||||
data.tree.type = 'COMPANY_GROUP';
|
||||
data.tree.children[0].children[0].type = 'COMPANY';
|
||||
const result = resolveUserOrganization(buildOrgDirectory([data]), user);
|
||||
assert.equal(result.company, '실제 회사');
|
||||
assert.equal(result.companyTenantId, COMPANY);
|
||||
assert.equal(result.department, '설계부');
|
||||
assert.equal(result.departmentTenantId, DEPT);
|
||||
assert.equal(result.departmentPath, '설계부');
|
||||
});
|
||||
|
||||
test('configured roots also resolve company and department when node types are missing', () => {
|
||||
const data = payload();
|
||||
delete data.tree.type;
|
||||
delete data.tree.children[0].type;
|
||||
delete data.tree.children[0].children[0].type;
|
||||
const result = resolveUserOrganization(buildOrgDirectory([data], [ROOT]), user);
|
||||
assert.equal(result.company, '실제 회사');
|
||||
assert.equal(result.department, '설계부');
|
||||
});
|
||||
|
||||
test('mixed node types still use the actual membership leaf as department', () => {
|
||||
const data = payload();
|
||||
const leaf = data.tree.children[0].children[0];
|
||||
leaf.type = 'COMPANY';
|
||||
data.tree.children[0].children = [{ id: OTHER, type: 'DEPARTMENT', name: '설계본부', children: [leaf] }];
|
||||
const result = resolveUserOrganization(buildOrgDirectory([data]), user);
|
||||
assert.equal(result.company, '실제 회사');
|
||||
assert.equal(result.department, '설계부');
|
||||
assert.equal(result.departmentPath, '설계본부 / 설계부');
|
||||
});
|
||||
|
||||
test('membership directly on the company never repeats the company name as department', () => {
|
||||
const data = payload();
|
||||
data.tree.children[0].members = [{ id: USER, department: '실제 회사' }];
|
||||
delete data.tree.children[0].children;
|
||||
const result = resolveUserOrganization(buildOrgDirectory([data]), user);
|
||||
assert.equal(result.company, '실제 회사');
|
||||
assert.equal(result.department, '');
|
||||
assert.equal(result.departmentTenantId, '');
|
||||
});
|
||||
test('merges overlapping roots and flat tenants without losing memberships', () => {
|
||||
const data = payload();
|
||||
data.tenants = [data.tree.children[0].children[0]];
|
||||
@@ -160,3 +203,30 @@ test('a failing root is not accepted as a partial complete directory', async ()
|
||||
test('identifiers verification rejects a structure-only response with no members', async () => {
|
||||
await assert.rejects(getOrgDirectory(env(), { fetchImpl: async () => response({ scope: { tenantId: ROOT }, tree: { id: ROOT, name: 'Root' } }) }), /members_missing/);
|
||||
});
|
||||
|
||||
for (const status of [401, 403, 503]) {
|
||||
test(`organization HTTP ${status} remains distinguishable and is not cached as success`, async () => {
|
||||
const config = env();
|
||||
await assert.rejects(getOrgDirectory(config, { fetchImpl: async () => response({}, status) }), new RegExp('http_' + status));
|
||||
assert.equal((await getOrgDirectory(config, { fetchImpl: async () => response(payload()) })).byUser.size, 1);
|
||||
});
|
||||
}
|
||||
|
||||
test('an aborted organization request reports timeout and allows a fresh retry', async (t) => {
|
||||
const originalTimer = globalThis.setTimeout;
|
||||
t.mock.method(globalThis, 'setTimeout', (callback, delay) => originalTimer(callback, delay === 5000 ? 5 : delay));
|
||||
const config = env();
|
||||
await assert.rejects(getOrgDirectory(config, { fetchImpl: async (_url, { signal }) => new Promise((_resolve, reject) => {
|
||||
signal.addEventListener('abort', () => reject(new DOMException('Aborted', 'AbortError')), { once: true });
|
||||
}) }), /org_context_timeout/);
|
||||
assert.equal((await getOrgDirectory(config, { fetchImpl: async () => response(payload()) })).byUser.size, 1);
|
||||
});
|
||||
|
||||
test('rotating integration credentials cannot reuse the previous directory cache', async () => {
|
||||
const config = env();
|
||||
let calls = 0;
|
||||
const fetchImpl = async () => { calls++; return response(payload()); };
|
||||
await getOrgDirectory(config, { fetchImpl });
|
||||
await getOrgDirectory({ ...config, ORG_CONTEXT_KEY_SECRET: 'rotated-' + config.ORG_CONTEXT_KEY_SECRET }, { fetchImpl });
|
||||
assert.equal(calls, 2);
|
||||
});
|
||||
Reference in new issue
Block a user