mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-20 13:33:48 +00:00
Do not save OAS example response if it is over the limit. SpecGen.MaxExampleLen is measured in bytes. Limit=0 means "don't record any examples", while limit=-1 means "record all". Limit is configured via the config file / --set: --set oas.max-example-len=100. The default is 10KB. This PR breaks the previous config. Moved oas bool (enable/disable OAS) to oas.enable. Users who wish to disable OAS (or to explicitly enable it) should now to so with --set oas.enable=false instead of --set oas=false. Co-authored-by: Nimrod Gilboa Markevich <nimrod@up9.com> Co-authored-by: Nimrod Gilboa Markevich <59927337+nimrod-up9@users.noreply.github.com>
46 lines
824 B
Go
46 lines
824 B
Go
package oas
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/up9inc/mizu/agent/pkg/har"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestOASGen(t *testing.T) {
|
|
gen := GetDefaultOasGeneratorInstance(-1)
|
|
|
|
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.Start()
|
|
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))
|
|
|
|
if !gen.IsStarted() {
|
|
t.Errorf("Should be started")
|
|
}
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
gen.Stop()
|
|
}
|