mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:39:42 +01:00
GraphQL, WebSocket, import, runner and CLI (M5, M6) plus packaging
- GraphQL editor with schema introspection, cached schema, autocomplete and explorer - WebSocket: auth and subprotocols in the handshake, text/JSON/hex/file messages, saved messages, live log with filter, search and export, reconnect with backoff - Import from Postman (collections and environments), Bruno, Insomnia, OpenAPI/Swagger and cURL; imported scripts are kept as docs, never run; credentials move to the gitignored secrets file - Code snippets for cURL, fetch, Python, HTTPie, Go, PowerShell; Postman export - Runner for folders and collections with JSON and JUnit reports - knock CLI: send, run, import, auth login/debug/logout - Large JSON responses parsed off the main thread - PKGBUILDs, desktop entry with knock:// handler, CI workflow, README
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
meta {
|
||||
name: Health
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{baseUrl}}/health
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
res.responseTime: lt 500
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
meta {
|
||||
name: Search
|
||||
type: graphql
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{baseUrl}}/graphql
|
||||
body: graphql
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:graphql {
|
||||
query Search($q: String!) {
|
||||
products(query: $q) { id name }
|
||||
}
|
||||
}
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"q": "chair"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
meta {
|
||||
name: Login
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{baseUrl}}/auth/login
|
||||
body: json
|
||||
auth: none
|
||||
}
|
||||
|
||||
headers {
|
||||
Accept: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"email": "{{email}}",
|
||||
"password": "{{password}}"
|
||||
}
|
||||
}
|
||||
|
||||
vars:post-response {
|
||||
token: res.body.token
|
||||
~refresh: res.body.refresh_token
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
res.body.token: isDefined
|
||||
res.headers.content-type: contains json
|
||||
res.body.roles: length 2
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
bru.setVar("loggedInAt", Date.now());
|
||||
}
|
||||
|
||||
tests {
|
||||
test("returns a token", function() {
|
||||
expect(res.getBody().token).to.be.a("string");
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
meta {
|
||||
name: auth
|
||||
seq: 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "Shop API",
|
||||
"type": "collection",
|
||||
"ignore": ["node_modules", ".git"]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
headers {
|
||||
X-Client: knock-fixture
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: bearer
|
||||
}
|
||||
|
||||
auth:bearer {
|
||||
token: {{apiToken}}
|
||||
}
|
||||
|
||||
script:pre-request {
|
||||
req.setHeader("X-Request-Id", Date.now().toString());
|
||||
}
|
||||
|
||||
docs {
|
||||
Internal shop API used by the storefront.
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
vars {
|
||||
baseUrl: http://localhost:4000
|
||||
~debugUser: alice
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
vars {
|
||||
baseUrl: https://api.shop.example.com
|
||||
}
|
||||
vars:secret [
|
||||
apiToken
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
meta {
|
||||
name: Create user
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{baseUrl}}/orgs/:org/users
|
||||
body: json
|
||||
auth: basic
|
||||
}
|
||||
|
||||
params:path {
|
||||
org: acme
|
||||
}
|
||||
|
||||
auth:basic {
|
||||
username: admin
|
||||
password: correct-horse
|
||||
}
|
||||
|
||||
body:json {
|
||||
{"name": "Ada", "roles": ["admin"]}
|
||||
}
|
||||
|
||||
docs {
|
||||
Creates a user in the given organisation.
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
meta {
|
||||
name: List users
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{baseUrl}}/users?page=1
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
params:query {
|
||||
page: 1
|
||||
~size: {{pageSize}}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
meta {
|
||||
name: Upload avatar
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{baseUrl}}/users/me/avatar
|
||||
body: multipartForm
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:multipart-form {
|
||||
file: @file(avatars/me.png)
|
||||
kind: profile
|
||||
~note: old
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
meta {
|
||||
name: users
|
||||
seq: 2
|
||||
}
|
||||
|
||||
headers {
|
||||
Accept: application/json
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
pageSize: 20
|
||||
}
|
||||
Reference in New Issue
Block a user