write oa3 spec for smoke test server, update inso-nedb fixture to include a spec so we can lint and generate config with it, add readme for how to update it

This commit is contained in:
Opender Singh
2021-09-30 14:41:34 +13:00
parent 1d7f08b10d
commit 8ea57f3f4d
18 changed files with 164 additions and 10 deletions

21
packages/insomnia-smoke-test/.gitignore vendored Normal file
View File

@@ -0,0 +1,21 @@
# ignore the response/unit test result files from the nedb fixture used by inso
fixtures/inso-nedb/insomnia.RequestVersion.db
fixtures/inso-nedb/insomnia.Response.db
fixtures/inso-nedb/insomnia.UnitTestResult.db
# ignore the metadata files that are not used by inso
fixtures/inso-nedb/insomnia.*Meta.db
# ignore the stats db file
fixtures/inso-nedb/insomnia.Stats.db
# ignore the settings db file because inso shouldn't use it
fixtures/inso-nedb/insomnia.Settings.db
# ignore some db files for security reasons
fixtures/inso-nedb/insomnia.ClientCertificate.db
fixtures/inso-nedb/insomnia.CookieJar.db
fixtures/inso-nedb/insomnia.GitRepository.db
fixtures/inso-nedb/insomnia.OAuth2Token.db
fixtures/inso-nedb/insomnia.PluginData.db

View File

@@ -20,13 +20,12 @@ describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath
describe('run test', () => {
it('should not fail running tests', () => {
const { failed } = inso(
'run',
'test',
['--src', 'fixtures/inso-nedb'],
['--env', 'Dev'],
'TestSuite',
'Echo Test Suite',
);
expect(failed).toBe(false);

View File

@@ -0,0 +1,19 @@
# How to update the inso-nedb fixture
In order to update the inso-nedb fixutre you need to launch Insomnia using the inso-nedb directory. To do this, set the INSOMNIA_DATA_PATH environment variable and launch from the command line.
## MacOS
```bash
INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia
```
## Linux
TODO
## Windows
TODO
After making your changes, be sure to relaunch the app one more time from the command line, so that Insomnia compacts the database. The .gitignore file will explicity ignore certain database files, to keep the directory size down and avoid prevent data leakage in case you are signed in to the app when launching with this database.

View File

@@ -1 +1 @@
{"_id":"spc_3703e60a16684b0ba1fabe734fbff005","type":"ApiSpec","parentId":"wrk_41a42f72882a483ba2bc92c908ac27a9","modified":1607311761330,"created":1607311536124,"fileName":"Document","contents":"","contentType":"yaml"}
{"_id":"spc_8d15c4d0364e4c3a8604e1a155e0771d","type":"ApiSpec","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632964915257,"created":1632962830813,"fileName":"Smoke Test API server 1.0.0","contents":"openapi: 3.0.0\ninfo:\n title: Smoke Test API server\n version: 1.0.0\nservers:\n - url: http://localhost:1234\ntags:\n - name: Misc\n - name: Auth\n - name: File\npaths:\n /pets/{id}:\n get:\n operationId: echoId\n summary: Echo id\n parameters:\n - name: id\n in: path\n schema:\n type: string\n required: true\n tags:\n - Misc\n responses:\n '200':\n description: A JSON object containing the id\n content:\n application/json:\n schema: \n type: object\n properties:\n id:\n type: string\n /file/dummy.csv:\n get:\n operationId: dummyCsvFile\n summary: Get dummy CSV file\n tags:\n - File\n responses:\n '200':\n description: loaded dummy csv file\n content:\n application/csv:\n schema:\n $ref: '#/components/schemas/File'\n /file/dummy.pdf:\n get:\n operationId: dummyPdfFile\n summary: Get dummy PDF file\n tags:\n - File\n responses:\n '200':\n description: loaded dummy CSV file\n content:\n application/pdf:\n schema:\n $ref: '#/components/schemas/File'\n /auth/basic:\n get:\n operationId: basicAuth\n summary: Make basic auth request\n security:\n - basicAuth: []\n tags:\n - Auth\n responses:\n '200':\n description: successfully authed\n content:\n text/plain:\n schema:\n $ref: '#/components/schemas/String'\n /delay/seconds/{duration}:\n get:\n operationId: delayByDuration\n summary: Delay by seconds\n parameters:\n - name: duration\n in: path\n schema:\n type: integer\n required: true\n tags:\n - Misc\n responses:\n '200':\n description: delayed\n content:\n text/plain:\n schema:\n $ref: '#/components/schemas/String'\ncomponents:\n schemas:\n File:\n type: string\n format: binary\n String:\n type: string\n securitySchemes:\n basicAuth:\n type: http\n scheme: basic\n ","contentType":"yaml"}

View File

@@ -1,2 +1,3 @@
{"_id":"env_28ef07475f8a3c570164d300b54834d4210556df","type":"Environment","parentId":"wrk_41a42f72882a483ba2bc92c908ac27a9","modified":1607312114703,"created":1607311536150,"name":"Base Environment","data":{"base_url":""},"dataPropertyOrder":{"&":["base_url"]},"color":null,"isPrivate":false,"metaSortKey":1607311536150}
{"_id":"env_baf32bd57d0e45f38e3914e51d2f0c29","type":"Environment","parentId":"env_28ef07475f8a3c570164d300b54834d4210556df","modified":1607312133614,"created":1607312095708,"name":"Dev","data":{"base_url":"http://localhost:4010"},"dataPropertyOrder":{"&":["base_url"]},"color":null,"isPrivate":false,"metaSortKey":1607312095708}
{"_id":"env_88524a9f0e6f44378a1599f7014d1aa3","type":"Environment","parentId":"env_abe7c3674891e7e3a2a3d6c88a238694fc8c64dc","modified":1632964852494,"created":1632964848994,"name":"Dev","data":{"scheme":"http","base_path":"","host":"localhost:4010","httpUsername":"username","httpPassword":"password"},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1632964774282}
{"_id":"env_abe7c3674891e7e3a2a3d6c88a238694fc8c64dc","type":"Environment","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632962829717,"created":1632962829715,"name":"Base environment","data":{"base_url":"{{ scheme }}://{{ host }}{{ base_path }}"},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1632962829715}
{"_id":"env_env_abe7c3674891e7e3a2a3d6c88a238694fc8c64dc_sub","type":"Environment","parentId":"env_abe7c3674891e7e3a2a3d6c88a238694fc8c64dc","modified":1632964874228,"created":1632964774232,"name":"OpenAPI env","data":{"scheme":"http","base_path":"","host":"localhost:1234","httpUsername":"username","httpPassword":"password"},"dataPropertyOrder":{"&":["scheme","base_path","host","httpUsername","httpPassword"]},"color":null,"isPrivate":false,"metaSortKey":1632964774232}

View File

@@ -0,0 +1 @@
{"_id":"proj_default-project","type":"Project","parentId":null,"modified":1632962424971,"created":1632962424971,"name":"Insomnia","remoteId":null}

View File

@@ -1 +1,6 @@
{"_id":"req_5a77fa051cae441783d6e20a364a60f7","type":"Request","parentId":"wrk_41a42f72882a483ba2bc92c908ac27a9","modified":1607311796833,"created":1607311548694,"url":"{{ _.base_url }}/pets/1","name":"My Request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1607311548694,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_f2cd394aad83485c8f7bee1b612165d5","type":"Request","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632964798467,"created":1632964791930,"url":"{{ base_url }}/pets/1234","name":"Echo ID 1234","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1632964774178,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_wrk_6bd09cdcf3c543829315b479f359ae480ce31489","type":"Request","parentId":"fld_wrk_6bd09cdcf3c543829315b479f359ae4835d0f5fb","modified":1632964774223,"created":1632964774223,"url":"{{ base_url }}/auth/basic","name":"Make basic auth request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{"type":"basic","username":"{{ httpUsername }}","password":"{{ httpPassword }}"},"metaSortKey":-1632964774223,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_wrk_6bd09cdcf3c543829315b479f359ae4845608a40","type":"Request","parentId":"fld_wrk_6bd09cdcf3c543829315b479f359ae482c3cafa4","modified":1632964774225,"created":1632964774225,"url":"{{ base_url }}/file/dummy.csv","name":"Get dummy CSV file","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1632964774225,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_wrk_6bd09cdcf3c543829315b479f359ae48773f3890","type":"Request","parentId":"fld_wrk_6bd09cdcf3c543829315b479f359ae480a893ece","modified":1632964774220,"created":1632964774220,"url":"{{ base_url }}/delay/seconds/{{ duration }}","name":"Delay by seconds","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1632964774220,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_wrk_6bd09cdcf3c543829315b479f359ae489a993792","type":"Request","parentId":"fld_wrk_6bd09cdcf3c543829315b479f359ae480a893ece","modified":1632964774227,"created":1632964774227,"url":"{{ base_url }}/pets/{{ id }}","name":"Echo id","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1632964774227,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}
{"_id":"req_wrk_6bd09cdcf3c543829315b479f359ae48da748d12","type":"Request","parentId":"fld_wrk_6bd09cdcf3c543829315b479f359ae482c3cafa4","modified":1632964774224,"created":1632964774224,"url":"{{ base_url }}/file/dummy.pdf","name":"Get dummy PDF file","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1632964774224,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global"}

View File

@@ -0,0 +1,3 @@
{"_id":"fld_wrk_6bd09cdcf3c543829315b479f359ae480a893ece","type":"RequestGroup","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632964774231,"created":1632964774231,"name":"Misc","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1632964774231}
{"_id":"fld_wrk_6bd09cdcf3c543829315b479f359ae482c3cafa4","type":"RequestGroup","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632964774228,"created":1632964774228,"name":"File","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1632964774228}
{"_id":"fld_wrk_6bd09cdcf3c543829315b479f359ae4835d0f5fb","type":"RequestGroup","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632964774230,"created":1632964774230,"name":"Auth","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1632964774230}

View File

@@ -1 +1 @@
{"_id":"ut_d9e46e1fae344232991d1724124480ee","type":"UnitTest","parentId":"uts_db079ef8d1a74a7da6158175ebd89b00","modified":1607311749442,"created":1607311745076,"requestId":"req_5a77fa051cae441783d6e20a364a60f7","name":"Returns 200","code":"const response = await insomnia.send();\nexpect(response.status).to.equal(200);\nexpect(JSON.parse(response.data).id).to.equal('1')"}
{"_id":"ut_babcaf85ec1b481ebed1e1cd1aa61a75","type":"UnitTest","parentId":"uts_b12681ace8eb4e5999b5b51677c4c269","modified":1632964811893,"created":1632962936043,"requestId":"req_f2cd394aad83485c8f7bee1b612165d5","name":"Returns 200","code":"const response1 = await insomnia.send();\nexpect(response1.status).to.equal(200);"}

View File

@@ -1 +1 @@
{"_id":"uts_db079ef8d1a74a7da6158175ebd89b00","type":"UnitTestSuite","parentId":"wrk_41a42f72882a483ba2bc92c908ac27a9","modified":1607311564521,"created":1607311564521,"name":"TestSuite"}
{"_id":"uts_b12681ace8eb4e5999b5b51677c4c269","type":"UnitTestSuite","parentId":"wrk_6bd09cdcf3c543829315b479f359ae48","modified":1632962932579,"created":1632962924332,"name":"Echo Test Suite"}

View File

@@ -1 +1 @@
{"_id":"wrk_41a42f72882a483ba2bc92c908ac27a9","type":"Workspace","parentId":null,"modified":1607311536124,"created":1607311536124,"name":"Insomnia Designer","description":"","scope":"spec"}
{"_id":"wrk_6bd09cdcf3c543829315b479f359ae48","type":"Workspace","parentId":"proj_default-project","modified":1632962830812,"created":1632962830812,"name":"Smoke Test API server 1.0.0","description":"","scope":"design"}

View File

@@ -0,0 +1,105 @@
openapi: 3.0.0
info:
title: Smoke Test API server
version: 1.0.0
servers:
- url: http://localhost:4010
tags:
- name: Misc
- name: Auth
- name: File
paths:
/pets/{id}:
get:
operationId: echoId
summary: Echo id
parameters:
- name: id
in: path
schema:
type: string
required: true
tags:
- Misc
responses:
'200':
description: A JSON object containing the id
content:
application/json:
schema:
type: object
properties:
id:
type: string
/file/dummy.csv:
get:
operationId: dummyCsvFile
summary: Get dummy CSV file
tags:
- File
responses:
'200':
description: loaded dummy csv file
content:
application/csv:
schema:
$ref: '#/components/schemas/File'
/file/dummy.pdf:
get:
operationId: dummyPdfFile
summary: Get dummy PDF file
tags:
- File
responses:
'200':
description: loaded dummy CSV file
content:
application/pdf:
schema:
$ref: '#/components/schemas/File'
/auth/basic:
get:
operationId: basicAuth
summary: Make basic auth request
security:
- basicAuth: []
tags:
- Auth
responses:
'200':
description: successfully authed
content:
text/plain:
schema:
$ref: '#/components/schemas/String'
/delay/seconds/{duration}:
get:
operationId: delayByDuration
summary: Delay by seconds
parameters:
- name: duration
in: path
schema:
type: integer
required: true
tags:
- Misc
responses:
'200':
description: delayed
content:
text/plain:
schema:
$ref: '#/components/schemas/String'
components:
schemas:
File:
type: string
format: binary
String:
type: string
securitySchemes:
basicAuth:
type: http
scheme: basic

View File

@@ -16,7 +16,7 @@ app.get('/pets/:id', (req, res) => {
res.status(200).send({ id: req.params.id });
});
app.use('/file', express.static('fixtures'));
app.use('/file', express.static('fixtures/files'));
const { utf8, latin1 } = basicAuthCreds;