forked from stoplightio/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add path * refactor: output is always defined * refactor: remove early return * feat: restore forwarder * feat: restore the forwarder in a better version * test: remove tests we have no idea what we're doing * refactor: use TaskEither.left * refactor: use uritemplate instead of homemade code * refactor: pull shared options in a different file * feat: add proxy basic command * feat: create and handle the upstream option * feat: add logging option * refactor: forward the whole options object * refactor: reorganise create options * refactor: defaults are not needed here anymore * fix: do not need to check for resource presence * fix: let axios handle the host * feat: types and stuff * refactor: log option is effectively shareable * feat: add types * feat: export router and mocker errors * feat: print out responses * test: fix * refactor: use the promise for intermediate handler * fix: correctly stringify the validation errors * docs: add * refactor: ignore server and documents * refactor: output violation * docs: add * refactor: it's a document, not a spec * Apply suggestions from code review Co-Authored-By: Phil Sturgeon <[email protected]> * docs: checkbox * chore: depdendenceis are good enough * chore: package upgrade * style: less code * refactor: prefer single statement returns * refactor: changes * refactor: log in client does not make any sense * refactor: security directory * chore: content negotiation directory * chore: default responses directory * test: add * chore: better print * fix: do not use resolve for remote resources * docs: changelog * test: rename file * test: generalize command * refactor: always return a Promise * refactor: simplify TypeScript's job * test: expand for proxy command as well * test: remove todo * refactor: remove default template params * test: change text * refactor: share object * test: add * Update docs/guides/cli.md Co-Authored-By: lag-of-death <[email protected]> * chore: move dist upstair * Update packages/http/src/mocker/generator/__tests__/HttpParamGenerator.spec.ts * Update docs/guides/cli.md Co-Authored-By: lag-of-death <[email protected]> * feat: replace with node-fetch * chore: move prettier rc out * docs: clarify changelog line * chore: update sample urls * test: fix * style: eslint prettier fixes * chore: add docs on the limitations * Apply suggestions from code review Co-Authored-By: Karol Maciaszek <[email protected]> * test: no mock is needed * feat: passthrough for proxy if payload is string * fix: use all fields * test: add port test * test: run httpbin container * feat: add support for * test: add passthrough html * test: add header validation * docs: add limitation * refator: move operation parsing in internal functions * test: update * Apply suggestions from code review Co-Authored-By: Karol Maciaszek <[email protected]> * fix: address comments * refactor: convert with async/await * refactor: sl-validation * chore: axios is no longer required * fix: add dependency * docs: contributing and proxy tweaks * Update packages/cli/src/commands/proxy.ts Co-Authored-By: Phil Sturgeon <[email protected]> * Update docs/guides/cli.md Co-Authored-By: Phil Sturgeon <[email protected]> * chore: restore * refactor: simplify replace expression * refactor: use standard warning header * refactor: messages only in header error * refactor: httpBody and reportViolations param name * refactor: use implicit async * Update docs/guides/cli.md Co-Authored-By: Karol Maciaszek <[email protected]> * Update test-harness/specs/violations/print-as-http-response.txt Co-Authored-By: Karol Maciaszek <[email protected]> * Update packages/cli/src/util/createServer.ts Co-Authored-By: Karol Maciaszek <[email protected]> * deps: do not pin http spec * test: dry with only tested properties * test: change text * Apply suggestions from code review Co-Authored-By: Phil Sturgeon <[email protected]> * refactor: --errors * test: update and fix * feat: report input errors and only errors * docs: update * refactor: back to sl-violations * docs: add comment * fix: print all violations * test: add no block for warnings test * chore: fix error message sent to the client * feat: add request/response origin * docs: show a returned error * docs: it's json * docs: clarify * refactor: path for us are always strings * docs: command clarification * test: move empty response in their own directory * chore: remove * Update docs/guides/cli.md Co-Authored-By: Phil Sturgeon <[email protected]> * refactor: violation is 500 * docs: add docs for violations error * docs: update
- Loading branch information
Showing
165 changed files
with
877 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
**/.circleci | ||
**/.github | ||
**/dist | ||
**/docs | ||
**/examples | ||
**/node_modules | ||
**/__tests__ | ||
**/examples | ||
**/test-harness | ||
**/.tsbuildinfo | ||
**/dist | ||
**/.circleci | ||
**/.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import * as prismHttp from '@stoplight/prism-http'; | ||
import * as yargs from 'yargs'; | ||
import { createMultiProcessPrism, createSingleProcessPrism } from '../../util/createServer'; | ||
import mockCommand from '../mock'; | ||
import proxyCommand from '../proxy'; | ||
|
||
const parser = yargs.command(mockCommand).command(proxyCommand); | ||
|
||
jest.mock('../../util/createServer', () => ({ | ||
createMultiProcessPrism: jest.fn().mockResolvedValue([]), | ||
createSingleProcessPrism: jest.fn().mockResolvedValue([]), | ||
})); | ||
|
||
jest.spyOn(prismHttp, 'getHttpOperationsFromResource').mockResolvedValue([]); | ||
|
||
describe.each<{ 0: string; 1: string; 2: unknown }>([ | ||
['mock', '', { dynamic: false }], | ||
['proxy', 'http://github.com', { upstream: new URL('http://github.com/') }], | ||
])('%s command', (command, upstream) => { | ||
beforeEach(() => { | ||
(createSingleProcessPrism as jest.Mock).mockClear(); | ||
(createMultiProcessPrism as jest.Mock).mockClear(); | ||
}); | ||
|
||
test(`starts ${command} server`, () => { | ||
parser.parse(`${command} /path/to ${upstream}`); | ||
|
||
expect(createMultiProcessPrism).not.toHaveBeenCalled(); | ||
expect(createSingleProcessPrism).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ | ||
document: '/path/to', | ||
multiprocess: false, | ||
errors: false, | ||
}) | ||
); | ||
}); | ||
|
||
test(`starts ${command} server on custom port`, () => { | ||
parser.parse(`${command} /path/to -p 666 ${upstream}`); | ||
|
||
expect(createMultiProcessPrism).not.toHaveBeenCalled(); | ||
expect(createSingleProcessPrism).toHaveBeenLastCalledWith(expect.objectContaining({ port: 666 })); | ||
}); | ||
|
||
test(`starts ${command} server on custom host`, () => { | ||
parser.parse(`${command} /path/to -h 0.0.0.0 ${upstream}`); | ||
|
||
expect(createMultiProcessPrism).not.toHaveBeenCalled(); | ||
expect(createSingleProcessPrism).toHaveBeenLastCalledWith(expect.objectContaining({ host: '0.0.0.0' })); | ||
}); | ||
|
||
test(`starts ${command} server on custom host and port`, () => { | ||
parser.parse(`${command} /path/to -p 666 -h 0.0.0.0 ${upstream}`); | ||
|
||
expect(createMultiProcessPrism).not.toHaveBeenCalled(); | ||
expect(createSingleProcessPrism).toHaveBeenLastCalledWith(expect.objectContaining({ port: 666, host: '0.0.0.0' })); | ||
}); | ||
|
||
test(`starts ${command} server with multiprocess option `, () => { | ||
parser.parse(`${command} /path/to -m -h 0.0.0.0 ${upstream}`); | ||
|
||
expect(createSingleProcessPrism).not.toHaveBeenCalled(); | ||
expect(createMultiProcessPrism).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ multiprocess: true, host: '0.0.0.0' }) | ||
); | ||
}); | ||
|
||
test(`starts ${command} server with error violations option on `, () => { | ||
parser.parse(`${command} /path/to -m -h 0.0.0.0 --errors ${upstream}`); | ||
|
||
expect(createMultiProcessPrism).toHaveBeenLastCalledWith(expect.objectContaining({ errors: true })); | ||
}); | ||
}); |
Oops, something went wrong.