mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-06 20:32:44 +08:00
fix: convert tests
This commit is contained in:
@@ -6,71 +6,49 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var curlPath = "../examples/data/curl/curl_examples.txt"
|
||||
var curlPath = "../tests/data/curl/curl_examples.txt"
|
||||
|
||||
func TestLoadCurlCase(t *testing.T) {
|
||||
tCase, err := LoadCurlCase(curlPath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !assert.Equal(t, 6, len(tCase.Steps)) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 6, len(tCase.Steps))
|
||||
|
||||
// curl httpbin.org
|
||||
if !assert.Equal(t, "curl httpbin.org", tCase.Steps[0].StepName) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "http://httpbin.org", tCase.Steps[0].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "curl httpbin.org", tCase.Steps[0].StepName)
|
||||
assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method)
|
||||
assert.Equal(t, "http://httpbin.org", tCase.Steps[0].Request.URL)
|
||||
|
||||
// curl https://httpbin.org/get?key1=value1&key2=value2
|
||||
if !assert.Equal(t, "https://httpbin.org/get", tCase.Steps[1].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]interface{}{
|
||||
assert.Equal(t, "https://httpbin.org/get", tCase.Steps[1].Request.URL)
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"key1": "value1",
|
||||
"key2": "value2",
|
||||
}, tCase.Steps[1].Request.Params) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, tCase.Steps[1].Request.Params)
|
||||
|
||||
// curl -H "Content-Type: application/json" \
|
||||
// -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" \
|
||||
// -d '{"type":"A","name":"www","data":"162.10.66.0","priority":null,"port":null,"weight":null}' \
|
||||
// "https://httpbin.org/post"
|
||||
if !assert.EqualValues(t, "POST", tCase.Steps[2].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.EqualValues(t, "POST", tCase.Steps[2].Request.Method)
|
||||
assert.Equal(t, map[string]string{
|
||||
"Authorization": "Bearer b7d03a6947b217efb6f3ec3bd3504582",
|
||||
"Content-Type": "application/json",
|
||||
}, tCase.Steps[2].Request.Headers) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]interface{}{
|
||||
}, tCase.Steps[2].Request.Headers)
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"data": "162.10.66.0",
|
||||
"name": "www",
|
||||
"port": nil,
|
||||
"priority": nil,
|
||||
"type": "A",
|
||||
"weight": nil,
|
||||
}, tCase.Steps[2].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, tCase.Steps[2].Request.Body)
|
||||
|
||||
// curl -F "dummyName=dummyFile" -F file1=@file1.txt -F file2=@file2.txt https://httpbin.org/post
|
||||
if !assert.Equal(t, map[string]interface{}{
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"dummyName": "dummyFile",
|
||||
"file1": "@file1.txt",
|
||||
"file2": "@file2.txt",
|
||||
}, tCase.Steps[3].Request.Upload) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, tCase.Steps[3].Request.Upload)
|
||||
|
||||
// curl https://httpbin.org/post \
|
||||
// -d 'shipment[to_address][id]=adr_HrBKVA85' \
|
||||
@@ -78,27 +56,21 @@ func TestLoadCurlCase(t *testing.T) {
|
||||
// -d 'shipment[parcel][id]=prcl_WDv2VzHp' \
|
||||
// -d 'shipment[is_return]=true' \
|
||||
// -d 'shipment[customs_info][id]=cstinfo_bl5sE20Y'
|
||||
if !assert.Equal(t, map[string]interface{}{
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"shipment[customs_info][id]": "cstinfo_bl5sE20Y",
|
||||
"shipment[from_address][id]": "adr_VtuTOj7o",
|
||||
"shipment[is_return]": "true",
|
||||
"shipment[parcel][id]": "prcl_WDv2VzHp",
|
||||
"shipment[to_address][id]": "adr_HrBKVA85",
|
||||
}, tCase.Steps[4].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, tCase.Steps[4].Request.Body)
|
||||
|
||||
// curl https://httpbing.org/post -H "Content-Type: application/x-www-form-urlencoded" \
|
||||
// --data "key1=value+1&key2=value%3A2"
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}, tCase.Steps[5].Request.Headers) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]interface{}{
|
||||
}, tCase.Steps[5].Request.Headers)
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"key1": "value 1",
|
||||
"key2": "value:2",
|
||||
}, tCase.Steps[5].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, tCase.Steps[5].Request.Body)
|
||||
}
|
||||
|
||||
@@ -5,79 +5,44 @@ import (
|
||||
|
||||
hrp "github.com/httprunner/httprunner/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var harPath = "../../../examples/data/har/demo.har"
|
||||
|
||||
var caseHar *CaseHar
|
||||
|
||||
func init() {
|
||||
caseHar, _ = loadCaseHAR(harPath)
|
||||
}
|
||||
var harPath = "../tests/data/har/demo.har"
|
||||
|
||||
func TestLoadHAR(t *testing.T) {
|
||||
caseHAR, err := loadCaseHAR(harPath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "GET", caseHAR.Log.Entries[0].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "POST", caseHAR.Log.Entries[1].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "GET", caseHAR.Log.Entries[0].Request.Method)
|
||||
assert.Equal(t, "POST", caseHAR.Log.Entries[1].Request.Method)
|
||||
}
|
||||
|
||||
func TestLoadTCaseFromHAR(t *testing.T) {
|
||||
tCase, err := LoadHARCase(harPath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
// make request method
|
||||
if !assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.EqualValues(t, "POST", tCase.Steps[1].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method)
|
||||
assert.EqualValues(t, "POST", tCase.Steps[1].Request.Method)
|
||||
|
||||
// make request url
|
||||
if !assert.Equal(t, "https://postman-echo.com/get", tCase.Steps[0].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "https://postman-echo.com/post", tCase.Steps[1].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "https://postman-echo.com/get", tCase.Steps[0].Request.URL)
|
||||
assert.Equal(t, "https://postman-echo.com/post", tCase.Steps[1].Request.URL)
|
||||
|
||||
// make request params
|
||||
if !assert.Equal(t, "HDnY8", tCase.Steps[0].Request.Params["foo1"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "HDnY8", tCase.Steps[0].Request.Params["foo1"])
|
||||
|
||||
// make request cookies
|
||||
if !assert.NotEmpty(t, tCase.Steps[1].Request.Cookies["sails.sid"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NotEmpty(t, tCase.Steps[1].Request.Cookies["sails.sid"])
|
||||
|
||||
// make request headers
|
||||
if !assert.Equal(t, "HttpRunnerPlus", tCase.Steps[0].Request.Headers["User-Agent"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "postman-echo.com", tCase.Steps[0].Request.Headers["Host"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "HttpRunnerPlus", tCase.Steps[0].Request.Headers["User-Agent"])
|
||||
assert.Equal(t, "postman-echo.com", tCase.Steps[0].Request.Headers["Host"])
|
||||
|
||||
// make request data
|
||||
if !assert.Equal(t, nil, tCase.Steps[0].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.Steps[1].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]string{"foo1": "HDnY8", "foo2": "12.3"}, tCase.Steps[2].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, nil, tCase.Steps[0].Request.Body)
|
||||
assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.Steps[1].Request.Body)
|
||||
assert.Equal(t, map[string]string{"foo1": "HDnY8", "foo2": "12.3"}, tCase.Steps[2].Request.Body)
|
||||
|
||||
// make validators
|
||||
validator, ok := tCase.Steps[0].Validators[0].(hrp.Validator)
|
||||
@@ -100,14 +65,12 @@ func TestMakeRequestURL(t *testing.T) {
|
||||
URL: "http://127.0.0.1:8080/api/login",
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, "http://127.0.0.1:8080/api/login", step.Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "http://127.0.0.1:8080/api/login", step.Request.URL)
|
||||
}
|
||||
|
||||
func TestMakeRequestHeaders(t *testing.T) {
|
||||
@@ -119,16 +82,14 @@ func TestMakeRequestHeaders(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
}, step.Request.Headers) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, step.Request.Headers)
|
||||
}
|
||||
|
||||
func TestMakeRequestCookies(t *testing.T) {
|
||||
@@ -141,17 +102,15 @@ func TestMakeRequestCookies(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"abc": "123",
|
||||
"UserName": "leolee",
|
||||
}, step.Request.Cookies) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, step.Request.Cookies)
|
||||
}
|
||||
|
||||
func TestMakeRequestDataParams(t *testing.T) {
|
||||
@@ -167,14 +126,12 @@ func TestMakeRequestDataParams(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]string{"a": "1", "b": "2"}, step.Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, map[string]string{"a": "1", "b": "2"}, step.Request.Body)
|
||||
}
|
||||
|
||||
func TestMakeRequestDataJSON(t *testing.T) {
|
||||
@@ -187,14 +144,12 @@ func TestMakeRequestDataJSON(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]interface{}{"a": "1", "b": "2"}, step.Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, map[string]interface{}{"a": "1", "b": "2"}, step.Request.Body)
|
||||
}
|
||||
|
||||
func TestMakeRequestDataTextEmpty(t *testing.T) {
|
||||
@@ -207,14 +162,11 @@ func TestMakeRequestDataTextEmpty(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
if !assert.Equal(t, nil, step.Request.Body) { // TODO
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nil, step.Request.Body)
|
||||
}
|
||||
|
||||
func TestMakeValidate(t *testing.T) {
|
||||
@@ -233,49 +185,37 @@ func TestMakeValidate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
caseHar, err := loadCaseHAR(harPath)
|
||||
require.NoError(t, err)
|
||||
step, err := caseHar.prepareTestStep(entry)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
validator, ok := step.Validators[0].(hrp.Validator)
|
||||
if !ok {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, validator,
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, validator,
|
||||
hrp.Validator{
|
||||
Check: "status_code",
|
||||
Expect: 200,
|
||||
Assert: "equals",
|
||||
Message: "assert response status code",
|
||||
}) {
|
||||
t.Fatal()
|
||||
}
|
||||
})
|
||||
|
||||
validator, ok = step.Validators[1].(hrp.Validator)
|
||||
if !ok {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, validator,
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, validator,
|
||||
hrp.Validator{
|
||||
Check: "headers.\"Content-Type\"",
|
||||
Expect: "application/json; charset=utf-8",
|
||||
Assert: "equals",
|
||||
Message: "assert response header Content-Type",
|
||||
}) {
|
||||
t.Fatal()
|
||||
}
|
||||
})
|
||||
|
||||
validator, ok = step.Validators[2].(hrp.Validator)
|
||||
if !ok {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, validator,
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, validator,
|
||||
hrp.Validator{
|
||||
Check: "body.Code",
|
||||
Expect: float64(200), // TODO
|
||||
Assert: "equals",
|
||||
Message: "assert response body Code",
|
||||
}) {
|
||||
t.Fatal()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,73 +6,37 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var collectionPath = "../../../examples/data/postman/postman_collection.json"
|
||||
var collectionPath = "../tests/data/postman/postman_collection.json"
|
||||
|
||||
func TestLoadCollection(t *testing.T) {
|
||||
casePostman, err := loadCasePostman(collectionPath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !assert.Equal(t, "postman collection demo", casePostman.Info.Name) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "postman collection demo", casePostman.Info.Name)
|
||||
}
|
||||
|
||||
func TestMakeTestCaseFromCollection(t *testing.T) {
|
||||
tCase, err := LoadPostmanCase(collectionPath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
// check name
|
||||
if !assert.Equal(t, "postman collection demo", tCase.Config.Name) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "postman collection demo", tCase.Config.Name)
|
||||
// check method
|
||||
if !assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.EqualValues(t, "POST", tCase.Steps[1].Request.Method) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.EqualValues(t, "GET", tCase.Steps[0].Request.Method)
|
||||
assert.EqualValues(t, "POST", tCase.Steps[1].Request.Method)
|
||||
// check url
|
||||
if !assert.Equal(t, "https://postman-echo.com/get", tCase.Steps[0].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "https://postman-echo.com/post", tCase.Steps[1].Request.URL) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "https://postman-echo.com/get", tCase.Steps[0].Request.URL)
|
||||
assert.Equal(t, "https://postman-echo.com/post", tCase.Steps[1].Request.URL)
|
||||
// check params
|
||||
if !assert.Equal(t, "v1", tCase.Steps[0].Request.Params["k1"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "v1", tCase.Steps[0].Request.Params["k1"])
|
||||
// check cookies (pass, postman collection doesn't contain cookies)
|
||||
// check headers
|
||||
if !assert.Equal(t, "application/x-www-form-urlencoded", tCase.Steps[2].Request.Headers["Content-Type"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "application/json", tCase.Steps[3].Request.Headers["Content-Type"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "text/plain", tCase.Steps[4].Request.Headers["Content-Type"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "HttpRunner", tCase.Steps[5].Request.Headers["User-Agent"]) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, "application/x-www-form-urlencoded", tCase.Steps[2].Request.Headers["Content-Type"])
|
||||
assert.Equal(t, "application/json", tCase.Steps[3].Request.Headers["Content-Type"])
|
||||
assert.Equal(t, "text/plain", tCase.Steps[4].Request.Headers["Content-Type"])
|
||||
assert.Equal(t, "HttpRunner", tCase.Steps[5].Request.Headers["User-Agent"])
|
||||
// check body
|
||||
if !assert.Equal(t, nil, tCase.Steps[0].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]string{"k1": "v1", "k2": "v2"}, tCase.Steps[2].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]interface{}{"k1": "v1", "k2": "v2"}, tCase.Steps[3].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, "have a nice day", tCase.Steps[4].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, nil, tCase.Steps[5].Request.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.Equal(t, nil, tCase.Steps[0].Request.Body)
|
||||
assert.Equal(t, map[string]string{"k1": "v1", "k2": "v2"}, tCase.Steps[2].Request.Body)
|
||||
assert.Equal(t, map[string]interface{}{"k1": "v1", "k2": "v2"}, tCase.Steps[3].Request.Body)
|
||||
assert.Equal(t, "have a nice day", tCase.Steps[4].Request.Body)
|
||||
assert.Equal(t, nil, tCase.Steps[5].Request.Body)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
|
||||
hrp "github.com/httprunner/httprunner/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
profilePath = "../../../examples/data/profile.yml"
|
||||
profileOverridePath = "../../../examples/data/profile_override.yml"
|
||||
profilePath = "../tests/data/profile.yml"
|
||||
profileOverridePath = "../tests/data/profile_override.yml"
|
||||
)
|
||||
|
||||
var converter *TCaseConverter
|
||||
@@ -20,28 +21,18 @@ func init() {
|
||||
|
||||
func TestLoadTCase(t *testing.T) {
|
||||
err := converter.loadCase(harPath, FromTypeHAR)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.NotEmpty(t, converter.tCase) {
|
||||
t.Fatal()
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, converter.tCase)
|
||||
}
|
||||
|
||||
func TestLoadHARWithProfileOverride(t *testing.T) {
|
||||
err := converter.loadCase(harPath, FromTypeHAR)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.NotEmpty(t, converter.tCase) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, converter.tCase)
|
||||
|
||||
// override TCase with profile
|
||||
err = converter.overrideWithProfile(profileOverridePath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
assert.Equal(t,
|
||||
@@ -75,23 +66,15 @@ func TestMakeRequestWithProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
err := caseConverter.overrideWithProfile(profilePath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "application/x-www-form-urlencoded", "User-Agent": "hrp",
|
||||
}, caseConverter.tCase.Steps[0].Request.Headers) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]string{
|
||||
}, caseConverter.tCase.Steps[0].Request.Headers)
|
||||
assert.Equal(t, map[string]string{
|
||||
"UserName": "debugtalk", "abc": "123",
|
||||
}, caseConverter.tCase.Steps[0].Request.Cookies) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, caseConverter.tCase.Steps[0].Request.Cookies)
|
||||
}
|
||||
|
||||
func TestMakeRequestWithProfileOverride(t *testing.T) {
|
||||
@@ -117,21 +100,13 @@ func TestMakeRequestWithProfileOverride(t *testing.T) {
|
||||
|
||||
// override TCase with profile
|
||||
err := caseConverter.overrideWithProfile(profileOverridePath)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, err)
|
||||
|
||||
if !assert.Equal(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}, caseConverter.tCase.Steps[0].Request.Headers) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, map[string]string{
|
||||
}, caseConverter.tCase.Steps[0].Request.Headers)
|
||||
assert.Equal(t, map[string]string{
|
||||
"UserName": "debugtalk",
|
||||
}, caseConverter.tCase.Steps[0].Request.Cookies) {
|
||||
t.Fatal()
|
||||
}
|
||||
}, caseConverter.tCase.Steps[0].Request.Cookies)
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-beta-2503052208
|
||||
v5.0.0-beta-2503052228
|
||||
|
||||
0
tests/data/.csv
Normal file
0
tests/data/.csv
Normal file
|
|
30
tests/data/a-b.c/1.yml
Normal file
30
tests/data/a-b.c/1.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
config:
|
||||
name: "request methods testcase with functions"
|
||||
variables:
|
||||
foo1: config_bar1
|
||||
foo2: config_bar2
|
||||
base_url: "https://postman-echo.com"
|
||||
verify: False
|
||||
|
||||
teststeps:
|
||||
-
|
||||
name: get with params
|
||||
variables:
|
||||
foo1: bar1
|
||||
sum_v: "${sum_two(1, 2)}"
|
||||
request:
|
||||
method: GET
|
||||
url: /get
|
||||
params:
|
||||
foo1: $foo1
|
||||
foo2: $foo2
|
||||
sum_v: $sum_v
|
||||
headers:
|
||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
||||
extract:
|
||||
session_foo2: "body.args.foo2"
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- eq: ["body.args.foo1", "bar1"]
|
||||
- eq: ["body.args.sum_v", "3"]
|
||||
- eq: ["body.args.foo2", "config_bar2"]
|
||||
26
tests/data/a-b.c/2 3.yml
Normal file
26
tests/data/a-b.c/2 3.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
config:
|
||||
name: "reference testcase unittest for abnormal folder path"
|
||||
base_url: "https://postman-echo.com"
|
||||
verify: False
|
||||
|
||||
teststeps:
|
||||
-
|
||||
name: request with functions
|
||||
testcase: a-b.c/1.yml
|
||||
export:
|
||||
- session_foo2
|
||||
-
|
||||
name: post form data
|
||||
variables:
|
||||
foo1: bar12
|
||||
request:
|
||||
method: POST
|
||||
url: /post
|
||||
headers:
|
||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
||||
Content-Type: "application/x-www-form-urlencoded"
|
||||
data: "foo1=$foo1&foo2=$session_foo2"
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- eq: ["body.form.foo1", "bar12"]
|
||||
- eq: ["body.form.foo2", "config_bar2"]
|
||||
0
tests/data/a-b.c/中文case.yml
Normal file
0
tests/data/a-b.c/中文case.yml
Normal file
34
tests/data/a_b_c/T1_test.py
Normal file
34
tests/data/a_b_c/T1_test.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# NOTE: Generated By HttpRunner v4.3.5
|
||||
# FROM: a-b.c/1.yml
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest
|
||||
|
||||
|
||||
class TestCaseT1(HttpRunner):
|
||||
|
||||
config = (
|
||||
Config("request methods testcase with functions")
|
||||
.variables(**{"foo1": "config_bar1", "foo2": "config_bar2"})
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
Step(
|
||||
RunRequest("get with params")
|
||||
.with_variables(**{"foo1": "bar1", "sum_v": "${sum_two(1, 2)}"})
|
||||
.get("/get")
|
||||
.with_params(**{"foo1": "$foo1", "foo2": "$foo2", "sum_v": "$sum_v"})
|
||||
.with_headers(**{"User-Agent": "HttpRunner/${get_httprunner_version()}"})
|
||||
.extract()
|
||||
.with_jmespath("body.args.foo2", "session_foo2")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
.assert_equal("body.args.foo1", "bar1")
|
||||
.assert_equal("body.args.sum_v", "3")
|
||||
.assert_equal("body.args.foo2", "config_bar2")
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
TestCaseT1().test_start()
|
||||
44
tests/data/a_b_c/T2_3_test.py
Normal file
44
tests/data/a_b_c/T2_3_test.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# NOTE: Generated By HttpRunner v4.3.5
|
||||
# FROM: a-b.c/2 3.yml
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest
|
||||
from httprunner import RunTestCase
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from a_b_c.T1_test import TestCaseT1 as T1
|
||||
|
||||
|
||||
class TestCaseT23(HttpRunner):
|
||||
|
||||
config = (
|
||||
Config("reference testcase unittest for abnormal folder path")
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
Step(RunTestCase("request with functions").call(T1).export(*["session_foo2"])),
|
||||
Step(
|
||||
RunRequest("post form data")
|
||||
.with_variables(**{"foo1": "bar12"})
|
||||
.post("/post")
|
||||
.with_headers(
|
||||
**{
|
||||
"User-Agent": "HttpRunner/${get_httprunner_version()}",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
)
|
||||
.with_data("foo1=$foo1&foo2=$session_foo2")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
.assert_equal("body.form.foo1", "bar12")
|
||||
.assert_equal("body.form.foo2", "config_bar2")
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
TestCaseT23().test_start()
|
||||
1
tests/data/a_b_c/__init__.py
Normal file
1
tests/data/a_b_c/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
|
||||
11
tests/data/curl/curl_examples.txt
Normal file
11
tests/data/curl/curl_examples.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
curl httpbin.org
|
||||
|
||||
curl https://httpbin.org/get?key1=value1&key2=value2
|
||||
|
||||
curl -H "Content-Type: application/json" -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" -d '{"type":"A","name":"www","data":"162.10.66.0","priority":null,"port":null,"weight":null}' "https://httpbin.org/post"
|
||||
|
||||
curl -F "dummyName=dummyFile" -F file1=@file1.txt -F file2=@file2.txt https://httpbin.org/post
|
||||
|
||||
curl https://httpbin.org/post -d 'shipment[to_address][id]=adr_HrBKVA85' -d 'shipment[from_address][id]=adr_VtuTOj7o' -d 'shipment[parcel][id]=prcl_WDv2VzHp' -d 'shipment[is_return]=true' -d 'shipment[customs_info][id]=cstinfo_bl5sE20Y'
|
||||
|
||||
curl https://httpbing.org/post -H "Content-Type: application/x-www-form-urlencoded" --data "key1=value+1&key2=value%3A2"
|
||||
13
tests/data/debugtalk.py
Normal file
13
tests/data/debugtalk.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from httprunner import __version__
|
||||
|
||||
|
||||
def get_httprunner_version():
|
||||
return __version__
|
||||
|
||||
|
||||
def sum_two(m, n):
|
||||
return m + n
|
||||
|
||||
|
||||
def get_variables():
|
||||
return {"foo1": "session_bar1"}
|
||||
356
tests/data/har/demo.har
Normal file
356
tests/data/har/demo.har
Normal file
@@ -0,0 +1,356 @@
|
||||
{
|
||||
"log": {
|
||||
"version": "1.2",
|
||||
"creator": {
|
||||
"name": "Charles Proxy",
|
||||
"version": "4.6.1"
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"startedDateTime": "2021-10-15T20:29:14.396+08:00",
|
||||
"time": 1528,
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"url": "https://postman-echo.com/get?foo1=HDnY8&foo2=34.5",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Host",
|
||||
"value": "postman-echo.com"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "HttpRunnerPlus"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
"value": "gzip"
|
||||
}
|
||||
],
|
||||
"queryString": [
|
||||
{
|
||||
"name": "foo1",
|
||||
"value": "HDnY8"
|
||||
},
|
||||
{
|
||||
"name": "foo2",
|
||||
"value": "34.5"
|
||||
}
|
||||
],
|
||||
"headersSize": 113,
|
||||
"bodySize": 0
|
||||
},
|
||||
"response": {
|
||||
"_charlesStatus": "COMPLETE",
|
||||
"status": 200,
|
||||
"statusText": "OK",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [
|
||||
{
|
||||
"name": "sails.sid",
|
||||
"value": "s%3Az_LpglkKxTvJ_eHVUH6V67drKp0AGWW-.PidabaXOnatLRP47hVyqqepl6BdrpEQzRlJQXtbIiwk",
|
||||
"path": "/",
|
||||
"domain": null,
|
||||
"expires": null,
|
||||
"httpOnly": true,
|
||||
"secure": false,
|
||||
"comment": null,
|
||||
"_maxAge": null
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Fri, 15 Oct 2021 12:29:15 GMT"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "300"
|
||||
},
|
||||
{
|
||||
"name": "ETag",
|
||||
"value": "W/\"12c-1pyB4v4mv3hdBoU+8cUmx4p37qI\""
|
||||
},
|
||||
{
|
||||
"name": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
},
|
||||
{
|
||||
"name": "set-cookie",
|
||||
"value": "sails.sid=s%3Az_LpglkKxTvJ_eHVUH6V67drKp0AGWW-.PidabaXOnatLRP47hVyqqepl6BdrpEQzRlJQXtbIiwk; Path=/; HttpOnly"
|
||||
},
|
||||
{
|
||||
"name": "Connection",
|
||||
"value": "keep-alive"
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"size": 300,
|
||||
"mimeType": "application/json; charset=utf-8",
|
||||
"text": "eyJhcmdzIjp7ImZvbzEiOiJIRG5ZOCIsImZvbzIiOiIzNC41In0sImhlYWRlcnMiOnsieC1mb3J3YXJkZWQtcHJvdG8iOiJodHRwcyIsIngtZm9yd2FyZGVkLXBvcnQiOiI0NDMiLCJob3N0IjoicG9zdG1hbi1lY2hvLmNvbSIsIngtYW16bi10cmFjZS1pZCI6IlJvb3Q9MS02MTY5NzQxYi01YjgyNTRjZTZjZThlNTU2NTRiNzc3MmQiLCJ1c2VyLWFnZW50IjoiSHR0cEJvb21lciIsImFjY2VwdC1lbmNvZGluZyI6Imd6aXAifSwidXJsIjoiaHR0cHM6Ly9wb3N0bWFuLWVjaG8uY29tL2dldD9mb28xPUhEblk4JmZvbzI9MzQuNSJ9",
|
||||
"encoding": "base64"
|
||||
},
|
||||
"redirectURL": null,
|
||||
"headersSize": 0,
|
||||
"bodySize": 300
|
||||
},
|
||||
"serverIPAddress": "44.193.31.23",
|
||||
"cache": {},
|
||||
"timings": {
|
||||
"dns": 105,
|
||||
"connect": 1108,
|
||||
"ssl": 721,
|
||||
"send": 1,
|
||||
"wait": 312,
|
||||
"receive": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"startedDateTime": "2021-10-15T20:29:16.120+08:00",
|
||||
"time": 306,
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [
|
||||
{
|
||||
"name": "sails.sid",
|
||||
"value": "s%3Az_LpglkKxTvJ_eHVUH6V67drKp0AGWW-.PidabaXOnatLRP47hVyqqepl6BdrpEQzRlJQXtbIiwk"
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Host",
|
||||
"value": "postman-echo.com"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "Go-http-client/1.1"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "28"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json; charset=UTF-8"
|
||||
},
|
||||
{
|
||||
"name": "Cookie",
|
||||
"value": "sails.sid=s%3Az_LpglkKxTvJ_eHVUH6V67drKp0AGWW-.PidabaXOnatLRP47hVyqqepl6BdrpEQzRlJQXtbIiwk"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
"value": "gzip"
|
||||
}
|
||||
],
|
||||
"queryString": [],
|
||||
"postData": {
|
||||
"mimeType": "application/json; charset=UTF-8",
|
||||
"text": "{\"foo1\":\"HDnY8\",\"foo2\":12.3}"
|
||||
},
|
||||
"headersSize": 269,
|
||||
"bodySize": 28
|
||||
},
|
||||
"response": {
|
||||
"_charlesStatus": "COMPLETE",
|
||||
"status": 200,
|
||||
"statusText": "OK",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [
|
||||
{
|
||||
"name": "sails.sid",
|
||||
"value": "s%3AS5e7w0zQ0xAsCwh9L8T6R7QLYCO7_gtD.r8%2B2w9IWqEIfuVkrZjnxzm2xADIk34zKAWXRPapr%2FAw",
|
||||
"path": "/",
|
||||
"domain": null,
|
||||
"expires": null,
|
||||
"httpOnly": true,
|
||||
"secure": false,
|
||||
"comment": null,
|
||||
"_maxAge": null
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Fri, 15 Oct 2021 12:29:16 GMT"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "526"
|
||||
},
|
||||
{
|
||||
"name": "ETag",
|
||||
"value": "W/\"20e-aXqJ0H6Q30sU41c/D7asB+yXWeQ\""
|
||||
},
|
||||
{
|
||||
"name": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
},
|
||||
{
|
||||
"name": "set-cookie",
|
||||
"value": "sails.sid=s%3AS5e7w0zQ0xAsCwh9L8T6R7QLYCO7_gtD.r8%2B2w9IWqEIfuVkrZjnxzm2xADIk34zKAWXRPapr%2FAw; Path=/; HttpOnly"
|
||||
},
|
||||
{
|
||||
"name": "Connection",
|
||||
"value": "keep-alive"
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"size": 526,
|
||||
"mimeType": "application/json; charset=utf-8",
|
||||
"text": "eyJhcmdzIjp7fSwiZGF0YSI6eyJmb28xIjoiSERuWTgiLCJmb28yIjoxMi4zfSwiZmlsZXMiOnt9LCJmb3JtIjp7fSwiaGVhZGVycyI6eyJ4LWZvcndhcmRlZC1wcm90byI6Imh0dHBzIiwieC1mb3J3YXJkZWQtcG9ydCI6IjQ0MyIsImhvc3QiOiJwb3N0bWFuLWVjaG8uY29tIiwieC1hbXpuLXRyYWNlLWlkIjoiUm9vdD0xLTYxNjk3NDFjLTIxN2RiMGI3MWFkYjgwYmQ3ODUxOTI2OCIsImNvbnRlbnQtbGVuZ3RoIjoiMjgiLCJ1c2VyLWFnZW50IjoiR28taHR0cC1jbGllbnQvMS4xIiwiY29udGVudC10eXBlIjoiYXBwbGljYXRpb24vanNvbjsgY2hhcnNldD1VVEYtOCIsImNvb2tpZSI6InNhaWxzLnNpZD1zJTNBel9McGdsa0t4VHZKX2VIVlVINlY2N2RyS3AwQUdXVy0uUGlkYWJhWE9uYXRMUlA0N2hWeXFxZXBsNkJkcnBFUXpSbEpRWHRiSWl3ayIsImFjY2VwdC1lbmNvZGluZyI6Imd6aXAifSwianNvbiI6eyJmb28xIjoiSERuWTgiLCJmb28yIjoxMi4zfSwidXJsIjoiaHR0cHM6Ly9wb3N0bWFuLWVjaG8uY29tL3Bvc3QifQ==",
|
||||
"encoding": "base64"
|
||||
},
|
||||
"redirectURL": null,
|
||||
"headersSize": 0,
|
||||
"bodySize": 526
|
||||
},
|
||||
"serverIPAddress": "44.193.31.23",
|
||||
"cache": {},
|
||||
"timings": {
|
||||
"dns": -1,
|
||||
"connect": -1,
|
||||
"ssl": -1,
|
||||
"send": 1,
|
||||
"wait": 304,
|
||||
"receive": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"startedDateTime": "2021-10-15T20:29:16.427+08:00",
|
||||
"time": 305,
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "https://postman-echo.com/post",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [
|
||||
{
|
||||
"name": "sails.sid",
|
||||
"value": "s%3AS5e7w0zQ0xAsCwh9L8T6R7QLYCO7_gtD.r8%2B2w9IWqEIfuVkrZjnxzm2xADIk34zKAWXRPapr%2FAw"
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Host",
|
||||
"value": "postman-echo.com"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "Go-http-client/1.1"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
{
|
||||
"name": "Cookie",
|
||||
"value": "sails.sid=s%3AS5e7w0zQ0xAsCwh9L8T6R7QLYCO7_gtD.r8%2B2w9IWqEIfuVkrZjnxzm2xADIk34zKAWXRPapr%2FAw"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
"value": "gzip"
|
||||
}
|
||||
],
|
||||
"queryString": [],
|
||||
"postData": {
|
||||
"mimeType": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
"params": [
|
||||
{
|
||||
"name": "foo1",
|
||||
"value": "HDnY8"
|
||||
},
|
||||
{
|
||||
"name": "foo2",
|
||||
"value": "12.3"
|
||||
}
|
||||
]
|
||||
},
|
||||
"headersSize": 290,
|
||||
"bodySize": 20
|
||||
},
|
||||
"response": {
|
||||
"_charlesStatus": "COMPLETE",
|
||||
"status": 200,
|
||||
"statusText": "OK",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [
|
||||
{
|
||||
"name": "sails.sid",
|
||||
"value": "s%3AMp2gGgeCCDM4sRS_MfL1q-hAkL3bAk84.9XT7TTW8QzueQqtQ6bQM%2BgHqiUBbkJSfgM5CbfhFreQ",
|
||||
"path": "/",
|
||||
"domain": null,
|
||||
"expires": null,
|
||||
"httpOnly": true,
|
||||
"secure": false,
|
||||
"comment": null,
|
||||
"_maxAge": null
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Fri, 15 Oct 2021 12:29:16 GMT"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "551"
|
||||
},
|
||||
{
|
||||
"name": "ETag",
|
||||
"value": "W/\"227-micuvGYwtEZN542D1sTL0hAZaRs\""
|
||||
},
|
||||
{
|
||||
"name": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
},
|
||||
{
|
||||
"name": "set-cookie",
|
||||
"value": "sails.sid=s%3AMp2gGgeCCDM4sRS_MfL1q-hAkL3bAk84.9XT7TTW8QzueQqtQ6bQM%2BgHqiUBbkJSfgM5CbfhFreQ; Path=/; HttpOnly"
|
||||
},
|
||||
{
|
||||
"name": "Connection",
|
||||
"value": "keep-alive"
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"size": 551,
|
||||
"mimeType": "application/json; charset=utf-8",
|
||||
"text": "eyJhcmdzIjp7fSwiZGF0YSI6IiIsImZpbGVzIjp7fSwiZm9ybSI6eyJmb28xIjoiSERuWTgiLCJmb28yIjoiMTIuMyJ9LCJoZWFkZXJzIjp7IngtZm9yd2FyZGVkLXByb3RvIjoiaHR0cHMiLCJ4LWZvcndhcmRlZC1wb3J0IjoiNDQzIiwiaG9zdCI6InBvc3RtYW4tZWNoby5jb20iLCJ4LWFtem4tdHJhY2UtaWQiOiJSb290PTEtNjE2OTc0MWMtNWI5ZDEyMWI2N2FlZTI0MTUyMmQzMjE2IiwiY29udGVudC1sZW5ndGgiOiIyMCIsInVzZXItYWdlbnQiOiJHby1odHRwLWNsaWVudC8xLjEiLCJjb250ZW50LXR5cGUiOiJhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQ7IGNoYXJzZXQ9VVRGLTgiLCJjb29raWUiOiJzYWlscy5zaWQ9cyUzQVM1ZTd3MHpRMHhBc0N3aDlMOFQ2UjdRTFlDTzdfZ3RELnI4JTJCMnc5SVdxRUlmdVZrclpqbnh6bTJ4QURJazM0ektBV1hSUGFwciUyRkF3IiwiYWNjZXB0LWVuY29kaW5nIjoiZ3ppcCJ9LCJqc29uIjp7ImZvbzEiOiJIRG5ZOCIsImZvbzIiOiIxMi4zIn0sInVybCI6Imh0dHBzOi8vcG9zdG1hbi1lY2hvLmNvbS9wb3N0In0=",
|
||||
"encoding": "base64"
|
||||
},
|
||||
"redirectURL": null,
|
||||
"headersSize": 0,
|
||||
"bodySize": 551
|
||||
},
|
||||
"serverIPAddress": "44.193.31.23",
|
||||
"cache": {},
|
||||
"timings": {
|
||||
"dns": -1,
|
||||
"connect": -1,
|
||||
"ssl": -1,
|
||||
"send": 0,
|
||||
"wait": 303,
|
||||
"receive": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
1
tests/data/postman/__init__.py
Normal file
1
tests/data/postman/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
|
||||
1
tests/data/postman/intro.txt
Normal file
1
tests/data/postman/intro.txt
Normal file
@@ -0,0 +1 @@
|
||||
HttpRunner is an open source API testing tool that supports HTTP(S)/HTTP2/WebSocket/RPC network protocols, covering API testing, performance testing and digital experience monitoring (DEM) test types. Enjoy!
|
||||
BIN
tests/data/postman/logo.jpeg
Normal file
BIN
tests/data/postman/logo.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 316 KiB |
498
tests/data/postman/postman_collection.json
Normal file
498
tests/data/postman/postman_collection.json
Normal file
@@ -0,0 +1,498 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "0417a445-b206-4ea2-b1d2-5441afd6c6b9",
|
||||
"name": "postman collection demo",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "folder1",
|
||||
"item": [
|
||||
{
|
||||
"name": "folder2",
|
||||
"item": [
|
||||
{
|
||||
"name": "Get with params",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path?k1=v1&k2=v2",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "k1",
|
||||
"value": "v1"
|
||||
},
|
||||
{
|
||||
"key": "k2",
|
||||
"value": "v2"
|
||||
},
|
||||
{
|
||||
"key": "k3",
|
||||
"value": "v3",
|
||||
"disabled": true
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "get"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": [
|
||||
{
|
||||
"name": "Get with params case1",
|
||||
"originalRequest": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path?k1=v1&k2=v2",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "k1",
|
||||
"value": "v1"
|
||||
},
|
||||
{
|
||||
"key": "k2",
|
||||
"value": "v2"
|
||||
},
|
||||
{
|
||||
"key": "k3",
|
||||
"value": "v3",
|
||||
"disabled": true
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "get"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"status": "OK",
|
||||
"code": 200,
|
||||
"_postman_previewlanguage": "json",
|
||||
"header": [
|
||||
{
|
||||
"key": "Date",
|
||||
"value": "Mon, 16 May 2022 12:12:28 GMT"
|
||||
},
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"key": "Content-Length",
|
||||
"value": "508"
|
||||
},
|
||||
{
|
||||
"key": "Connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"key": "ETag",
|
||||
"value": "W/\"1fc-x4EIPFQzoLX0HenCFPx6HNfG0lc\""
|
||||
},
|
||||
{
|
||||
"key": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
},
|
||||
{
|
||||
"key": "set-cookie",
|
||||
"value": "sails.sid=s%3AX2aa_Z7gbcUqIWAjlBkytBRmQ4WCvc3D.pX9Qxh8aO9Ict0BL4CrRhdDJmz81UVmwFsV5Nx30Ils; Path=/; HttpOnly"
|
||||
}
|
||||
],
|
||||
"cookie": [],
|
||||
"body": "{\n \"args\": {\n \"k1\": \"v1\",\n \"k2\": \"v2\"\n },\n \"headers\": {\n \"x-forwarded-proto\": \"https\",\n \"x-forwarded-port\": \"443\",\n \"host\": \"postman-echo.com\",\n \"user-agent\": \"PostmanRuntime/7.29.0\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate, br\",\n \"cookie\": \"Cookie_1=c1; Cookie_2=c2; sails.sid=s%3AGX6aS9b_phvUSUk66w7ZBgWuOPI7IIKT.ayEGTaW4U35eAWyPz%2Fh6Q74DonNcbqw3H5Q5Zv%2BfKMY\"\n },\n \"url\": \"https://postman-echo.com/get?k1=v1&k2=v2\"\n}"
|
||||
},
|
||||
{
|
||||
"name": "Get with params case2",
|
||||
"originalRequest": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path?k1=v1&k3=v3",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "k1",
|
||||
"value": "v1"
|
||||
},
|
||||
{
|
||||
"key": "k2",
|
||||
"value": "v2",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "k3",
|
||||
"value": "v3"
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "get"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"status": "OK",
|
||||
"code": 200,
|
||||
"_postman_previewlanguage": "json",
|
||||
"header": [
|
||||
{
|
||||
"key": "Date",
|
||||
"value": "Mon, 16 May 2022 12:14:04 GMT"
|
||||
},
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"key": "Content-Length",
|
||||
"value": "504"
|
||||
},
|
||||
{
|
||||
"key": "Connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"key": "ETag",
|
||||
"value": "W/\"1f8-tMaKs4xmwr+3su3I8mcgR0p+ucw\""
|
||||
},
|
||||
{
|
||||
"key": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
},
|
||||
{
|
||||
"key": "set-cookie",
|
||||
"value": "sails.sid=s%3AMNuX_i0KgaP_KuuMpYB8RtCNipCGJWVw.4ETfPHxE81Omqb6Yli%2FezUU8CXyYBcN3%2Bxkx5htwh8Y; Path=/; HttpOnly"
|
||||
}
|
||||
],
|
||||
"cookie": [],
|
||||
"body": "{\n \"args\": {\n \"k1\": \"v1\",\n \"k3\": \"v3\"\n },\n \"headers\": {\n \"x-forwarded-proto\": \"https\",\n \"x-forwarded-port\": \"443\",\n \"host\": \"postman-echo.com\",\n \"user-agent\": \"PostmanRuntime/7.29.0\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate, br\",\n \"cookie\": \"Cookie_1=c1; Cookie_2=c2; sails.sid=s%3AX2aa_Z7gbcUqIWAjlBkytBRmQ4WCvc3D.pX9Qxh8aO9Ict0BL4CrRhdDJmz81UVmwFsV5Nx30Ils\"\n },\n \"url\": \"https://postman-echo.com/get?k1=v1&k3=v3\"\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "folder3",
|
||||
"item": [
|
||||
{
|
||||
"name": "Post form-data",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "formdata",
|
||||
"formdata": [
|
||||
{
|
||||
"key": "k1",
|
||||
"value": "v1",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "k2",
|
||||
"value": "v2",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "k3",
|
||||
"value": "v3",
|
||||
"type": "text",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "intro_key",
|
||||
"type": "file",
|
||||
"src": "intro.txt"
|
||||
},
|
||||
{
|
||||
"key": "logo_key",
|
||||
"type": "file",
|
||||
"src": "logo.jpeg"
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "post"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Post x-www-form-urlencoded",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "urlencoded",
|
||||
"urlencoded": [
|
||||
{
|
||||
"key": "k1",
|
||||
"value": "v1",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "k2",
|
||||
"value": "v2",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "k3",
|
||||
"value": "v3",
|
||||
"type": "text",
|
||||
"disabled": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "post"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Post raw json",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"k1\": \"v1\",\n \"k2\": \"v2\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "post"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Post raw text",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "have a nice day",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "post"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Get request headers",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "User-Agent",
|
||||
"value": "HttpRunner",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "User-Name",
|
||||
"value": "bbx",
|
||||
"type": "text",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "Connection",
|
||||
"value": "close",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "headers"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": [
|
||||
{
|
||||
"name": "Get request headers case1",
|
||||
"originalRequest": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "User-Agent",
|
||||
"value": "HttpRunner",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "User-Name",
|
||||
"value": "bbx",
|
||||
"type": "text",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "Cookie",
|
||||
"value": "Cookie_1=c1; Cookie_2=c2; sails.sid=s%3AGX6aS9b_phvUSUk66w7ZBgWuOPI7IIKT.ayEGTaW4U35eAWyPz%2Fh6Q74DonNcbqw3H5Q5Zv%2BfKMY",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://postman-echo.com/:path",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"postman-echo",
|
||||
"com"
|
||||
],
|
||||
"path": [
|
||||
":path"
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "path",
|
||||
"value": "headers"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"status": "OK",
|
||||
"code": 200,
|
||||
"_postman_previewlanguage": "json",
|
||||
"header": [
|
||||
{
|
||||
"key": "Date",
|
||||
"value": "Mon, 16 May 2022 12:14:25 GMT"
|
||||
},
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"key": "Content-Length",
|
||||
"value": "541"
|
||||
},
|
||||
{
|
||||
"key": "Connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"key": "ETag",
|
||||
"value": "W/\"21d-ld5UvFTaRM6lihVnvCj6mZm5Of0\""
|
||||
},
|
||||
{
|
||||
"key": "Vary",
|
||||
"value": "Accept-Encoding"
|
||||
}
|
||||
],
|
||||
"cookie": [],
|
||||
"body": "{\n \"headers\": {\n \"x-forwarded-proto\": \"https\",\n \"x-forwarded-port\": \"443\",\n \"host\": \"postman-echo.com\",\n \"user-agent\": \"HttpRunner\",\n \"cookie\": \"Cookie_1=c1; Cookie_2=c2; sails.sid=s%3AGX6aS9b_phvUSUk66w7ZBgWuOPI7IIKT.ayEGTaW4U35eAWyPz%2Fh6Q74DonNcbqw3H5Q5Zv%2BfKMY\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate, br\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4
tests/data/profile.yml
Normal file
4
tests/data/profile.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
headers:
|
||||
Content-Type: "application/x-www-form-urlencoded"
|
||||
cookies:
|
||||
UserName: "debugtalk"
|
||||
5
tests/data/profile_override.yml
Normal file
5
tests/data/profile_override.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
override: true
|
||||
headers:
|
||||
Content-Type: "application/x-www-form-urlencoded"
|
||||
cookies:
|
||||
UserName: "debugtalk"
|
||||
BIN
tests/data/sqlite.db
Normal file
BIN
tests/data/sqlite.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user