123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import {api, DateRegex, DatetimeRegex} from "./restful";
- import {Resp} from "@util/Resp";
- import {models} from "@core-models/Models";
- import {Config} from "@util/Config";
- const globalAny: any = global;
- export const acs_application_test = () => {
- beforeAll(async (done) => {
- globalAny.user_id = 'admin';
- await globalAny.svr.init_data_models(models);
- done();
- }, 30000);
- test('获取应用列表', async () => {
- let result = await api('/api/acs.application.get_list', {
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.list).toBeDefined();
- expect(result.data.list.length).toBe(1);
- expect(result.data.list[0].app_id).toBe('a5ce3be0-de5b-11ed-898d-230b931b8e81');
- });
- test('添加应用', async () => {
- let result = await api('/api/acs.application.add', {
- id: 'app_id',
- name: '测试',
- app_type: 0,
- auth_type: 1,
- status: 1
- });
- expect(result.code).toBe(Resp.OK.code);
- });
- test('获取应用列表', async () => {
- let result = await api('/api/acs.application.get_list', {
- keyword: '测试'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.list).toBeDefined();
- expect(result.data.list.length).toBe(1);
- expect(result.data.list[0].app_id).toBe('app_id');
- expect(result.data.list[0].name).toBe('测试');
- expect(result.data.list[0].app_type).toBe(0);
- expect(result.data.list[0].auth_type).toBe(1);
- expect(result.data.list[0].status).toBe(1);
- });
- test('修改应用信息', async () => {
- let result = await api('/api/acs.application.modify', {
- id: 'app_id',
- name: '测试new',
- app_key: 'app_key',
- app_type: 2,
- auth_type: 2,
- status: 0,
- private_key: 'private',
- public_key: 'public',
- memo: 'memo'
- });
- expect(result.code).toBe(Resp.OK.code);
- });
- test('获取应用列表', async () => {
- let result = await api('/api/acs.application.get_list', {
- keyword: '测试'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.list).toBeDefined();
- expect(result.data.list.length).toBe(1);
- expect(result.data.list[0].app_id).toBe('app_id');
- expect(result.data.list[0].app_key).toBe('app_key');
- expect(result.data.list[0].name).toBe('测试new');
- expect(result.data.list[0].app_type).toBe(2);
- expect(result.data.list[0].auth_type).toBe(2);
- expect(result.data.list[0].status).toBe(0);
- });
- test('应用详情', async () => {
- let result = await api('/api/acs.application.detail', {
- id: 'app_id'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.app_id).toBe('app_id');
- expect(result.data.app_key).toBe('app_key');
- expect(result.data.name).toBe('测试new');
- expect(result.data.app_type).toBe(2);
- expect(result.data.auth_type).toBe(2);
- expect(result.data.status).toBe(0);
- expect(result.data.private_key).toBe('private');
- expect(result.data.public_key).toBe('public');
- expect(result.data.memo).toBe('memo');
- });
- test('删除应用', async () => {
- let result = await api('/api/acs.application.remove', {
- id: 'app_id'
- });
- expect(result.code).toBe(Resp.OK.code);
- });
- test('获取应用列表', async () => {
- let result = await api('/api/acs.application.get_list', {
- keyword: '测试'
- });
- expect(result.code).toBe(Resp.OK.code);
- expect(result.data).toBeDefined();
- expect(result.data.list).toBeDefined();
- expect(result.data.list.length).toBe(0);
- });
- }
|