mirror of
https://github.com/kristoferssolo/tree-sitter-bruno.git
synced 2026-03-22 00:36:24 +00:00
Initial commit
This commit is contained in:
47
test/corpus/assert.txt
Normal file
47
test/corpus/assert.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
=======================
|
||||
Assert res.status = 200
|
||||
=======================
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(varsandassert
|
||||
(assert
|
||||
(keyword)
|
||||
(assert_dictionary
|
||||
(assert_dictionary_pair
|
||||
(assert_key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=======================
|
||||
Assert with empty value
|
||||
=======================
|
||||
|
||||
assert {
|
||||
res.status:
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(varsandassert
|
||||
(assert
|
||||
(keyword)
|
||||
(assert_dictionary
|
||||
(assert_dictionary_pair
|
||||
(assert_key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
57
test/corpus/auth.txt
Normal file
57
test/corpus/auth.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
===========
|
||||
Auth Oauth2
|
||||
===========
|
||||
|
||||
auth:oauth2 {
|
||||
grant_type: authorization_code
|
||||
scope: read write
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(auths
|
||||
(authoauth2
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===========================================
|
||||
Auth Basic with empty username and password
|
||||
===========================================
|
||||
|
||||
auth:basic {
|
||||
username:
|
||||
password:
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(auths
|
||||
(authbasic
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
192
test/corpus/body.txt
Normal file
192
test/corpus/body.txt
Normal file
@@ -0,0 +1,192 @@
|
||||
==========
|
||||
JSON Body
|
||||
==========
|
||||
|
||||
body:json {
|
||||
{
|
||||
"apiKey": "secret",
|
||||
"numbers": "9988776655",
|
||||
"message": "Woof! lets play with some apis"
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodyjson
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==========
|
||||
Text Body
|
||||
==========
|
||||
|
||||
body:text {
|
||||
This is a text body
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodytext
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=========
|
||||
XML Body
|
||||
=========
|
||||
|
||||
body:xml {
|
||||
<xml>
|
||||
<name>John</name>
|
||||
<age>30</age>
|
||||
</xml>
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodyxml
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=============
|
||||
GraphQL Body
|
||||
=============
|
||||
|
||||
body:graphql {
|
||||
{
|
||||
launchesPast {
|
||||
launch_site {
|
||||
site_name
|
||||
}
|
||||
launch_success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodygraphql
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==================
|
||||
GraphQL Vars Body
|
||||
==================
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"limit": 5
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodygraphqlvars
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=====================
|
||||
Form URLEncoded Body
|
||||
=====================
|
||||
|
||||
body:form-urlencoded {
|
||||
apikey: secret
|
||||
numbers: +91998877665
|
||||
~message: hello
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodyforms
|
||||
(bodyformurlencoded
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=====================
|
||||
Form Multipart Body
|
||||
=====================
|
||||
|
||||
body:multipart-form {
|
||||
apikey: secret
|
||||
numbers: +91998877665
|
||||
~message: hello
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(bodies
|
||||
(bodyforms
|
||||
(bodyformmultipart
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
31
test/corpus/bruno.txt
Normal file
31
test/corpus/bruno.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
================
|
||||
META Tag
|
||||
================
|
||||
|
||||
meta {
|
||||
name: Get users
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (meta
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
239
test/corpus/methods.txt
Normal file
239
test/corpus/methods.txt
Normal file
@@ -0,0 +1,239 @@
|
||||
=====================
|
||||
Query Parameters Tag
|
||||
=====================
|
||||
|
||||
query {
|
||||
apiKey: secret
|
||||
numbers: 9988776655
|
||||
message: hello
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (query
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
============
|
||||
Headers Tag
|
||||
============
|
||||
|
||||
headers {
|
||||
content-type: application/json
|
||||
Authorization: Bearer topsecret
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (headers
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===============
|
||||
GET Method Tag
|
||||
===============
|
||||
|
||||
get {
|
||||
url: https://github.com/Scalamando/tree-sitter-bruno
|
||||
body: JSON
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
================
|
||||
POST Method Tag
|
||||
================
|
||||
|
||||
post {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===============
|
||||
PUT Method Tag
|
||||
===============
|
||||
|
||||
put {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==================
|
||||
DELETE Method Tag
|
||||
==================
|
||||
|
||||
delete {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===================
|
||||
OPTIONS Method Tag
|
||||
===================
|
||||
|
||||
options {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=================
|
||||
TRACE Method Tag
|
||||
=================
|
||||
|
||||
trace {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===================
|
||||
CONNECT Method Tag
|
||||
===================
|
||||
|
||||
connect {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
================
|
||||
HEAD Method Tag
|
||||
================
|
||||
|
||||
head {
|
||||
url: https://api.github.com/users/usebruno
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
197
test/corpus/real.txt
Normal file
197
test/corpus/real.txt
Normal file
@@ -0,0 +1,197 @@
|
||||
=================
|
||||
GET with headers
|
||||
=================
|
||||
|
||||
get {
|
||||
url: https://api.textlocal.in/send?apiKey=secret&numbers=9988776655&message=hello
|
||||
}
|
||||
|
||||
headers {
|
||||
content-type: application/json
|
||||
Authorization: Bearer topsecret
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (headers
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
===============
|
||||
POST with body
|
||||
===============
|
||||
|
||||
post {
|
||||
url: https://api.textlocal.in/send
|
||||
}
|
||||
|
||||
body {
|
||||
{
|
||||
"apiKey": "secret",
|
||||
"numbers": "9988776655",
|
||||
"message": "Woof! lets play with some apis"
|
||||
}
|
||||
}
|
||||
|
||||
headers {
|
||||
content-type: application/json
|
||||
Authorization: Bearer topsecret
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (bodies
|
||||
(body
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (headers
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==========
|
||||
Scripting
|
||||
==========
|
||||
|
||||
post {
|
||||
url: https://api.textlocal.in/login
|
||||
}
|
||||
|
||||
body {
|
||||
{
|
||||
"username": "johnnash",
|
||||
"password": "governingdynamics"
|
||||
}
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
bru.setVar("token", res.body.token);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (bodies
|
||||
(body
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (script
|
||||
(scriptres
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
========
|
||||
Testing
|
||||
========
|
||||
|
||||
post {
|
||||
url: https://api.textlocal.in/login
|
||||
}
|
||||
|
||||
body {
|
||||
{
|
||||
"username": "johnnash",
|
||||
"password": "governingdynamics"
|
||||
}
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should be able to login", function() {
|
||||
expect(res.status).to.equal(201);
|
||||
});
|
||||
|
||||
test("should receive the token", function() {
|
||||
expect(res.body.token).to.be.a('string');
|
||||
});
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (http
|
||||
(keyword)
|
||||
(dictionary
|
||||
(dictionary_pair
|
||||
(key)
|
||||
(value)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (bodies
|
||||
(body
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
tag: (tests
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
60
test/corpus/scripts.txt
Normal file
60
test/corpus/scripts.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
========================
|
||||
Script Pre-Request Tags
|
||||
========================
|
||||
|
||||
script:pre-request {
|
||||
req.setHeader("Authorization", "{{token}}");
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (script
|
||||
(scriptreq
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
========================
|
||||
Script Post-Response Tags
|
||||
========================
|
||||
|
||||
script:post-response {
|
||||
bru.setVar("token", res.body.token);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (script
|
||||
(scriptres
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
========================
|
||||
Test Tags
|
||||
========================
|
||||
|
||||
tests {
|
||||
expect(res.status).to.equal(200);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
tag: (tests
|
||||
(keyword)
|
||||
(textblock
|
||||
(rawtext)
|
||||
)
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user