diff --git a/agent/pkg/oas/specgen_test.go b/agent/pkg/oas/specgen_test.go index f00cbb41c..5077b2910 100644 --- a/agent/pkg/oas/specgen_test.go +++ b/agent/pkg/oas/specgen_test.go @@ -124,7 +124,8 @@ func TestEntries(t *testing.T) { func TestFileSingle(t *testing.T) { GetOasGeneratorInstance().Start() GetOasGeneratorInstance().Reset() - // loadStartingOAS() + loadStartingOAS("test_artifacts/httpbin.org.json", "httpbin.org") + file := "test_artifacts/params.har" files := []string{file} cnt, err := feedEntries(files, true) diff --git a/agent/pkg/oas/test_artifacts/httpbin.org.json b/agent/pkg/oas/test_artifacts/httpbin.org.json new file mode 100644 index 000000000..5e2295618 --- /dev/null +++ b/agent/pkg/oas/test_artifacts/httpbin.org.json @@ -0,0 +1,54 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Preloaded https://httpbin.org", + "version": "0.0" + }, + "servers": [ + { + "url": "https://httpbin.org" + } + ], + "paths": { + "/param-patterns/{parampatternId}/{num}": { + "parameters": [ + { + "name": "parampatternId", + "in": "path", + "required": true, + "style": "simple", + "schema": { + "type": "string" + }, + "examples": { + "example #0": { + "value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r" + }, + "example #1": { + "value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf" + }, + "example #2": { + "value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45" + }, + "example #3": { + "value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k" + }, + "example #4": { + "value": "prefix-gibberish-afterwards" + } + } + }, + { + "name": "num", + "in": "path", + "required": true, + "style": "simple", + "schema": { + "type": "string", + "pattern": "\\d+" + } + } + ] + } + } +} \ No newline at end of file diff --git a/agent/pkg/oas/test_artifacts/params.har.spec.json b/agent/pkg/oas/test_artifacts/params.har.spec.json index 533ad5720..b1f558de5 100644 --- a/agent/pkg/oas/test_artifacts/params.har.spec.json +++ b/agent/pkg/oas/test_artifacts/params.har.spec.json @@ -1,9 +1,9 @@ { "openapi": "3.1.0", "info": { - "title": "https://httpbin.org", + "title": "Preloaded https://httpbin.org", "description": "Mizu observed 18 entries (0 failed), at 0.11 hits/s, average response time is 0.18 seconds", - "version": "1.0" + "version": "0.0" }, "servers": [ { @@ -386,73 +386,6 @@ } ] }, - "/param-patterns/{parampatternId}/1": { - "get": { - "tags": [ - "param-patterns" - ], - "summary": "/param-patterns/{parampatternId}/1", - "description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds", - "operationId": "", - "responses": { - "200": { - "description": "Successful call with status 200", - "content": { - "": {} - } - } - }, - "x-counters-per-source": { - "": { - "entries": 1, - "failures": 0, - "firstSeen": 1567750582.00, - "lastSeen": 1567750582.00, - "sumRT": 0.00, - "sumDuration": 0 - } - }, - "x-counters-total": { - "entries": 1, - "failures": 0, - "firstSeen": 1567750582.00, - "lastSeen": 1567750582.00, - "sumRT": 0.00, - "sumDuration": 0 - }, - "x-last-seen-ts": 1567750582.00, - "x-sample-entry": 0 - }, - "parameters": [ - { - "name": "parampatternId", - "in": "path", - "required": true, - "style": "simple", - "schema": { - "type": "string", - "pattern": "^prefix-gibberish-.+" - }, - "examples": { - "example #0": { - "value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r" - }, - "example #1": { - "value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf" - }, - "example #2": { - "value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45" - }, - "example #3": { - "value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k" - }, - "example #4": { - "value": "prefix-gibberish-afterwards" - } - } - } - ] - }, "/param-patterns/{parampatternId}/static": { "get": { "tags": [ @@ -520,13 +453,13 @@ } ] }, - "/param-patterns/{parampatternId}/{param1}": { + "/param-patterns/{parampatternId}/{num}": { "get": { "tags": [ "param-patterns" ], - "summary": "/param-patterns/{parampatternId}/{param1}", - "description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds", + "summary": "/param-patterns/{parampatternId}/{num}", + "description": "Mizu observed 2 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds", "operationId": "", "responses": { "200": { @@ -538,40 +471,26 @@ }, "x-counters-per-source": { "": { - "entries": 1, + "entries": 2, "failures": 0, "firstSeen": 1567750582.00, "lastSeen": 1567750582.00, "sumRT": 0.00, - "sumDuration": 0 + "sumDuration": 9.53e-7 } }, "x-counters-total": { - "entries": 1, + "entries": 2, "failures": 0, "firstSeen": 1567750582.00, "lastSeen": 1567750582.00, "sumRT": 0.00, - "sumDuration": 0 + "sumDuration": 9.53e-7 }, "x-last-seen-ts": 1567750582.00, "x-sample-entry": 0 }, "parameters": [ - { - "name": "param1", - "in": "path", - "required": true, - "style": "simple", - "schema": { - "type": "string" - }, - "examples": { - "example #0": { - "value": "23421" - } - } - }, { "name": "parampatternId", "in": "path", @@ -598,6 +517,24 @@ "value": "prefix-gibberish-afterwards" } } + }, + { + "name": "num", + "in": "path", + "required": true, + "style": "simple", + "schema": { + "type": "string", + "pattern": "\\d+" + }, + "examples": { + "example #0": { + "value": "1" + }, + "example #1": { + "value": "23421" + } + } } ] },