add feature to disable test case
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
5
go.mod
5
go.mod
@@ -5,8 +5,13 @@ go 1.21.0
|
||||
require github.com/iancoleman/orderedmap v0.3.0
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
||||
github.com/go-ldap/ldap/v3 v3.4.6 // indirect
|
||||
github.com/google/uuid v1.3.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
golang.org/x/crypto v0.13.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
)
|
||||
|
58
go.sum
58
go.sum
@@ -1,5 +1,16 @@
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
||||
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
|
||||
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
@@ -7,7 +18,54 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@@ -139,6 +139,10 @@ func ReadInput(data []byte, testDefinitions *TestDefinitions) {
|
||||
if val, ok := thisTestCaseMap.Get("description"); ok {
|
||||
thisTestCase.Description = val.(string)
|
||||
}
|
||||
// Disabled
|
||||
if val, ok := thisTestCaseMap.Get("disabled"); ok {
|
||||
thisTestCase.Disabled = val.(bool)
|
||||
}
|
||||
// Body
|
||||
if val, ok := thisTestCaseMap.Get("body"); ok {
|
||||
// Create a normal string map for all the body key-value pairs
|
||||
|
6
main.go
6
main.go
@@ -44,6 +44,12 @@ func main() {
|
||||
|
||||
// Perform specified test cases
|
||||
for i := range testDefinitions.TestCases {
|
||||
|
||||
if testDefinitions.TestCases[i].Disabled {
|
||||
fmt.Printf("\nSkipping disabled test '%s'\n", testDefinitions.TestCases[i].Name)
|
||||
continue
|
||||
}
|
||||
|
||||
RunTest(&testDefinitions.TestCases[i])
|
||||
success, err := CheckResults(&testDefinitions.TestCases[i])
|
||||
if err != nil {
|
||||
|
@@ -11,6 +11,7 @@ type TestDefinitions struct {
|
||||
|
||||
type TestCase struct {
|
||||
Name string
|
||||
Disabled bool `json:"disabled"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
Description string `json:"description"`
|
||||
|
145
tests.json
145
tests.json
@@ -76,12 +76,133 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
"test5": {
|
||||
"path": "/api/admin/user/delete",
|
||||
"method": "POST",
|
||||
"description": "try to delete non-existing user account",
|
||||
"body": {
|
||||
"userName": "test"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "400"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contains": {
|
||||
"error": "attempt to delete non-existing username"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test10": {
|
||||
"path": "/api/admin/unlock",
|
||||
"disabled": true,
|
||||
"method": "POST",
|
||||
"description": "provide unlock key",
|
||||
"body": {
|
||||
"secretKey": "Example32ByteSecretKey0123456789"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "200"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test11": {
|
||||
"path": "/api/admin/unlock",
|
||||
"disabled": true,
|
||||
"method": "POST",
|
||||
"description": "repeat provide unlock key",
|
||||
"body": {
|
||||
"secretKey": "Example32ByteSecretKey0123456789"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "400"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test20": {
|
||||
"path": "/api/secret/list",
|
||||
"disabled": false,
|
||||
"method": "GET",
|
||||
"description": "List secrets",
|
||||
"header": {
|
||||
"Authorization": "Bearer %ACCESS_TOKEN%"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "200"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test21": {
|
||||
"path": "/api/secret/retrieve",
|
||||
"method": "POST",
|
||||
"description": "get existing secret",
|
||||
"body": {
|
||||
"deviceName": "adcp01.cdc.home",
|
||||
"deviceCategory": "windows-server",
|
||||
"userName": "dummy@cdc.home"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "200"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test22": {
|
||||
"path": "/api/secret/update",
|
||||
"method": "POST",
|
||||
"description": "update existing secret",
|
||||
"body": {
|
||||
"deviceName": "adcp01.cdc.home",
|
||||
"deviceCategory": "windows-server",
|
||||
"userName": "dummy@cdc.home",
|
||||
"secretValue": "TheAlphabet29"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "200"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test23": {
|
||||
"path": "/api/secret/delete",
|
||||
"method": "POST",
|
||||
"description": "delete existing secret",
|
||||
"body": {
|
||||
"deviceName": "adcp01.cdc.home",
|
||||
"deviceCategory": "windows-server",
|
||||
"userName": "dummy@cdc.home"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
"contains": {
|
||||
"http_status": "200"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test24": {
|
||||
"path": "/api/secret/store",
|
||||
"method": "POST",
|
||||
"description": "store new secret",
|
||||
"body": {
|
||||
"safeId": 1,
|
||||
"deviceName": "adcp01.cdc.home",
|
||||
"deviceCategory": "windows-server",
|
||||
"userName": "dummy@cdc.home",
|
||||
@@ -94,20 +215,14 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"test99": {
|
||||
"path": "/api/secret/list",
|
||||
"method": "GET",
|
||||
"description": "List secrets",
|
||||
"header": {
|
||||
"Authorization": "Bearer %ACCESS_TOKEN%"
|
||||
},
|
||||
},
|
||||
"test25": {
|
||||
"path": "/api/secret/retrieve",
|
||||
"method": "POST",
|
||||
"description": "test retrieving the new secret",
|
||||
"body": {
|
||||
"Hostname":"host999.cdc.home",
|
||||
"BootTypeUefi":true,
|
||||
"parent": {
|
||||
"childKey": "childValue"
|
||||
}
|
||||
"deviceName": "adcp01.cdc.home",
|
||||
"userName": "dummy@cdc.home"
|
||||
},
|
||||
"expect": {
|
||||
"header": {
|
||||
@@ -116,7 +231,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"url": "https://10.63.39.130:8443",
|
||||
"insecure": true,
|
||||
|
Reference in New Issue
Block a user