|
1 | 1 | import {
|
2 | 2 | Rdi,
|
3 | 3 | RdiClientMetadata,
|
| 4 | + RdiPipeline, |
| 5 | + RdiStatisticsData, |
4 | 6 | } from 'src/modules/rdi/models';
|
5 | 7 | import { ApiRdiClient } from 'src/modules/rdi/client/api.rdi.client';
|
| 8 | +import { RdiEntity } from 'src/modules/rdi/entities/rdi.entity'; |
| 9 | +import { EncryptionStrategy } from 'src/modules/encryption/models'; |
| 10 | +import { RdiDryRunJobDto } from 'src/modules/rdi/dto'; |
6 | 11 |
|
7 | 12 | export const mockRdiId = 'rdiId';
|
| 13 | +export const mockRdiPasswordEncrypted = 'password_ENCRYPTED'; |
| 14 | + |
| 15 | +export const mockRdiPasswordPlain = 'some pass'; |
8 | 16 |
|
9 | 17 | export class MockRdiClient extends ApiRdiClient {
|
10 | 18 | constructor(metadata: RdiClientMetadata, client: any = jest.fn()) {
|
@@ -56,9 +64,57 @@ export const mockRdi = Object.assign(new Rdi(), {
|
56 | 64 | username: 'user',
|
57 | 65 | });
|
58 | 66 |
|
| 67 | +export const mockRdiPipeline = Object.assign(new RdiPipeline(), { |
| 68 | + jobs: { some_job: {} }, |
| 69 | + config: {}, |
| 70 | +}); |
| 71 | + |
| 72 | +export const mockRdiDryRunJob: RdiDryRunJobDto = Object.assign(new RdiDryRunJobDto(), { |
| 73 | + input_data: {}, |
| 74 | + job: {}, |
| 75 | +}); |
| 76 | + |
| 77 | +export const mockRdiStatisticsData = Object.assign(new RdiStatisticsData(), {}); |
| 78 | + |
| 79 | +export const mockRdiDecrypted = Object.assign(new Rdi(), { |
| 80 | + id: '1', |
| 81 | + name: 'name', |
| 82 | + version: '1.0', |
| 83 | + url: 'http://test.com', |
| 84 | + username: 'testuser', |
| 85 | + password: mockRdiPasswordPlain, |
| 86 | + lastConnection: new Date(), |
| 87 | +}); |
| 88 | + |
| 89 | +export const mockRdiEntityEncrypted = Object.assign(new RdiEntity(), { |
| 90 | + ...mockRdiDecrypted, |
| 91 | + password: mockRdiPasswordEncrypted, |
| 92 | + encryption: EncryptionStrategy.KEYTAR, |
| 93 | +}); |
| 94 | + |
59 | 95 | export const mockRdiUnauthorizedError = {
|
60 | 96 | message: 'Request failed with status code 401',
|
61 | 97 | response: {
|
62 | 98 | status: 401,
|
63 | 99 | },
|
64 | 100 | };
|
| 101 | + |
| 102 | +export const mockRdiRepository = jest.fn(() => ({ |
| 103 | + get: jest.fn(), |
| 104 | + list: jest.fn(), |
| 105 | + create: jest.fn(), |
| 106 | + update: jest.fn(), |
| 107 | + delete: jest.fn(), |
| 108 | +})); |
| 109 | + |
| 110 | +export const mockRdiClientProvider = jest.fn(() => ({ |
| 111 | + getOrCreate: jest.fn(), |
| 112 | + create: jest.fn(), |
| 113 | + delete: jest.fn(), |
| 114 | + deleteById: jest.fn(), |
| 115 | + deleteManyByRdiId: jest.fn(), |
| 116 | +})); |
| 117 | + |
| 118 | +export const mockRdiClientFactory = jest.fn(() => ({ |
| 119 | + createClient: jest.fn(), |
| 120 | +})); |
0 commit comments