@@ -14,6 +14,7 @@ import * as keysUtils from '@/keys/utils/index';
14
14
15
15
describe ( 'PolykeyAgent' , ( ) => {
16
16
const password = 'password' ;
17
+ const localhost = '127.0.0.1' ;
17
18
const logger = new Logger ( 'PolykeyAgent Test' , LogLevel . WARN , [
18
19
new StreamHandler ( ) ,
19
20
] ) ;
@@ -33,13 +34,17 @@ describe('PolykeyAgent', () => {
33
34
const nodePath = path . join ( dataDir , 'polykey' ) ;
34
35
const pkAgent = await PolykeyAgent . createPolykeyAgent ( {
35
36
password,
36
- nodePath,
37
- logger,
38
- keyRingConfig : {
39
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
40
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
41
- strictMemoryLock : false ,
37
+ options : {
38
+ nodePath,
39
+ agentServiceHost : localhost ,
40
+ clientServiceHost : localhost ,
41
+ keys : {
42
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
43
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
44
+ strictMemoryLock : false ,
45
+ } ,
42
46
} ,
47
+ logger,
43
48
} ) ;
44
49
await expect ( pkAgent . destroy ( password ) ) . rejects . toThrow (
45
50
errors . ErrorPolykeyAgentRunning ,
@@ -56,14 +61,18 @@ describe('PolykeyAgent', () => {
56
61
const nodePath = `${ dataDir } /polykey` ;
57
62
const pkAgent = await PolykeyAgent . createPolykeyAgent ( {
58
63
password,
59
- nodePath,
60
- logger,
61
- keyRingConfig : {
62
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
63
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
64
- strictMemoryLock : false ,
64
+ options : {
65
+ nodePath,
66
+ workers : 0 ,
67
+ agentServiceHost : localhost ,
68
+ clientServiceHost : localhost ,
69
+ keys : {
70
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
71
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
72
+ strictMemoryLock : false ,
73
+ } ,
65
74
} ,
66
- workers : 0 ,
75
+ logger ,
67
76
} ) ;
68
77
let nodePathContents = await fs . promises . readdir ( nodePath ) ;
69
78
expect ( nodePathContents ) . toContain ( config . paths . statusBase ) ;
@@ -96,13 +105,17 @@ describe('PolykeyAgent', () => {
96
105
const statusLockPath = path . join ( nodePath , config . paths . statusLockBase ) ;
97
106
const pkAgent = await PolykeyAgent . createPolykeyAgent ( {
98
107
password,
99
- nodePath,
100
- logger,
101
- keyRingConfig : {
102
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
103
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
104
- strictMemoryLock : false ,
108
+ options : {
109
+ nodePath,
110
+ agentServiceHost : localhost ,
111
+ clientServiceHost : localhost ,
112
+ keys : {
113
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
114
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
115
+ strictMemoryLock : false ,
116
+ } ,
105
117
} ,
118
+ logger,
106
119
} ) ;
107
120
const status = new Status ( {
108
121
statusPath,
@@ -131,13 +144,17 @@ describe('PolykeyAgent', () => {
131
144
} ) ;
132
145
const pkAgent = await PolykeyAgent . createPolykeyAgent ( {
133
146
password,
134
- nodePath,
135
- logger,
136
- keyRingConfig : {
137
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
138
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
139
- strictMemoryLock : false ,
147
+ options : {
148
+ nodePath,
149
+ agentServiceHost : localhost ,
150
+ clientServiceHost : localhost ,
151
+ keys : {
152
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
153
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
154
+ strictMemoryLock : false ,
155
+ } ,
140
156
} ,
157
+ logger,
141
158
} ) ;
142
159
expect ( await schema . readVersion ( ) ) . toBe ( config . stateVersion ) ;
143
160
await pkAgent . stop ( ) ;
@@ -158,13 +175,17 @@ describe('PolykeyAgent', () => {
158
175
await expect (
159
176
PolykeyAgent . createPolykeyAgent ( {
160
177
password,
161
- nodePath,
162
- logger,
163
- keyRingConfig : {
164
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
165
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
166
- strictMemoryLock : false ,
178
+ options : {
179
+ nodePath,
180
+ agentServiceHost : localhost ,
181
+ clientServiceHost : localhost ,
182
+ keys : {
183
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
184
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
185
+ strictMemoryLock : false ,
186
+ } ,
167
187
} ,
188
+ logger,
168
189
} ) ,
169
190
) . rejects . toThrow ( errors . ErrorSchemaVersionTooNew ) ;
170
191
// The 0 version will always be too old
@@ -179,13 +200,17 @@ describe('PolykeyAgent', () => {
179
200
await expect (
180
201
PolykeyAgent . createPolykeyAgent ( {
181
202
password,
182
- nodePath,
183
- logger,
184
- keyRingConfig : {
185
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
186
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
187
- strictMemoryLock : false ,
203
+ options : {
204
+ nodePath,
205
+ agentServiceHost : localhost ,
206
+ clientServiceHost : localhost ,
207
+ keys : {
208
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
209
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
210
+ strictMemoryLock : false ,
211
+ } ,
188
212
} ,
213
+ logger,
189
214
} ) ,
190
215
) . rejects . toThrow ( errors . ErrorSchemaVersionTooOld ) ;
191
216
} ) ;
@@ -195,13 +220,17 @@ describe('PolykeyAgent', () => {
195
220
try {
196
221
pkAgent = await PolykeyAgent . createPolykeyAgent ( {
197
222
password,
198
- nodePath,
199
- logger,
200
- keyRingConfig : {
201
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
202
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
203
- strictMemoryLock : false ,
223
+ options : {
224
+ nodePath,
225
+ agentServiceHost : localhost ,
226
+ clientServiceHost : localhost ,
227
+ keys : {
228
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
229
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
230
+ strictMemoryLock : false ,
231
+ } ,
204
232
} ,
233
+ logger,
205
234
} ) ;
206
235
const prom = promise < CertManagerChangeData > ( ) ;
207
236
pkAgent . events . on (
@@ -224,13 +253,17 @@ describe('PolykeyAgent', () => {
224
253
try {
225
254
pkAgent = await PolykeyAgent . createPolykeyAgent ( {
226
255
password,
227
- nodePath,
228
- logger,
229
- keyRingConfig : {
230
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
231
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
232
- strictMemoryLock : false ,
256
+ options : {
257
+ nodePath,
258
+ agentServiceHost : localhost ,
259
+ clientServiceHost : localhost ,
260
+ keys : {
261
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
262
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
263
+ strictMemoryLock : false ,
264
+ } ,
233
265
} ,
266
+ logger,
234
267
} ) ;
235
268
const prom = promise < CertManagerChangeData > ( ) ;
236
269
pkAgent . events . on (
@@ -253,13 +286,17 @@ describe('PolykeyAgent', () => {
253
286
try {
254
287
pkAgent = await PolykeyAgent . createPolykeyAgent ( {
255
288
password,
256
- nodePath,
257
- logger,
258
- keyRingConfig : {
259
- passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
260
- passwordMemLimit : keysUtils . passwordMemLimits . min ,
261
- strictMemoryLock : false ,
289
+ options : {
290
+ nodePath,
291
+ agentServiceHost : localhost ,
292
+ clientServiceHost : localhost ,
293
+ keys : {
294
+ passwordOpsLimit : keysUtils . passwordOpsLimits . min ,
295
+ passwordMemLimit : keysUtils . passwordMemLimits . min ,
296
+ strictMemoryLock : false ,
297
+ } ,
262
298
} ,
299
+ logger,
263
300
} ) ;
264
301
const prom = promise < CertManagerChangeData > ( ) ;
265
302
pkAgent . events . on (
0 commit comments