checkInfoEndpoint performs elementary checks for /info endpoint
|
func checkInfoEndpoint ( ) {
var expectedInfoKeys = [ ] string {
"BuildBranch" ,
"BuildCommit" ,
"BuildTime" ,
"BuildVersion" ,
"OCP_DB_version" ,
"DVO_DB_version" ,
"UtilsVersion" ,
}
f := frisby . Create ( "Check the /info endpoint" ) . Get ( apiURL + "info" )
setAuthHeaderForOrganization ( f , knownOrganizations [ 0 ] )
f . Send ( )
f . ExpectStatus ( 200 )
f . ExpectHeader ( contentTypeHeader , "application/json; charset=utf-8" )
|
check the response
|
text , err := f . Resp . Content ( )
if err != nil {
f . AddError ( err . Error ( ) )
} else {
response := InfoResponse { }
err := json . Unmarshal ( text , & response )
if err != nil {
f . AddError ( err . Error ( ) )
}
if response . Status != "ok" {
f . AddError ( "Expecting 'status' to be set to 'ok'" )
}
if len ( response . Info ) == 0 {
f . AddError ( "Info node is empty" )
}
for _ , expectedKey := range expectedInfoKeys {
_ , found := response . Info [ expectedKey ]
if ! found {
f . AddError ( "Info node does not contain key " + expectedKey )
}
}
}
f . PrintReport ( )
}
|