acs_application.test.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {api, DateRegex, DatetimeRegex} from "./restful";
  2. import {Resp} from "@util/Resp";
  3. import {models} from "@core-models/Models";
  4. import {Config} from "@util/Config";
  5. const globalAny: any = global;
  6. export const acs_application_test = () => {
  7. beforeAll(async (done) => {
  8. globalAny.user_id = 'admin';
  9. await globalAny.svr.init_data_models(models);
  10. done();
  11. }, 30000);
  12. test('获取应用列表', async () => {
  13. let result = await api('/api/acs.application.get_list', {
  14. });
  15. expect(result.code).toBe(Resp.OK.code);
  16. expect(result.data).toBeDefined();
  17. expect(result.data.list).toBeDefined();
  18. expect(result.data.list.length).toBe(1);
  19. expect(result.data.list[0].app_id).toBe('a5ce3be0-de5b-11ed-898d-230b931b8e81');
  20. });
  21. test('添加应用', async () => {
  22. let result = await api('/api/acs.application.add', {
  23. id: 'app_id',
  24. name: '测试',
  25. app_type: 0,
  26. auth_type: 1,
  27. status: 1
  28. });
  29. expect(result.code).toBe(Resp.OK.code);
  30. });
  31. test('获取应用列表', async () => {
  32. let result = await api('/api/acs.application.get_list', {
  33. keyword: '测试'
  34. });
  35. expect(result.code).toBe(Resp.OK.code);
  36. expect(result.data).toBeDefined();
  37. expect(result.data.list).toBeDefined();
  38. expect(result.data.list.length).toBe(1);
  39. expect(result.data.list[0].app_id).toBe('app_id');
  40. expect(result.data.list[0].name).toBe('测试');
  41. expect(result.data.list[0].app_type).toBe(0);
  42. expect(result.data.list[0].auth_type).toBe(1);
  43. expect(result.data.list[0].status).toBe(1);
  44. });
  45. test('修改应用信息', async () => {
  46. let result = await api('/api/acs.application.modify', {
  47. id: 'app_id',
  48. name: '测试new',
  49. app_key: 'app_key',
  50. app_type: 2,
  51. auth_type: 2,
  52. status: 0,
  53. private_key: 'private',
  54. public_key: 'public',
  55. memo: 'memo'
  56. });
  57. expect(result.code).toBe(Resp.OK.code);
  58. });
  59. test('获取应用列表', async () => {
  60. let result = await api('/api/acs.application.get_list', {
  61. keyword: '测试'
  62. });
  63. expect(result.code).toBe(Resp.OK.code);
  64. expect(result.data).toBeDefined();
  65. expect(result.data.list).toBeDefined();
  66. expect(result.data.list.length).toBe(1);
  67. expect(result.data.list[0].app_id).toBe('app_id');
  68. expect(result.data.list[0].app_key).toBe('app_key');
  69. expect(result.data.list[0].name).toBe('测试new');
  70. expect(result.data.list[0].app_type).toBe(2);
  71. expect(result.data.list[0].auth_type).toBe(2);
  72. expect(result.data.list[0].status).toBe(0);
  73. });
  74. test('应用详情', async () => {
  75. let result = await api('/api/acs.application.detail', {
  76. id: 'app_id'
  77. });
  78. expect(result.code).toBe(Resp.OK.code);
  79. expect(result.data).toBeDefined();
  80. expect(result.data.app_id).toBe('app_id');
  81. expect(result.data.app_key).toBe('app_key');
  82. expect(result.data.name).toBe('测试new');
  83. expect(result.data.app_type).toBe(2);
  84. expect(result.data.auth_type).toBe(2);
  85. expect(result.data.status).toBe(0);
  86. expect(result.data.private_key).toBe('private');
  87. expect(result.data.public_key).toBe('public');
  88. expect(result.data.memo).toBe('memo');
  89. });
  90. test('删除应用', async () => {
  91. let result = await api('/api/acs.application.remove', {
  92. id: 'app_id'
  93. });
  94. expect(result.code).toBe(Resp.OK.code);
  95. });
  96. test('获取应用列表', async () => {
  97. let result = await api('/api/acs.application.get_list', {
  98. keyword: '测试'
  99. });
  100. expect(result.code).toBe(Resp.OK.code);
  101. expect(result.data).toBeDefined();
  102. expect(result.data.list).toBeDefined();
  103. expect(result.data.list.length).toBe(0);
  104. });
  105. }