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 ( ) ) {
@@ -15,7 +23,9 @@ export class MockRdiClient extends ApiRdiClient {
15
23
16
24
public getPipeline = jest . fn ( ) ;
17
25
18
- public getTemplate = jest . fn ( ) ;
26
+ public getConfigTemplate = jest . fn ( ) ;
27
+
28
+ public getJobTemplate = jest . fn ( ) ;
19
29
20
30
public getStrategies = jest . fn ( ) ;
21
31
@@ -56,9 +66,75 @@ export const mockRdi = Object.assign(new Rdi(), {
56
66
username : 'user' ,
57
67
} ) ;
58
68
69
+ export const mockRdiPipeline = Object . assign ( new RdiPipeline ( ) , {
70
+ jobs : { some_job : { } } ,
71
+ config : { } ,
72
+ } ) ;
73
+
74
+ export const mockRdiDryRunJob : RdiDryRunJobDto = Object . assign ( new RdiDryRunJobDto ( ) , {
75
+ input_data : { } ,
76
+ job : { } ,
77
+ } ) ;
78
+
79
+ export const mockRdiStatisticsData = Object . assign ( new RdiStatisticsData ( ) , { } ) ;
80
+
81
+ export const mockRdiDecrypted = Object . assign ( new Rdi ( ) , {
82
+ id : '1' ,
83
+ name : 'name' ,
84
+ version : '1.0' ,
85
+ url : 'http://test.com' ,
86
+ username : 'testuser' ,
87
+ password : mockRdiPasswordPlain ,
88
+ lastConnection : new Date ( ) ,
89
+ } ) ;
90
+
91
+ export const mockRdiEntityEncrypted = Object . assign ( new RdiEntity ( ) , {
92
+ ...mockRdiDecrypted ,
93
+ password : mockRdiPasswordEncrypted ,
94
+ encryption : EncryptionStrategy . KEYTAR ,
95
+ } ) ;
96
+
59
97
export const mockRdiUnauthorizedError = {
60
98
message : 'Request failed with status code 401' ,
61
99
response : {
62
100
status : 401 ,
63
101
} ,
64
102
} ;
103
+
104
+ export const mockRdiRepository = jest . fn ( ( ) => ( {
105
+ get : jest . fn ( ) ,
106
+ list : jest . fn ( ) ,
107
+ create : jest . fn ( ) ,
108
+ update : jest . fn ( ) ,
109
+ delete : jest . fn ( ) ,
110
+ } ) ) ;
111
+
112
+ export const mockRdiClientProvider = jest . fn ( ( ) => ( {
113
+ getOrCreate : jest . fn ( ) ,
114
+ create : jest . fn ( ) ,
115
+ delete : jest . fn ( ) ,
116
+ deleteById : jest . fn ( ) ,
117
+ deleteManyByRdiId : jest . fn ( ) ,
118
+ } ) ) ;
119
+
120
+ export const mockRdiClientFactory = jest . fn ( ( ) => ( {
121
+ createClient : jest . fn ( ) ,
122
+ } ) ) ;
123
+
124
+ export const mockRdiClientStorage = jest . fn ( ( ) => ( {
125
+ getByMetadata : jest . fn ( ) ,
126
+ set : jest . fn ( ) ,
127
+ delete : jest . fn ( ) ,
128
+ deleteManyByRdiId : jest . fn ( ) ,
129
+ } ) ) ;
130
+
131
+ export const mockRdiPipelineAnalytics = jest . fn ( ( ) => ( {
132
+ sendRdiPipelineFetched : jest . fn ( ) ,
133
+ sendRdiPipelineFetchFailed : jest . fn ( ) ,
134
+ sendRdiPipelineDeployed : jest . fn ( ) ,
135
+ sendRdiPipelineDeployFailed : jest . fn ( ) ,
136
+ } ) ) ;
137
+
138
+ export const mockRdiAnalytics = jest . fn ( ( ) => ( {
139
+ sendRdiInstanceDeleted : jest . fn ( ) ,
140
+ } ) ) ;
0 commit comments