mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-24 19:47:38 +00:00
OAS: rework data feeding + sampleIDs (#917)
* Call OAS feeder * Don't call old OAS code * Rework calls * Work on it * Put back rules * Make it compile * start thinking of test * Compiles * Save * Fixes * Save * Fixing * Trying to fake conn * add timeout * Test timeout * Fix tests * Only build OAS for HTTP entries * Remove some dead code * Adding SampleIDs * Cosmetics * lint * Revert rename * Sample ID for content * Cleanuo * Add more sample IDs * Checking hypothesis * Move assignment place a bit * Cosmetics * Update test.yml Co-authored-by: undera <undera@undera-old-desktop.home> Co-authored-by: Igor Gov <iggvrv@gmail.com>
This commit is contained in:
36
agent/pkg/oas/oas_generator_test.go
Normal file
36
agent/pkg/oas/oas_generator_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package oas
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/up9inc/mizu/agent/pkg/har"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOASGen(t *testing.T) {
|
||||
gen := new(defaultOasGenerator)
|
||||
gen.serviceSpecs = &sync.Map{}
|
||||
|
||||
e := new(har.Entry)
|
||||
err := json.Unmarshal([]byte(`{"startedDateTime": "20000101","request": {"url": "https://host/path", "method": "GET"}, "response": {"status": 200}}`), e)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ews := &EntryWithSource{
|
||||
Destination: "some",
|
||||
Entry: *e,
|
||||
}
|
||||
gen.handleHARWithSource(ews)
|
||||
g, ok := gen.serviceSpecs.Load("some")
|
||||
if !ok {
|
||||
panic("Failed")
|
||||
}
|
||||
sg := g.(*SpecGen)
|
||||
spec, err := sg.GetSpec()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
specText, _ := json.Marshal(spec)
|
||||
t.Log(string(specText))
|
||||
}
|
Reference in New Issue
Block a user