Repository navigation
Expand file tree
/
Copy pathfind_component_test.go
More file actions
704 lines (555 loc) · 18.1 KB
/
Copy pathfind_component_test.go
File metadata and controls
704 lines (555 loc) · 18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package index
import (
"bytes"
"context"
"io/fs"
"log/slog"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/pb33f/testify/assert"
"go.yaml.in/yaml/v4"
)
func TestSpecIndex_performExternalLookup(t *testing.T) {
yml := `{
"openapi": "3.1.0",
"paths": [
{"/": {
"get": {}
}}
]
}`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(yml), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
assert.Len(t, index.GetPathsNode().Content, 1)
}
func TestSpecIndex_CheckCircularIndex(t *testing.T) {
cFile := "../test_specs/first.yaml"
yml, _ := os.ReadFile(cFile)
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(yml), &rootNode)
cf := CreateOpenAPIIndexConfig()
cf.AvoidCircularReferenceCheck = true
cf.BasePath = "../test_specs"
rolo := NewRolodex(cf)
rolo.SetRootNode(&rootNode)
cf.Rolodex = rolo
fsCfg := LocalFSConfig{
BaseDirectory: cf.BasePath,
FileFilters: []string{"first.yaml", "second.yaml", "third.yaml", "fourth.yaml"},
DirFS: os.DirFS(cf.BasePath),
}
fileFS, err := NewLocalFSWithConfig(&fsCfg)
assert.NoError(t, err)
rolo.AddLocalFS(cf.BasePath, fileFS)
indexedErr := rolo.IndexTheRolodex(context.Background())
rolo.BuildIndexes()
assert.NoError(t, indexedErr)
index := rolo.GetRootIndex()
assert.Nil(t, index.uri)
a, _ := index.SearchIndexForReference("second.yaml#/properties/property2")
b, _ := index.SearchIndexForReference("second.yaml")
c, _ := index.SearchIndexForReference("fourth.yaml")
assert.NotNil(t, a)
assert.NotNil(t, b)
assert.Nil(t, c)
}
func TestSpecIndex_CheckCircularIndex_NoDirFS(t *testing.T) {
cFile := "../test_specs/first.yaml"
yml, _ := os.ReadFile(cFile)
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(yml), &rootNode)
cf := CreateOpenAPIIndexConfig()
cf.AvoidCircularReferenceCheck = true
cf.BasePath = "../test_specs"
rolo := NewRolodex(cf)
rolo.SetRootNode(&rootNode)
cf.Rolodex = rolo
fsCfg := LocalFSConfig{
BaseDirectory: cf.BasePath,
IndexConfig: cf,
}
fileFS, err := NewLocalFSWithConfig(&fsCfg)
assert.NoError(t, err)
rolo.AddLocalFS(cf.BasePath, fileFS)
indexedErr := rolo.IndexTheRolodex(context.Background())
rolo.BuildIndexes()
assert.NoError(t, indexedErr)
index := rolo.GetRootIndex()
assert.Nil(t, index.uri)
a, _ := index.SearchIndexForReference("second.yaml#/properties/property2")
b, _ := index.SearchIndexForReference("second.yaml")
c, _ := index.SearchIndexForReference("fourth.yaml")
assert.NotNil(t, a)
assert.NotNil(t, b)
assert.Nil(t, c)
}
func TestFindComponent_RolodexFileParseError_Recovery(t *testing.T) {
badData := "I cannot be parsed: \"I am not a YAML file or a JSON file"
_ = os.WriteFile("bad.yaml", []byte(badData), 0o644)
defer os.Remove("bad.yaml")
badRef := `openapi: 3.1.0
components:
schemas:
thing:
type: object
properties:
thong:
$ref: 'bad.yaml'
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(badRef), &rootNode)
cf := CreateOpenAPIIndexConfig()
cf.AvoidCircularReferenceCheck = true
cf.BasePath = "."
rolo := NewRolodex(cf)
rolo.SetRootNode(&rootNode)
cf.Rolodex = rolo
fsCfg := LocalFSConfig{
BaseDirectory: cf.BasePath,
FileFilters: []string{"bad.yaml"},
DirFS: os.DirFS(cf.BasePath),
}
fileFS, err := NewLocalFSWithConfig(&fsCfg)
assert.NoError(t, err)
rolo.AddLocalFS(cf.BasePath, fileFS)
indexedErr := rolo.IndexTheRolodex(context.Background())
rolo.BuildIndexes()
// should no longer error
assert.NoError(t, indexedErr)
index := rolo.GetRootIndex()
assert.Nil(t, index.uri)
// can still be found.
a, _ := index.SearchIndexForReference("bad.yaml")
assert.NotNil(t, a)
}
func TestSpecIndex_performExternalLookup_invalidURL(t *testing.T) {
yml := `openapi: 3.1.0
components:
schemas:
thing:
properties:
thong:
$ref: 'httpssss://not-gonna-work.com'`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(yml), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
assert.Len(t, index.GetReferenceIndexErrors(), 1)
}
func TestSpecIndex_FindComponentInRoot(t *testing.T) {
yml := `openapi: 3.1.0
components:
schemas:
thing:
properties:
thong: hi!`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(yml), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
thing := index.FindComponentInRoot(context.Background(), "#/$splish/$.../slash#$///./")
assert.Nil(t, thing)
assert.Len(t, index.GetReferenceIndexErrors(), 0)
}
func TestSpecIndex_FailFindComponentInRoot(t *testing.T) {
index := NewTestSpecIndex().Load().(*SpecIndex)
assert.Nil(t, index.FindComponentInRoot(context.Background(), "does it even matter? of course not. no"))
}
func TestSpecIndex_LocateRemoteDocsWithRemoteURLHandler(t *testing.T) {
requireNetworkTests(t)
// This test will push the index to do try and locate remote references that use relative references
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
paths:
/test:
get:
parameters:
- $ref: "https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
// create a new config that allows remote lookups.
cf := &SpecIndexConfig{}
cf.AllowRemoteLookup = true
cf.AvoidCircularReferenceCheck = true
// create a new rolodex
rolo := NewRolodex(cf)
// set the rolodex root node to the root node of the spec.
rolo.SetRootNode(&rootNode)
// create a new remote fs and set the config for indexing.
remoteFS, _ := NewRemoteFSWithConfig(cf)
// add remote filesystem
rolo.AddRemoteFS("", remoteFS)
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(5*time.Second))
defer cancel()
var idx *SpecIndex
done := make(chan struct{})
go func() {
// index the rolodex.
indexedErr := rolo.IndexTheRolodex(ctx)
assert.NoError(t, indexedErr)
idx = rolo.GetRootIndex()
done <- struct{}{}
}()
complete := false
for !complete {
select {
case <-ctx.Done():
complete = true
break
case <-done:
crsParam := idx.GetMappedReferences()["https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"]
assert.NotNil(t, crsParam)
assert.True(t, crsParam.IsRemote)
assert.Equal(t, "crs", crsParam.Node.Content[1].Value)
assert.Equal(t, "query", crsParam.Node.Content[3].Value)
assert.Equal(t, "form", crsParam.Node.Content[9].Value)
complete = true
}
}
// extract crs param from index
}
func TestSpecIndex_LocateRemoteDocsWithMalformedEscapedCharacters(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
paths:
/test:
get:
parameters:
- $ref: "https://petstore3.swagger.io/api/v3/openapi.yaml#/paths/~1pet~1%$petId%7D/get/parameters"`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
assert.Len(t, index.GetReferenceIndexErrors(), 1)
assert.Equal(t, "component `#/paths/~1pet~1%$petId%7D/get/parameters` does not exist in the specification", index.GetReferenceIndexErrors()[0].Error())
}
func TestSpecIndex_LocateRemoteDocsWithEscapedCharacters(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
paths:
/test:
get:
parameters:
- $ref: "https://petstore3.swagger.io/api/v3/openapi.yaml#/paths/~1pet~1%7BpetId%7D/get/parameters"`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
assert.Len(t, index.GetReferenceIndexErrors(), 1)
}
func TestFindComponent_LookupRolodex_GrabRoot(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
n := index.lookupRolodex(context.Background(), []string{"bingobango"})
// if the reference is not found, it should return the root.
assert.NotNil(t, n)
}
func TestFindComponentInRoot_GrabDocRoot(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
n := index.FindComponentInRoot(context.Background(), "#/")
// if the reference is not found, it should return the root.
assert.NotNil(t, n)
}
func TestFindComponentInRoot_SimulateWindows(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
n := index.FindComponentInRoot(context.Background(), `C:\windows\you\annoy\me#\components\schemas\thang`)
assert.NotNil(t, n)
}
func TestFindComponent_LookupRolodex_NoURL(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
n := index.lookupRolodex(context.Background(), nil)
// no url, no ref.
assert.Nil(t, n)
}
func TestFindComponent_LookupRolodex_NoRolodex(t *testing.T) {
index := NewTestSpecIndex().Load().(*SpecIndex)
index.rolodex = nil
assert.Nil(t, index.lookupRolodex(context.Background(), []string{"pet.yaml"}))
}
func TestFindComponent_LookupRolodex_MissingWholeFileReturnsNil(t *testing.T) {
cfg := CreateOpenAPIIndexConfig()
rolo := NewRolodex(cfg)
cfg.Rolodex = rolo
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte("openapi: 3.0.2"), &rootNode)
index := NewSpecIndexWithConfig(&rootNode, cfg)
index.rolodex = rolo
assert.Nil(t, index.lookupRolodex(context.Background(), []string{"/tmp/does-not-exist.yaml"}))
}
func TestFindComponent_LookupRolodex_InvalidFile_NoBypass(t *testing.T) {
spec := `i:am : not a yaml file:`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
n := index.lookupRolodex(context.Background(), []string{"bingobango"})
// if the reference is not found, it should return the root.
assert.NotNil(t, n)
}
func TestFindComponent_LookupRolodex_WithSpecAbsolutePath(t *testing.T) {
// Test that triggers line 156: basePath = filepath.Dir(index.specAbsolutePath)
// This happens when:
// 1. A relative file reference is used (not absolute, not http)
// 2. index.specAbsolutePath is set (non-empty)
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object
`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
c.BasePath = "."
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
// Set specAbsolutePath to trigger the branch at line 156
index.specAbsolutePath = "/some/absolute/path/to/spec.yaml"
// Call lookupRolodex with a relative file reference (not absolute, not http)
// This will hit the branch where specAbsolutePath is used to determine basePath
n := index.lookupRolodex(context.Background(), []string{"relative_file.yaml"})
// The file doesn't exist, so it returns nil, but the important thing is
// that we hit the code path at line 156
assert.Nil(t, n)
}
func TestFindComponent_LookupRolodex_FindComponentReturnsNil_DebugLog(t *testing.T) {
// Test that triggers the debug log at lines 241-245 when FindComponent returns nil.
// This happens when a file exists in the rolodex but the queried component doesn't exist.
// Create a valid external file with some components
externalContent := `type: object
properties:
name:
type: string
age:
type: integer`
// Write the external file
err := os.WriteFile("external_schema.yaml", []byte(externalContent), 0o644)
assert.NoError(t, err)
defer os.Remove("external_schema.yaml")
// Create main spec that references a non-existent component in the external file
mainSpec := `openapi: 3.1.0
components:
schemas:
MySchema:
$ref: 'external_schema.yaml#/components/schemas/NonExistent'`
var rootNode yaml.Node
err = yaml.Unmarshal([]byte(mainSpec), &rootNode)
assert.NoError(t, err)
// Create a buffer to capture log output
var logBuf bytes.Buffer
logger := slog.New(slog.NewJSONHandler(&logBuf, &slog.HandlerOptions{
Level: slog.LevelDebug,
}))
// Create config with debug logger
cf := CreateOpenAPIIndexConfig()
cf.BasePath = "."
cf.Logger = logger
cf.AvoidCircularReferenceCheck = true
// Create rolodex
rolo := NewRolodex(cf)
rolo.SetRootNode(&rootNode)
cf.Rolodex = rolo
// Add local filesystem
fsCfg := LocalFSConfig{
BaseDirectory: cf.BasePath,
FileFilters: []string{"external_schema.yaml"},
DirFS: os.DirFS(cf.BasePath),
IndexConfig: cf,
}
fileFS, err := NewLocalFSWithConfig(&fsCfg)
assert.NoError(t, err)
rolo.AddLocalFS(cf.BasePath, fileFS)
// Index the rolodex - errors are expected because the component doesn't exist
_ = rolo.IndexTheRolodex(context.Background())
index := rolo.GetRootIndex()
assert.NotNil(t, index)
// The reference to NonExistent should trigger the debug log
// because the file exists but the component path doesn't
logOutput := logBuf.String()
assert.True(t, strings.Contains(logOutput, "[lookupRolodex] FindComponent returned nil"),
"Expected debug log about FindComponent returning nil, got: %s", logOutput)
assert.True(t, strings.Contains(logOutput, "external_schema.yaml"),
"Expected log to contain the file location")
}
func TestLookupRolodex_SkipExternalRefResolution(t *testing.T) {
spec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0
components:
schemas:
thang:
type: object`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(spec), &rootNode)
c := CreateOpenAPIIndexConfig()
c.SkipExternalRefResolution = true
index := NewSpecIndexWithConfig(&rootNode, c)
r := NewRolodex(c)
index.rolodex = r
// lookupRolodex should return nil immediately when SkipExternalRefResolution is set,
// without attempting to open files via the rolodex
n := index.lookupRolodex(context.Background(), []string{"./models/pet.yaml"})
assert.Nil(t, n, "lookupRolodex should return nil when SkipExternalRefResolution is enabled")
// Also test with a remote URL reference
n = index.lookupRolodex(context.Background(), []string{"https://example.com/schemas/pet.yaml"})
assert.Nil(t, n, "lookupRolodex should return nil for remote refs when SkipExternalRefResolution is enabled")
}
func TestFindComponent_LookupRolodex_WholeFileLocalDocument(t *testing.T) {
tempDir := t.TempDir()
filePath := filepath.Join(tempDir, "schema.yaml")
err := os.WriteFile(filePath, []byte("type: object\nproperties:\n name:\n type: string\n"), 0o644)
assert.NoError(t, err)
rootSpec := `openapi: 3.0.2
info:
title: Test
version: 1.0.0`
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(rootSpec), &rootNode)
cfg := CreateOpenAPIIndexConfig()
cfg.BasePath = tempDir
rolo := NewRolodex(cfg)
rolo.SetRootNode(&rootNode)
cfg.Rolodex = rolo
fileFS, fsErr := NewLocalFSWithConfig(&LocalFSConfig{
BaseDirectory: tempDir,
DirFS: os.DirFS(tempDir),
IndexConfig: cfg,
})
assert.NoError(t, fsErr)
rolo.AddLocalFS(tempDir, fileFS)
index := NewSpecIndexWithConfig(&rootNode, cfg)
index.rolodex = rolo
ref := index.lookupRolodex(context.Background(), []string{filePath})
assert.NotNil(t, ref)
assert.Equal(t, "$", ref.Path)
assert.True(t, ref.IsRemote)
assert.Equal(t, filePath, ref.FullDefinition)
}
func TestFindComponent_FastFragmentAndNilRoot(t *testing.T) {
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(`components:
schemas:
Pet:
type: string`), &rootNode)
ref := FindComponent(context.Background(), &rootNode, "#/components/schemas/Pet", "test.yaml", nil)
assert.NotNil(t, ref)
assert.Equal(t, "#/components/schemas/Pet", ref.Definition)
assert.Nil(t, FindComponent(context.Background(), nil, "#/components/schemas/Pet", "test.yaml", nil))
assert.Nil(t, FindComponent(context.Background(), &rootNode, "[", "test.yaml", nil))
}
func TestFindComponent_UnescapesEncodedComponentId(t *testing.T) {
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(`components:
schemas:
thing name:
type: string`), &rootNode)
ref := FindComponent(context.Background(), &rootNode, "#/components/schemas/thing%20name", "test.yaml", nil)
assert.NotNil(t, ref)
assert.Equal(t, "#/components/schemas/thing name", ref.Definition)
assert.Equal(t, "$.components.schemas['thing name']", ref.Path)
}
func TestFindComponent_FallbackRootPointerJSONPath(t *testing.T) {
var rootNode yaml.Node
_ = yaml.Unmarshal([]byte(`openapi: 3.1.0
info:
title: test`), &rootNode)
ref := FindComponent(context.Background(), &rootNode, "", "test.yaml", nil)
assert.NotNil(t, ref)
assert.Equal(t, "$", ref.Path)
assert.Equal(t, "", ref.Definition)
assert.Equal(t, rootNode.Content[0], ref.Node)
}
type emptyRemoteFS struct{}
func (e *emptyRemoteFS) Open(name string) (fs.File, error) {
return &testFile{content: ""}, nil
}
func TestFindComponent_LookupRolodex_NilRolodexFileLogsAndReturnsNil(t *testing.T) {
var logBuf bytes.Buffer
cfg := CreateOpenAPIIndexConfig()
cfg.AllowRemoteLookup = true
cfg.Logger = slog.New(slog.NewTextHandler(&logBuf, nil))
index := NewTestSpecIndex().Load().(*SpecIndex)
index.config = cfg
index.logger = cfg.Logger
rolo := NewRolodex(cfg)
rolo.AddRemoteFS("http://example.com", &emptyRemoteFS{})
index.rolodex = rolo
ref := index.lookupRolodex(context.Background(), []string{"http://example.com/spec.yaml"})
assert.Nil(t, ref)
assert.Contains(t, logBuf.String(), "cannot locate file in the rolodex")
}