import { AuthService } from '../api'; import { createOptions, TestOrgId, TestTenantId, TestProjectId, setupTokens } from '../test.config'; import { trim } from 'lodash'; import { matchRealname, matchMobile } from './matcher/string.matcher'; const factory = createOptions(); beforeAll(async () => { await setupTokens(); console.log('tokens are loaded'); // console.log(TestTokens); }); test('auth 00 广联云 token 加载 pengyc 用户对象', async () => { const user = await new AuthService(factory).loadCloudtUser(); console.log('loadCloudtUser(pengyc)', user); matchRealname(user.realname); matchMobile(user.mobile); }); test('auth 01 加载用户角色', async () => { const userId = 137454301650944; const roles = await new AuthService(factory).loadUserRoles('133116919562240/133118457434112/133118611058688', userId); // console.log('loadUserRoles', roles); expect(roles.userId).toBe(String(userId)); expect(roles.roles.length).toBeGreaterThan(0); }); test('auth 01 某个用户是否有某个产品的权限', async () => { const roles = await new AuthService(factory).loadProductAuth(TestProjectId, 'labor-glm', TestTenantId, TestOrgId); console.log('劳务权限', roles); });