Fix postman import and import Insomnia gRPC

This commit is contained in:
Gregory Schier
2024-03-18 08:18:04 -07:00
parent e47c2513a8
commit 8afe0c0755
12 changed files with 1861 additions and 83 deletions

View File

@@ -0,0 +1,164 @@
{
"info": {
"_postman_id": "9e6dfada-256c-49ea-a38f-7d1b05b7ca2d",
"name": "New Collection",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
"_exporter_id": "18798"
},
"item": [
{
"name": "New Folder",
"item": [
{
"name": "FOlder 2",
"item": [
{
"name": "Basic Auth",
"request": {
"auth": {
"type": "basic",
"basic": {
"password": "pass",
"username": "user"
}
},
"method": "GET",
"header": [],
"url": "https://schier.co"
},
"response": []
}
]
},
{
"name": "Form Data",
"request": {
"method": "POST",
"header": [
{
"key": "X-foo",
"value": "bar",
"description": "description",
"type": "text"
},
{
"key": "Disabled",
"value": "tnroant",
"description": "ntisorantosra",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "Form",
"value": "Value",
"description": "descirption",
"type": "text"
},
{
"key": "Disabled",
"value": "foo",
"description": "bar",
"type": "text",
"disabled": true
},
{
"key": "file",
"type": "file",
"src": "/Users/gschier/Desktop/foo.json"
},
{
"key": "Rendered",
"value": "{{Foo}}",
"type": "text"
}
]
},
"url": {
"raw": "schier.co?firstkey=firstvalue&hi=there",
"host": [
"schier",
"co"
],
"query": [
{
"key": "disabled",
"value": "secondvalue",
"description": "this is disabled",
"disabled": true
},
{
"key": "firstkey",
"value": "firstvalue"
},
{
"key": "hi",
"value": "there"
}
]
}
},
"response": []
}
]
},
{
"name": "Form URL",
"request": {
"method": "POST",
"header": [
{
"key": "X-foo",
"value": "bar",
"description": "description",
"type": "text"
},
{
"key": "Disabled",
"value": "tnroant",
"description": "ntisorantosra",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "foo",
"value": "bar",
"type": "text"
}
]
},
"url": {
"raw": "schier.co?firstkey=firstvalue&hi=there",
"host": [
"schier",
"co"
],
"query": [
{
"key": "disabled",
"value": "secondvalue",
"description": "this is disabled",
"disabled": true
},
{
"key": "firstkey",
"value": "firstvalue"
},
{
"key": "hi",
"value": "there"
}
]
}
},
"response": []
}
]
}

View File

@@ -0,0 +1,35 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { expect, test, describe, beforeEach, afterEach, vi } from 'vitest';
import { pluginHookImport } from '../src';
let originalRandom = Math.random;
describe('importer-postman', () => {
beforeEach(() => {
let i = 0;
const mocked = vi.fn(() => ((i++ * 1000) % 133) / 100);
Math.random = mocked;
});
afterEach(() => {
Math.random = originalRandom;
});
const p = path.join(__dirname, 'fixtures');
const fixtures = fs.readdirSync(p);
console.log('FIXTURES', fixtures);
for (const fixture of fixtures) {
test('Imports ' + fixture, () => {
const contents = fs.readFileSync(path.join(p, fixture), 'utf-8');
const imported = pluginHookImport(contents);
expect(imported).toEqual({
resources: {
environments: [],
requests: [],
},
});
});
}
});