@@ -8,9 +8,19 @@ import mockNestedTermsAndMissingAggs from './mockESData/mockNestedTermsAndMissin
8
8
import mockNestedAggs from './mockESData/mockNestedAggs' ;
9
9
10
10
const mockPing = ( ) => {
11
- nock ( config . esConfig . host )
12
- . head ( '/' )
13
- . reply ( 200 , 'hello' ) ;
11
+ nock ( config . esConfig . host ) . head ( '/' ) . reply ( 200 , 'hello' ) ;
12
+ } ;
13
+
14
+ const mockRefresh = ( ) => {
15
+ if ( config . allowRefresh ) {
16
+ nock ( config . esConfig . host )
17
+ . post ( '/_refresh' )
18
+ . reply ( 200 , '[Server] guppy refreshed successfully' ) ;
19
+ } else {
20
+ nock ( config . esConfig . host )
21
+ . post ( '/_refresh' )
22
+ . reply ( 404 , '[Server] guppy _refresh functionality is not enabled' ) ;
23
+ }
14
24
} ;
15
25
16
26
const mockResourcePath = ( ) => {
@@ -35,12 +45,8 @@ const mockResourcePath = () => {
35
45
} ,
36
46
} ,
37
47
highlight : {
38
- pre_tags : [
39
- '<em>' ,
40
- ] ,
41
- post_tags : [
42
- '</em>' ,
43
- ] ,
48
+ pre_tags : [ '<em>' ] ,
49
+ post_tags : [ '</em>' ] ,
44
50
fields : {
45
51
'*.analyzed' : { } ,
46
52
} ,
@@ -111,12 +117,8 @@ const mockResourcePath = () => {
111
117
} ,
112
118
} ,
113
119
highlight : {
114
- pre_tags : [
115
- '<em>' ,
116
- ] ,
117
- post_tags : [
118
- '</em>' ,
119
- ] ,
120
+ pre_tags : [ '<em>' ] ,
121
+ post_tags : [ '</em>' ] ,
120
122
fields : {
121
123
'*.analyzed' : { } ,
122
124
} ,
@@ -172,12 +174,8 @@ const mockResourcePath = () => {
172
174
} ,
173
175
} ,
174
176
highlight : {
175
- pre_tags : [
176
- '<em>' ,
177
- ] ,
178
- post_tags : [
179
- '</em>' ,
180
- ] ,
177
+ pre_tags : [ '<em>' ] ,
178
+ post_tags : [ '</em>' ] ,
181
179
fields : {
182
180
'*.analyzed' : { } ,
183
181
} ,
@@ -212,7 +210,8 @@ const mockArborist = () => {
212
210
. persist ( )
213
211
. post ( '/auth/mapping' )
214
212
. reply ( 200 , {
215
- 'internal-project-1' : [ // accessible
213
+ 'internal-project-1' : [
214
+ // accessible
216
215
{
217
216
service : '*' ,
218
217
method : 'create' ,
@@ -234,13 +233,15 @@ const mockArborist = () => {
234
233
method : 'update' ,
235
234
} ,
236
235
] ,
237
- 'internal-project-2' : [ // accessible
236
+ 'internal-project-2' : [
237
+ // accessible
238
238
{
239
239
service : '*' ,
240
240
method : 'read' ,
241
241
} ,
242
242
] ,
243
- 'internal-project-3' : [ // not accessible since method does not match
243
+ 'internal-project-3' : [
244
+ // not accessible since method does not match
244
245
{
245
246
service : '*' ,
246
247
method : 'create' ,
@@ -258,19 +259,22 @@ const mockArborist = () => {
258
259
method : 'update' ,
259
260
} ,
260
261
] ,
261
- 'internal-project-4' : [ // accessible
262
+ 'internal-project-4' : [
263
+ // accessible
262
264
{
263
265
service : '*' ,
264
266
method : '*' ,
265
267
} ,
266
268
] ,
267
- 'internal-project-5' : [ // accessible
269
+ 'internal-project-5' : [
270
+ // accessible
268
271
{
269
272
service : 'guppy' ,
270
273
method : '*' ,
271
274
} ,
272
275
] ,
273
- 'internal-project-6' : [ // not accessible since service does not match
276
+ 'internal-project-6' : [
277
+ // not accessible since service does not match
274
278
{
275
279
service : 'indexd' ,
276
280
method : '*' ,
@@ -376,7 +380,9 @@ const mockESMapping = () => {
376
380
} ;
377
381
378
382
const mockArrayConfig = ( ) => {
379
- const arrayConfigQuery = { query : { ids : { values : [ 'gen3-dev-subject' , 'gen3-dev-file' ] } } } ;
383
+ const arrayConfigQuery = {
384
+ query : { ids : { values : [ 'gen3-dev-subject' , 'gen3-dev-file' ] } } ,
385
+ } ;
380
386
const fakeArrayConfig = {
381
387
hits : {
382
388
total : 1 ,
@@ -387,10 +393,7 @@ const mockArrayConfig = () => {
387
393
_id : 'gen3-dev-subject' ,
388
394
_score : 1.0 ,
389
395
_source : {
390
- array : [
391
- 'some_array_integer_field' ,
392
- 'some_array_string_field' ,
393
- ] ,
396
+ array : [ 'some_array_integer_field' , 'some_array_string_field' ] ,
394
397
} ,
395
398
} ,
396
399
] ,
@@ -405,6 +408,7 @@ const mockArrayConfig = () => {
405
408
const setup = ( ) => {
406
409
mockArborist ( ) ;
407
410
mockPing ( ) ;
411
+ mockRefresh ( ) ;
408
412
mockResourcePath ( ) ;
409
413
mockESMapping ( ) ;
410
414
mockArrayConfig ( ) ;
0 commit comments