Repository: elastic/ecctl
Pull request #48 (2019-11-15 03:08:08)

go.mod: Update cloud-sdk-go to version v1.0.0-bc4
## Description
<!--- Describe your changes in detail. -->
Updates cloud-sdk-go to version v1.0.0-bc4 in th go.mod file and updates
the required Golang source files. Since a change was merged that is now
able to obtain the underlying response message from the http.Body,
updates all of our tests which relied on the unknown error (status xxx).

Also updates the deployment_example.json provided in `deployment
create` which now has the correct non-deprecated zone_count setting

**Now users will be able to see the underlying reason of all API errors**
**without the need to use the --verbose flag**

## TODO

- [x] Rebase after #47 is merged to update the docs.


Patch:
diff --git a/cmd/deployment/create.go b/cmd/deployment/create.go
index 028c9ea..40213a6 100644
--- a/cmd/deployment/create.go
+++ b/cmd/deployment/create.go
@@ -94,7 +94,6 @@ $ cat deployment_example.json
                 "ref_id": "my-kibana-instance",
                 "elasticsearch_cluster_ref_id": "my-es-cluster",
                 "plan": {
-                    "zone_count": 1,
                     "kibana": {
                         "version": "6.8.4"
                     },
@@ -102,7 +101,8 @@ $ cat deployment_example.json
                         {
                             "instance_configuration_id": "kibana",
                             "memory_per_node": 1024,
-                            "node_count_per_zone": 1
+                            "node_count_per_zone": 1,
+                            "zone_count": 1
                         }
                     ]
                 }
diff --git a/docs/ecctl_deployment_create.md b/docs/ecctl_deployment_create.md
index b0610dd..3a9e0a9 100644
--- a/docs/ecctl_deployment_create.md
+++ b/docs/ecctl_deployment_create.md
@@ -74,7 +74,6 @@ $ cat deployment_example.json
                 "ref_id": "my-kibana-instance",
                 "elasticsearch_cluster_ref_id": "my-es-cluster",
                 "plan": {
-                    "zone_count": 1,
                     "kibana": {
                         "version": "6.8.4"
                     },
@@ -82,7 +81,8 @@ $ cat deployment_example.json
                         {
                             "instance_configuration_id": "kibana",
                             "memory_per_node": 1024,
-                            "node_count_per_zone": 1
+                            "node_count_per_zone": 1,
+                            "zone_count": 1
                         }
                     ]
                 }
diff --git a/go.mod b/go.mod
index caa4afb..bf894d5 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/chzyer/logex v1.1.10 // indirect
 	github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
 	github.com/davecgh/go-spew v1.1.1
-	github.com/elastic/cloud-sdk-go v1.0.0-bc3
+	github.com/elastic/cloud-sdk-go v1.0.0-bc4
 	github.com/elastic/uptd v1.0.0
 	github.com/ghodss/yaml v1.0.0
 	github.com/go-openapi/runtime v0.19.8
diff --git a/go.sum b/go.sum
index e856a43..fb4cc69 100644
--- a/go.sum
+++ b/go.sum
@@ -9,8 +9,10 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
 github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
 github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA=
 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/asaskevich/govalidator v0.0.0-20170425121227-4918b99a7cb9/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
@@ -49,8 +51,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
 github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
 github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
-github.com/elastic/cloud-sdk-go v1.0.0-bc3 h1:giV/eTC5ZpovZr124o6/2uB/OP4CcmISTSSsd4+Rgd0=
-github.com/elastic/cloud-sdk-go v1.0.0-bc3/go.mod h1:zhBhuQcIJKsXh24Rf+LNkJdgRvaIJo7Gn9h/TWL0Kks=
+github.com/elastic/cloud-sdk-go v1.0.0-bc4 h1:8Gc/gFos+dJv992c8FQ06X9Mx080p2ceuiB1dUPWeUA=
+github.com/elastic/cloud-sdk-go v1.0.0-bc4/go.mod h1:19tuRaJglGTECDJfiWEDMOVj23ZL+9+YYoIV1fZIGzc=
 github.com/elastic/uptd v1.0.0 h1:oUhbbTK6hjFYB5w5dwjo1HtbqrWyLiqj+6Sb05oawU8=
 github.com/elastic/uptd v1.0.0/go.mod h1:2Pm07gLal/a/gTPq3el2QgOjoxu97pB2I17AprXxa48=
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
@@ -89,6 +91,8 @@ github.com/go-openapi/jsonreference v0.18.0 h1:oP2OUNdG1l2r5kYhrfVMXO54gWmzcfAwP
 github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
 github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
 github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
+github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o=
+github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
 github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
 github.com/go-openapi/loads v0.18.0 h1:2A3goxrC4KuN8ZrMKHCqAAugtq6A6WfXVfOIKUbZ4n0=
 github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
@@ -96,12 +100,12 @@ github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf
 github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs=
 github.com/go-openapi/loads v0.19.3 h1:jwIoahqCmaA5OBoc/B+1+Mu2L0Gr8xYQnbeyQEo/7b0=
 github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI=
+github.com/go-openapi/loads v0.19.4 h1:5I4CCSqoWzT+82bBkNIvmLc0UOsoKKQ4Fz+3VxOB7SY=
+github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk=
 github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA=
 github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE=
 github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64=
 github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4=
-github.com/go-openapi/runtime v0.19.7 h1:b2zcE9GCjDVtguugU7+S95vkHjwQEjz/lB+8LOuA9Nw=
-github.com/go-openapi/runtime v0.19.7/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo=
 github.com/go-openapi/runtime v0.19.8 h1:la3rOpJ+UnJSCgsgMv/xKHCMCpKJtFVa7ai4mPnV2ts=
 github.com/go-openapi/runtime v0.19.8/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo=
 github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
@@ -130,8 +134,8 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+
 github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
 github.com/go-openapi/validate v0.19.3 h1:PAH/2DylwWcIU1s0Y7k3yNmeAgWOcKrNE2Q7Ww/kCg4=
 github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo=
-github.com/go-openapi/validate v0.19.4 h1:LGjO87VyXY3bIKjlYpXSFuLRG2mTeuYlZyeNwFFWpyM=
-github.com/go-openapi/validate v0.19.4/go.mod h1:BkJ0ZmXui7yB0bJXWSXgLPNTmbLVeX/3D1xn/N9mMUM=
+github.com/go-openapi/validate v0.19.5 h1:QhCBKRYqZR+SKo4gl1lPhPahope8/RLt6EVgY8X80w0=
+github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4=
 github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -191,6 +195,8 @@ github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN
 github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
 github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
+github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
 github.com/marclop/elasticsearch-cli v0.0.0-20190212132418-ee09f7ae57f1 h1:AjKJSp3BJvuT8IZI0qmK4UtST/Gl+W+ohf7QO87Xfd4=
 github.com/marclop/elasticsearch-cli v0.0.0-20190212132418-ee09f7ae57f1/go.mod h1:5IsNi9k3pZY5PtppCpl0QRBsmmtUOb4vJMoky6DXjy8=
 github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
@@ -227,6 +233,7 @@ github.com/russross/blackfriday v0.0.0-20170728175326-4048872b16cc h1:Ng688TEbTG
 github.com/russross/blackfriday v0.0.0-20170728175326-4048872b16cc/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
 github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
 github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
@@ -248,8 +255,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
 github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
 github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
 github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
-github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
-github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
 github.com/spf13/viper v1.5.0 h1:GpsTwfsQ27oS/Aha/6d1oD7tpKIqWnOA6tgOX9HHkt4=
 github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -268,6 +273,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=
 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
 github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow=
 github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
@@ -275,6 +281,8 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
 go.mongodb.org/mongo-driver v1.1.1 h1:Sq1fR+0c58RME5EoqKdjkiQAmPjmfHlZOoRI6fTUOcs=
 go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
+go.mongodb.org/mongo-driver v1.1.2 h1:jxcFYjlkl8xaERsgLo+RNquI0epW6zuy/ZRQs6jnrFA=
+go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
 go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
 go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
@@ -336,6 +344,7 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
 golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190211224914-44bee7e801e4/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=


Test patch:
diff --git a/pkg/deployment/apm/resync_test.go b/pkg/deployment/apm/resync_test.go
index b71ff35..2cf4609 100644
--- a/pkg/deployment/apm/resync_test.go
+++ b/pkg/deployment/apm/resync_test.go
@@ -66,7 +66,7 @@ func TestResync(t *testing.T) {
 					Body:       mock.NewStringBody(`{}`),
 				}}),
 			}},
-			wantErr: errors.New("unknown error (status 403)"),
+			wantErr: errors.New("{}"),
 		},
 		{
 			name: "Fails due to API error",
diff --git a/pkg/deployment/create_test.go b/pkg/deployment/create_test.go
index 8dc7e8f..8abf08f 100644
--- a/pkg/deployment/create_test.go
+++ b/pkg/deployment/create_test.go
@@ -77,12 +77,12 @@ func TestCreate(t *testing.T) {
 				API:     api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
 				Request: &models.DeploymentCreateRequest{},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("error"),
 		},
 		{
 			name: "succeeds",
 			args: args{params: CreateParams{
-				API: api.NewMock(mock.New200Response(mock.NewStringBody(basicESCluster))),
+				API: api.NewMock(mock.New201Response(mock.NewStringBody(basicESCluster))),
 				Request: &models.DeploymentCreateRequest{
 					Name: "my example cluster",
 					Resources: &models.DeploymentCreateResources{
@@ -129,7 +129,7 @@ func TestCreate(t *testing.T) {
 			name: "succeeds with idempotency ID",
 			args: args{params: CreateParams{
 				RequestID: "1232131231",
-				API:       api.NewMock(mock.New200Response(mock.NewStringBody(basicESCluster))),
+				API:       api.NewMock(mock.New201Response(mock.NewStringBody(basicESCluster))),
 				Request: &models.DeploymentCreateRequest{
 					Name: "my example cluster",
 					Resources: &models.DeploymentCreateResources{
diff --git a/pkg/deployment/delete_test.go b/pkg/deployment/delete_test.go
index 3216d05..49ed7b3 100644
--- a/pkg/deployment/delete_test.go
+++ b/pkg/deployment/delete_test.go
@@ -54,7 +54,7 @@ func TestDelete(t *testing.T) {
 				API:          api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
 				DeploymentID: util.ValidClusterID,
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("error"),
 		},
 		{
 			name: "Succeeds",
diff --git a/pkg/deployment/elasticsearch/create_test.go b/pkg/deployment/elasticsearch/create_test.go
index e70c72c..8c4ecae 100644
--- a/pkg/deployment/elasticsearch/create_test.go
+++ b/pkg/deployment/elasticsearch/create_test.go
@@ -225,14 +225,9 @@ func TestCreate(t *testing.T) {
 		{
 			name: "fails when the API returns an error",
 			args: args{params: CreateParams{
-				API: api.NewMock(mock.Response{
-					Response: http.Response{
-						StatusCode: 500,
-						Body:       mock.NewStringBody(`{}`),
-					},
-				}),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{}`))),
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("{}"),
 		},
 		{
 			name: "succeeds with tracking",
diff --git a/pkg/deployment/elasticsearch/delete_test.go b/pkg/deployment/elasticsearch/delete_test.go
index 4fc3238..2338f21 100644
--- a/pkg/deployment/elasticsearch/delete_test.go
+++ b/pkg/deployment/elasticsearch/delete_test.go
@@ -80,7 +80,7 @@ func TestDeleteCluster(t *testing.T) {
 					}),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("{}"),
 		},
 		{
 			name: "fails due to cluster not being stopped",
@@ -104,15 +104,10 @@ func TestDeleteCluster(t *testing.T) {
 			args: args{params: DeleteClusterParams{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("{}"),
 		},
 		{
 			name: "fails due to missing cluster ID",
diff --git a/pkg/deployment/elasticsearch/diagnose_test.go b/pkg/deployment/elasticsearch/diagnose_test.go
index ad8463d..bf871e7 100644
--- a/pkg/deployment/elasticsearch/diagnose_test.go
+++ b/pkg/deployment/elasticsearch/diagnose_test.go
@@ -75,14 +75,14 @@ func TestDiagnose(t *testing.T) {
 									"Content-Type": []string{"application/zip"},
 								},
 								StatusCode: 500,
-								Body:       mock.NewStringBody("something diagnosed"),
+								Body:       mock.NewStringBody("something not diagnosed"),
 							},
 						}),
 					},
 				},
 				buf: new(bytes.Buffer),
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("something not diagnosed"),
 		},
 		{
 			name: "empty params return error",
diff --git a/pkg/deployment/elasticsearch/instances/lifecycle_test.go b/pkg/deployment/elasticsearch/instances/lifecycle_test.go
index 6e58871..d8c13c6 100644
--- a/pkg/deployment/elasticsearch/instances/lifecycle_test.go
+++ b/pkg/deployment/elasticsearch/instances/lifecycle_test.go
@@ -68,15 +68,10 @@ func TestResume(t *testing.T) {
 			args: args{params: Params{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("{}"),
 		},
 	}
 	for _, tt := range tests {
@@ -127,15 +122,10 @@ func TestPause(t *testing.T) {
 			args: args{params: Params{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New("{}"),
 		},
 	}
 	for _, tt := range tests {
diff --git a/pkg/deployment/elasticsearch/instances/reducer_test.go b/pkg/deployment/elasticsearch/instances/reducer_test.go
index 6bcd34b..d6ccf50 100644
--- a/pkg/deployment/elasticsearch/instances/reducer_test.go
+++ b/pkg/deployment/elasticsearch/instances/reducer_test.go
@@ -81,12 +81,9 @@ func TestList(t *testing.T) {
 			name: "fails due to API error",
 			args: args{params: util.ClusterParams{
 				ClusterID: util.ValidClusterID,
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: 500,
-					Body:       mock.NewStructBody(models.ElasticsearchClusterInfo{}),
-				}}),
+				API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due parameter validation",
diff --git a/pkg/deployment/elasticsearch/instances/routing_test.go b/pkg/deployment/elasticsearch/instances/routing_test.go
index 5026dce..513034e 100644
--- a/pkg/deployment/elasticsearch/instances/routing_test.go
+++ b/pkg/deployment/elasticsearch/instances/routing_test.go
@@ -62,16 +62,10 @@ func TestStartRouting(t *testing.T) {
 			args: args{params: Params{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							Status:     http.StatusText(http.StatusInternalServerError),
-							StatusCode: http.StatusInternalServerError,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation",
@@ -128,16 +122,10 @@ func TestStopRouting(t *testing.T) {
 			args: args{params: Params{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							Status:     http.StatusText(http.StatusInternalServerError),
-							StatusCode: http.StatusInternalServerError,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation",
diff --git a/pkg/deployment/elasticsearch/list_test.go b/pkg/deployment/elasticsearch/list_test.go
index e3b309f..c345ce8 100644
--- a/pkg/deployment/elasticsearch/list_test.go
+++ b/pkg/deployment/elasticsearch/list_test.go
@@ -116,14 +116,9 @@ func TestList(t *testing.T) {
 		{
 			name: "fails due to api error",
 			args: args{params: ListParams{
-				API: api.NewMock(mock.Response{
-					Response: http.Response{
-						StatusCode: 500,
-						Body:       mock.NewStringBody(`{}`),
-					},
-				}),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation",
diff --git a/pkg/deployment/elasticsearch/metadata/cluster_metadata_test.go b/pkg/deployment/elasticsearch/metadata/cluster_metadata_test.go
index bc09ee0..730790f 100644
--- a/pkg/deployment/elasticsearch/metadata/cluster_metadata_test.go
+++ b/pkg/deployment/elasticsearch/metadata/cluster_metadata_test.go
@@ -92,16 +92,14 @@ func TestGetSettings(t *testing.T) {
 					StatusCode: 400,
 				}}),
 			}},
-			want:    nil,
 			wantErr: true,
-			error:   errors.New("unknown error (status 400)"),
+			error:   errors.New(errorResponse),
 		},
 		{
 			name: "Get cluster metadata settings fails if api reference is empty",
 			args: args{params: util.ClusterParams{
 				ClusterID: util.ValidClusterID,
 			}},
-			want:    nil,
 			wantErr: true,
 			error:   errors.New("api reference is required for command"),
 		},
@@ -110,7 +108,6 @@ func TestGetSettings(t *testing.T) {
 			args: args{params: util.ClusterParams{
 				ClusterID: util.InvalidClusterID,
 			}},
-			want:    nil,
 			wantErr: true,
 			error:   errors.New("cluster id should have a length of 32 characters"),
 		},
@@ -184,7 +181,7 @@ func TestUpdateClusterMetadataSettings(t *testing.T) {
 			}},
 			want:    nil,
 			wantErr: true,
-			error:   errors.New("unknown error (status 400)"),
+			error:   errors.New(errorResponse),
 		},
 		{
 			name:    "Get cluster metadata settings fails if settings reference is empty",
diff --git a/pkg/deployment/elasticsearch/monitoring/monitoring_test.go b/pkg/deployment/elasticsearch/monitoring/monitoring_test.go
index 168c394..6d06190 100644
--- a/pkg/deployment/elasticsearch/monitoring/monitoring_test.go
+++ b/pkg/deployment/elasticsearch/monitoring/monitoring_test.go
@@ -59,18 +59,12 @@ func TestEnable(t *testing.T) {
 			name: "fails due to API error",
 			args: args{params: EnableParams{
 				ClusterParams: util.ClusterParams{
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: http.StatusInternalServerError,
-							Status:     http.StatusText(http.StatusInternalServerError),
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 					ClusterID: util.ValidClusterID,
 				},
 				TargetID: util.ValidClusterID,
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to empty parameters",
@@ -155,17 +149,11 @@ func TestDisable(t *testing.T) {
 			name: "fails due to API error",
 			args: args{params: DisableParams{
 				ClusterParams: util.ClusterParams{
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: http.StatusInternalServerError,
-							Status:     http.StatusText(http.StatusInternalServerError),
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 					ClusterID: util.ValidClusterID,
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to empty parameters",
diff --git a/pkg/deployment/elasticsearch/plan/read_test.go b/pkg/deployment/elasticsearch/plan/read_test.go
index 7e9e3f7..6f18378 100644
--- a/pkg/deployment/elasticsearch/plan/read_test.go
+++ b/pkg/deployment/elasticsearch/plan/read_test.go
@@ -104,13 +104,9 @@ func TestGet(t *testing.T) {
 			name: "Fails when the API returns an error",
 			args: args{params: GetParams{Pending: true, ClusterParams: util.ClusterParams{
 				ClusterID: "8b43ed5e277f7ea6f13606fcf4027f9c",
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusInternalServerError,
-					Status:     http.StatusText(http.StatusInternalServerError),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
+				API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 	}
 	for _, tt := range tests {
@@ -177,13 +173,9 @@ func TestGetHistory(t *testing.T) {
 			name: "Fails when the API returns an error",
 			args: args{params: GetHistoryParams{ClusterParams: util.ClusterParams{
 				ClusterID: "8b43ed5e277f7ea6f13606fcf4027f9c",
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusInternalServerError,
-					Status:     http.StatusText(http.StatusInternalServerError),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
+				API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 	}
 	for _, tt := range tests {
diff --git a/pkg/deployment/elasticsearch/query_test.go b/pkg/deployment/elasticsearch/query_test.go
index 210169f..655d289 100644
--- a/pkg/deployment/elasticsearch/query_test.go
+++ b/pkg/deployment/elasticsearch/query_test.go
@@ -162,17 +162,10 @@ func TestQuery(t *testing.T) {
 				RestRequest: RestRequest{Method: "GET"},
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{Response: http.Response{
-						StatusCode: http.StatusInternalServerError,
-						Body: mock.NewStructBody(models.ElasticsearchClusterInfo{
-							Metadata: &models.ClusterMetadataInfo{
-								Endpoint: "some-host",
-							},
-						}),
-					}}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails to create an elasticsearch-cli app",
diff --git a/pkg/deployment/elasticsearch/reallocate_test.go b/pkg/deployment/elasticsearch/reallocate_test.go
index 04a05cf..82256c6 100644
--- a/pkg/deployment/elasticsearch/reallocate_test.go
+++ b/pkg/deployment/elasticsearch/reallocate_test.go
@@ -60,21 +60,10 @@ func TestReallocate(t *testing.T) {
 				OutputDevice: output.NewDevice(new(bytes.Buffer)),
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body: mock.NewStructBody(models.ElasticsearchClusterInfo{
-								Topology: &models.ClusterTopologyInfo{
-									Instances: []*models.ClusterInstanceInfo{
-										{InstanceName: ec.String("instance-00000001")},
-									},
-								},
-							}),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "failed obtaining instances"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed obtaining instances"}`),
 		},
 		{
 			name: "Fails performing the move operation",
@@ -93,15 +82,12 @@ func TestReallocate(t *testing.T) {
 								},
 							}),
 						},
-					}, mock.Response{ // MOVE
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					}, mock.New500Response( // MOVE
+						mock.NewStringBody(`{"error": "failed moving instances"}`),
+					)),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed moving instances"}`),
 		},
 		{
 			name: "Succeeds when no instances are specified",
diff --git a/pkg/deployment/elasticsearch/restart_test.go b/pkg/deployment/elasticsearch/restart_test.go
index 5c15051..871f242 100644
--- a/pkg/deployment/elasticsearch/restart_test.go
+++ b/pkg/deployment/elasticsearch/restart_test.go
@@ -95,15 +95,10 @@ func TestRestartCluster(t *testing.T) {
 			args: args{params: RestartClusterParams{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation (Cluster ID)",
diff --git a/pkg/deployment/elasticsearch/resync_test.go b/pkg/deployment/elasticsearch/resync_test.go
index c6fb8a9..d14701a 100644
--- a/pkg/deployment/elasticsearch/resync_test.go
+++ b/pkg/deployment/elasticsearch/resync_test.go
@@ -24,13 +24,16 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/davecgh/go-spew/spew"
 	"github.com/elastic/cloud-sdk-go/pkg/api"
 	"github.com/elastic/cloud-sdk-go/pkg/api/mock"
 
 	"github.com/elastic/ecctl/pkg/util"
 )
 
+const errStr = `{
+  "errors": null
+}`
+
 func TestResyncCluster(t *testing.T) {
 	type args struct {
 		params ResyncClusterParams
@@ -59,13 +62,10 @@ func TestResyncCluster(t *testing.T) {
 			args: args{params: ResyncClusterParams{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{Response: http.Response{
-						StatusCode: http.StatusForbidden,
-						Body:       mock.NewStringBody(`{}`),
-					}}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{}`))),
 				},
 			}},
-			wantErr: errors.New("unknown error (status 403)"),
+			wantErr: errors.New(errStr),
 		},
 		{
 			name: "Fails due to API error",
@@ -102,7 +102,6 @@ func TestResyncCluster(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			if err := ResyncCluster(tt.args.params); !reflect.DeepEqual(err, tt.wantErr) {
-				spew.Dump(err, tt.wantErr)
 				t.Errorf("ResyncCluster() error = %v, wantErr %v", err, tt.wantErr)
 			}
 		})
diff --git a/pkg/deployment/elasticsearch/search_test.go b/pkg/deployment/elasticsearch/search_test.go
index 7662bd7..c3c9bb9 100644
--- a/pkg/deployment/elasticsearch/search_test.go
+++ b/pkg/deployment/elasticsearch/search_test.go
@@ -62,13 +62,10 @@ func TestSearchClusters(t *testing.T) {
 			name: "Search clusters fails if search api call fails",
 			args: args{params: SearchClusterParams{
 				Request: models.SearchRequest{Query: &models.QueryContainer{}},
-				API: api.NewMock(mock.Response{Response: http.Response{
-					Body:       mock.NewStringBody("{}"),
-					StatusCode: 404,
-				}}),
+				API:     api.NewMock(mock.New404Response(mock.NewStringBody(`{}`))),
 			}},
 			wantErr: true,
-			error:   errors.New("unknown error (status 404)"),
+			error:   errors.New("{}"),
 		},
 		{
 			name: "Search clusters succeeds if search api call succeeds",
diff --git a/pkg/deployment/elasticsearch/shutdown_test.go b/pkg/deployment/elasticsearch/shutdown_test.go
index 143c26e..038f362 100644
--- a/pkg/deployment/elasticsearch/shutdown_test.go
+++ b/pkg/deployment/elasticsearch/shutdown_test.go
@@ -81,15 +81,10 @@ func TestShutdownCluster(t *testing.T) {
 			args: args{params: ShutdownClusterParams{
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody(`{}`),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation (Cluster ID)",
diff --git a/pkg/deployment/elasticsearch/upgrade_test.go b/pkg/deployment/elasticsearch/upgrade_test.go
index a718a41..5adc370 100644
--- a/pkg/deployment/elasticsearch/upgrade_test.go
+++ b/pkg/deployment/elasticsearch/upgrade_test.go
@@ -86,15 +86,10 @@ func TestUpgrade(t *testing.T) {
 				Version: "5.0.0",
 				ClusterParams: util.ClusterParams{
 					ClusterID: util.ValidClusterID,
-					API: api.NewMock(mock.Response{
-						Response: http.Response{
-							StatusCode: 500,
-							Body:       mock.NewStringBody("{}"),
-						},
-					}),
+					API:       api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "succeeds without tracking",
diff --git a/pkg/deployment/kibana/resync_test.go b/pkg/deployment/kibana/resync_test.go
index de16ac0..70a25b7 100644
--- a/pkg/deployment/kibana/resync_test.go
+++ b/pkg/deployment/kibana/resync_test.go
@@ -63,10 +63,10 @@ func TestResync(t *testing.T) {
 				ID: "2c221bd86b7f48959a59ee3128d5c5e8",
 				API: api.NewMock(mock.Response{Response: http.Response{
 					StatusCode: http.StatusForbidden,
-					Body:       mock.NewStringBody(`{}`),
+					Body:       mock.NewStringBody(`{"error": "some forbidden error"}`),
 				}}),
 			}},
-			wantErr: errors.New("unknown error (status 403)"),
+			wantErr: errors.New(`{"error": "some forbidden error"}`),
 		},
 		{
 			name: "Fails due to API error",
diff --git a/pkg/deployment/list_test.go b/pkg/deployment/list_test.go
index dd16e02..4c2c1e6 100644
--- a/pkg/deployment/list_test.go
+++ b/pkg/deployment/list_test.go
@@ -99,9 +99,9 @@ func TestList(t *testing.T) {
 		{
 			name: "fails on API error",
 			args: args{params: ListParams{
-				API: api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Succeeds",
diff --git a/pkg/deployment/restore_test.go b/pkg/deployment/restore_test.go
index 3e709d0..0d2f3fc 100644
--- a/pkg/deployment/restore_test.go
+++ b/pkg/deployment/restore_test.go
@@ -51,10 +51,10 @@ func TestRestore(t *testing.T) {
 		{
 			name: "fails on API error",
 			args: args{params: RestoreParams{
-				API:          api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
+				API:          api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				DeploymentID: util.ValidClusterID,
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Succeeds",
diff --git a/pkg/deployment/search_test.go b/pkg/deployment/search_test.go
index 8ef4386..61ecaf8 100644
--- a/pkg/deployment/search_test.go
+++ b/pkg/deployment/search_test.go
@@ -51,10 +51,10 @@ func TestSearch(t *testing.T) {
 		{
 			name: "fails on API error",
 			args: args{params: SearchParams{
-				API:     api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
+				API:     api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				Request: &models.SearchRequest{},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Succeeds",
diff --git a/pkg/deployment/shutdown_test.go b/pkg/deployment/shutdown_test.go
index 95b40fd..7023bbd 100644
--- a/pkg/deployment/shutdown_test.go
+++ b/pkg/deployment/shutdown_test.go
@@ -51,10 +51,10 @@ func TestShutdown(t *testing.T) {
 		{
 			name: "fails on API error",
 			args: args{params: ShutdownParams{
-				API:          api.NewMock(mock.New500Response(mock.NewStringBody("error"))),
+				API:          api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				DeploymentID: util.ValidClusterID,
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Succeeds",
diff --git a/pkg/platform/allocator/allocator_test.go b/pkg/platform/allocator/allocator_test.go
index a77cea3..6009d27 100644
--- a/pkg/platform/allocator/allocator_test.go
+++ b/pkg/platform/allocator/allocator_test.go
@@ -128,14 +128,11 @@ func TestGet(t *testing.T) {
 			name: "Get fails due to API failure",
 			args: args{
 				params: GetParams{
-					ID: "an id",
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					ID:  "an id",
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Get Succeeds",
@@ -406,15 +403,10 @@ func TestList(t *testing.T) {
 		},
 		{
 			name: "List fails due to API error",
-			args: args{
-				params: ListParams{
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
-				},
-			},
-			err: errors.New("unknown error (status 500)"),
+			args: args{params: ListParams{
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
+			}},
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "List Succeeds",
diff --git a/pkg/platform/allocator/metadata_test.go b/pkg/platform/allocator/metadata_test.go
index 5dee381..6f970f0 100644
--- a/pkg/platform/allocator/metadata_test.go
+++ b/pkg/platform/allocator/metadata_test.go
@@ -102,14 +102,11 @@ func TestGetAllocatorMetadata(t *testing.T) {
 			name: "Get metadata fails due to API failure",
 			args: args{
 				params: MetadataGetParams{
-					ID: "an id",
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					ID:  "an id",
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Get metadata Succeeds",
diff --git a/pkg/platform/allocator/search_test.go b/pkg/platform/allocator/search_test.go
index 49bbb33..fbb9e62 100644
--- a/pkg/platform/allocator/search_test.go
+++ b/pkg/platform/allocator/search_test.go
@@ -64,14 +64,11 @@ func TestSearch(t *testing.T) {
 			name: "fails if search api call fails",
 			args: args{params: SearchParams{
 				Request: models.SearchRequest{Query: &models.QueryContainer{}},
-				API: api.NewMock(mock.Response{Response: http.Response{
-					Body:       mock.NewStringBody(`{"error":"invalid query"}`),
-					StatusCode: 404,
-				}}),
+				API:     api.NewMock(mock.New404Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
 			want:    nil,
 			wantErr: true,
-			error:   errors.New("unknown error (status 404)"),
+			error:   errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "succeeds if search api call succeeds",
diff --git a/pkg/platform/info_test.go b/pkg/platform/info_test.go
index 0d3cc9b..0c037bd 100644
--- a/pkg/platform/info_test.go
+++ b/pkg/platform/info_test.go
@@ -60,14 +60,10 @@ func TestGetInfo(t *testing.T) {
 		},
 		{
 			name: "fails due to API error",
-			args: args{params: GetInfoParams{API: api.NewMock(mock.Response{
-				Response: http.Response{
-					Status:     http.StatusText(http.StatusNotFound),
-					StatusCode: http.StatusNotFound,
-					Body:       mock.NewStringBody(`{}`),
-				},
-			})}},
-			err: errors.New("unknown error (status 404)"),
+			args: args{params: GetInfoParams{
+				API: api.NewMock(mock.New404Response(mock.NewStringBody(`{"error": "some error"}`))),
+			}},
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to parameter validation",
diff --git a/pkg/platform/instanceconfig/instanceconfig_test.go b/pkg/platform/instanceconfig/instanceconfig_test.go
index 740f4a9..5a4b4e1 100644
--- a/pkg/platform/instanceconfig/instanceconfig_test.go
+++ b/pkg/platform/instanceconfig/instanceconfig_test.go
@@ -98,13 +98,10 @@ func TestList(t *testing.T) {
 			name: "List fails on API error",
 			args: args{
 				params: ListParams{
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "List fails on parameter validation failure",
@@ -204,14 +201,11 @@ func TestGet(t *testing.T) {
 			name: "Get fails on API error",
 			args: args{
 				params: GetParams{
-					ID: "kibana",
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					ID:  "kibana",
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Get fails on parameter validation failure (API missing)",
@@ -329,13 +323,10 @@ func TestCreate(t *testing.T) {
 							},
 						},
 					},
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Create fails on parameter validation failure (API missing)",
@@ -424,13 +415,10 @@ func TestUpdate(t *testing.T) {
 							},
 						},
 					},
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Update fails on parameter validation failure (API missing)",
@@ -494,14 +482,11 @@ func TestDelete(t *testing.T) {
 			name: "Delete fails on API error",
 			args: args{
 				params: DeleteParams{
-					ID: "kibana",
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					ID:  "kibana",
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Delete fails on parameter validation failure (API missing)",
diff --git a/pkg/platform/proxy/filteredgroup/filtered_group_test.go b/pkg/platform/proxy/filteredgroup/filtered_group_test.go
index 222c650..6931d98 100644
--- a/pkg/platform/proxy/filteredgroup/filtered_group_test.go
+++ b/pkg/platform/proxy/filteredgroup/filtered_group_test.go
@@ -79,14 +79,10 @@ func TestShow(t *testing.T) {
 		{
 			name: "Proxies filtered group show fails with 403 Forbidden",
 			args: args{params: CommonParams{
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusForbidden,
-					Status:     http.StatusText(http.StatusForbidden),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
-				ID: "test1",
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
+				ID:  "test1",
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxies filtered group show fails due to empty API",
@@ -168,7 +164,7 @@ func TestCreate(t *testing.T) {
 					API: api.NewMock(mock.Response{Response: http.Response{
 						StatusCode: http.StatusForbidden,
 						Status:     http.StatusText(http.StatusForbidden),
-						Body:       mock.NewStringBody(`{}`),
+						Body:       mock.NewStringBody(`{"error": "some error"}`),
 					}}),
 					ID: "test2",
 				},
@@ -177,7 +173,7 @@ func TestCreate(t *testing.T) {
 				},
 				ExpectedProxiesCount: 15,
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxies filtered group create expected proxies count greater than 0 fails",
@@ -273,14 +269,10 @@ func TestDelete(t *testing.T) {
 		{
 			name: "Proxies filtered group delete fails with 403 Forbidden",
 			args: args{params: CommonParams{
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusForbidden,
-					Status:     http.StatusText(http.StatusForbidden),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
-				ID: "test1",
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
+				ID:  "test1",
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxies filtered group delete fails due to empty API",
@@ -362,7 +354,7 @@ func TestUpdate(t *testing.T) {
 						API: api.NewMock(mock.Response{Response: http.Response{
 							StatusCode: http.StatusForbidden,
 							Status:     http.StatusText(http.StatusForbidden),
-							Body:       mock.NewStringBody(`{}`),
+							Body:       mock.NewStringBody(`{"error": "some error"}`),
 						}}),
 						ID: "test2",
 					},
@@ -375,7 +367,7 @@ func TestUpdate(t *testing.T) {
 				Version: 1,
 			},
 			},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxies filtered group update expected proxies count greater than 0 fails",
@@ -607,14 +599,10 @@ func TestList(t *testing.T) {
 		{
 			name: "Proxies filtered group list fails with 403 Forbidden",
 			args: args{params: CommonParams{
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusForbidden,
-					Status:     http.StatusText(http.StatusForbidden),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
-				ID: "all",
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
+				ID:  "all",
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxies filtered group list fails due to empty API",
diff --git a/pkg/platform/proxy/proxy_test.go b/pkg/platform/proxy/proxy_test.go
index 084cdbb..f2cbba8 100644
--- a/pkg/platform/proxy/proxy_test.go
+++ b/pkg/platform/proxy/proxy_test.go
@@ -79,13 +79,9 @@ func TestList(t *testing.T) {
 		{
 			name: "Proxy list fails",
 			args: args{params: Params{
-				API: api.NewMock(mock.Response{Response: http.Response{
-					StatusCode: http.StatusForbidden,
-					Status:     http.StatusText(http.StatusForbidden),
-					Body:       mock.NewStringBody(`{}`),
-				}}),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Proxy list fails due to empty API",
@@ -154,14 +150,10 @@ func TestGet(t *testing.T) {
 			args: args{params: GetParams{
 				ID: "87b2c433c761",
 				Params: Params{
-					API: api.NewMock(mock.Response{Response: http.Response{
-						StatusCode: http.StatusForbidden,
-						Status:     http.StatusText(http.StatusForbidden),
-						Body:       mock.NewStringBody(`{}`),
-					}}),
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			}},
-			err: errors.New("unknown error (status 403)"),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Get proxy fails due to empty params.ID",
diff --git a/pkg/platform/role/add_blessing_test.go b/pkg/platform/role/add_blessing_test.go
index 8d4a9f6..bcc9e82 100644
--- a/pkg/platform/role/add_blessing_test.go
+++ b/pkg/platform/role/add_blessing_test.go
@@ -53,13 +53,13 @@ func TestAddBlessing(t *testing.T) {
 			name: "fails updating the role",
 			args: args{params: AddBlessingParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					`"failed creating role"`,
+					`{"error": "failed updating role"}`,
 				))),
 				Blessing: &models.Blessing{},
 				RunnerID: "some",
 				ID:       "one",
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed updating role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/create_test.go b/pkg/platform/role/create_test.go
index 64f7ab7..f6acfd2 100644
--- a/pkg/platform/role/create_test.go
+++ b/pkg/platform/role/create_test.go
@@ -51,11 +51,11 @@ func TestCreate(t *testing.T) {
 			name: "fails creating the role",
 			args: args{params: CreateParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					`"failed creating role"`,
+					`{"error": "failed creating role"}`,
 				))),
 				Role: &models.RoleAggregateCreateData{},
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed creating role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/delete_test.go b/pkg/platform/role/delete_test.go
index 658285d..3612850 100644
--- a/pkg/platform/role/delete_test.go
+++ b/pkg/platform/role/delete_test.go
@@ -50,11 +50,11 @@ func TestDelete(t *testing.T) {
 			name: "fails creating the role",
 			args: args{params: DeleteParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					`"failed creating role"`,
+					`{"error": "failed deleting role"}`,
 				))),
 				ID: "some",
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed deleting role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/list_test.go b/pkg/platform/role/list_test.go
index a41a710..2d4bebc 100644
--- a/pkg/platform/role/list_test.go
+++ b/pkg/platform/role/list_test.go
@@ -50,10 +50,10 @@ func TestList(t *testing.T) {
 			name: "fails on api error",
 			args: args{params: ListParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					"big failure",
+					`{"error": "failed listing roles"}`,
 				))),
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed listing roles"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/set_blessing_test.go b/pkg/platform/role/set_blessing_test.go
index 3869f6e..801fc29 100644
--- a/pkg/platform/role/set_blessing_test.go
+++ b/pkg/platform/role/set_blessing_test.go
@@ -52,12 +52,12 @@ func TestSetBlessings(t *testing.T) {
 			name: "fails updating the role",
 			args: args{params: SetBlessingsParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					`"failed creating role"`,
+					`{"error": "failed updating role"}`,
 				))),
 				Blessings: &models.Blessings{},
 				ID:        "one",
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed updating role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/show_test.go b/pkg/platform/role/show_test.go
index 9471524..df7a7c0 100644
--- a/pkg/platform/role/show_test.go
+++ b/pkg/platform/role/show_test.go
@@ -53,11 +53,11 @@ func TestShow(t *testing.T) {
 			name: "fails on api error",
 			args: args{params: ShowParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					"big failure",
+					`{"error": "failed getting role"}`,
 				))),
 				ID: "some",
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed getting role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/role/update_test.go b/pkg/platform/role/update_test.go
index 0ca44d1..cd9410c 100644
--- a/pkg/platform/role/update_test.go
+++ b/pkg/platform/role/update_test.go
@@ -52,12 +52,12 @@ func TestUpdate(t *testing.T) {
 			name: "fails updating the role",
 			args: args{params: UpdateParams{
 				API: api.NewMock(mock.New500Response(mock.NewStringBody(
-					`"failed creating role"`,
+					`{"error": "failed updating role"}`,
 				))),
 				Role: &models.Role{},
 				ID:   "one",
 			}},
-			err: errors.New("unknown error (status 500)"),
+			err: errors.New(`{"error": "failed updating role"}`),
 		},
 		{
 			name: "succeeds",
diff --git a/pkg/platform/snaprepo/repository_test.go b/pkg/platform/snaprepo/repository_test.go
index af35dea..ed34df3 100644
--- a/pkg/platform/snaprepo/repository_test.go
+++ b/pkg/platform/snaprepo/repository_test.go
@@ -160,14 +160,11 @@ func TestDelete(t *testing.T) {
 				params: DeleteParams{
 					Name: "my_repo",
 					Params: Params{
-						API: api.NewMock(mock.Response{Response: http.Response{
-							StatusCode: 404,
-							Body:       mock.NewStringBody(`{}`),
-						}}),
+						API: api.NewMock(mock.New404Response(mock.NewStringBody(`{"error": "some error"}`))),
 					},
 				},
 			},
-			wantErr: errors.New("unknown error (status 404)"),
+			wantErr: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Delete fails on invalid params",
diff --git a/pkg/platform/stack/stack_test.go b/pkg/platform/stack/stack_test.go
index ca18806..84eedb0 100644
--- a/pkg/platform/stack/stack_test.go
+++ b/pkg/platform/stack/stack_test.go
@@ -139,13 +139,13 @@ func TestGet(t *testing.T) {
 			args: args{params: GetParams{
 				Version: "6.0.0",
 				API: api.NewMock(mock.Response{
-					Error: errors.New("unknown error"),
+					Error: errors.New(`{"error": "some error"}`),
 				}),
 			}},
 			err: &url.Error{
 				Op:  "Get",
 				URL: "https://mock-host/mock-path/stack/versions/6.0.0",
-				Err: errors.New("unknown error"),
+				Err: errors.New(`{"error": "some error"}`),
 			},
 		},
 		{
@@ -302,13 +302,13 @@ func TestList(t *testing.T) {
 			name: "List fails due to API error",
 			args: args{params: ListParams{
 				API: api.NewMock(mock.Response{
-					Error: errors.New("unknown error"),
+					Error: errors.New(`{"error": "some error"}`),
 				}),
 			}},
 			err: &url.Error{
 				Op:  "Get",
 				URL: "https://mock-host/mock-path/stack/versions?show_deleted=false&show_unusable=false",
-				Err: errors.New("unknown error"),
+				Err: errors.New(`{"error": "some error"}`),
 			},
 		},
 		{
@@ -316,13 +316,13 @@ func TestList(t *testing.T) {
 			args: args{params: ListParams{
 				Deleted: true,
 				API: api.NewMock(mock.Response{
-					Error: errors.New("unknown error"),
+					Error: errors.New(`{"error": "some error"}`),
 				}),
 			}},
 			err: &url.Error{
 				Op:  "Get",
 				URL: "https://mock-host/mock-path/stack/versions?show_deleted=true&show_unusable=false",
-				Err: errors.New("unknown error"),
+				Err: errors.New(`{"error": "some error"}`),
 			},
 		},
 		{
@@ -372,13 +372,13 @@ func TestUpload(t *testing.T) {
 			args: args{params: UploadParams{
 				StackPack: strings.NewReader("aa"),
 				API: api.NewMock(mock.Response{
-					Error: errors.New("unknown error"),
+					Error: errors.New(`{"error": "some error"}`),
 				}),
 			}},
 			err: &url.Error{
 				Op:  "Post",
 				URL: "https://mock-host/mock-path/stack/versions",
-				Err: errors.New("unknown error"),
+				Err: errors.New(`{"error": "some error"}`),
 			},
 		},
 		{
@@ -460,13 +460,13 @@ func TestDelete(t *testing.T) {
 			args: args{params: DeleteParams{
 				Version: "5.6.0",
 				API: api.NewMock(mock.Response{
-					Error: errors.New("unknown error"),
+					Error: errors.New(`{"error": "some error"}`),
 				}),
 			}},
 			err: &url.Error{
 				Op:  "Delete",
 				URL: "https://mock-host/mock-path/stack/versions/5.6.0",
-				Err: errors.New("unknown error"),
+				Err: errors.New(`{"error": "some error"}`),
 			},
 		},
 		{
diff --git a/pkg/user/auth/admin/listkeys_test.go b/pkg/user/auth/admin/listkeys_test.go
index ef1182b..f0cfc75 100644
--- a/pkg/user/auth/admin/listkeys_test.go
+++ b/pkg/user/auth/admin/listkeys_test.go
@@ -76,22 +76,18 @@ func TestListKeys(t *testing.T) {
 		{
 			name: "fails due to API error on all call",
 			args: args{params: ListKeysParams{
-				API: api.NewMock(
-					mock.New500Response(mock.NewStringBody("")),
-				),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				All: true,
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to API error on user call",
 			args: args{params: ListKeysParams{
-				API: api.NewMock(
-					mock.New500Response(mock.NewStringBody("")),
-				),
+				API:    api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				UserID: "someid",
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "succeeds listing keys for multiple users",
diff --git a/pkg/user/auth/listkeys_test.go b/pkg/user/auth/listkeys_test.go
index b2c6546..9161858 100644
--- a/pkg/user/auth/listkeys_test.go
+++ b/pkg/user/auth/listkeys_test.go
@@ -58,20 +58,16 @@ func TestListKeys(t *testing.T) {
 		{
 			name: "fails due to API error on all call",
 			args: args{params: ListKeysParams{
-				API: api.NewMock(
-					mock.New500Response(mock.NewStringBody("")),
-				),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "fails due to API error",
 			args: args{params: ListKeysParams{
-				API: api.NewMock(
-					mock.New500Response(mock.NewStringBody("")),
-				),
+				API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 			}},
-			err: errors.New(`unknown error (status 500)`),
+			err: errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "succeeds listing keys",
diff --git a/pkg/user/create_test.go b/pkg/user/create_test.go
index 790e04b..2797149 100644
--- a/pkg/user/create_test.go
+++ b/pkg/user/create_test.go
@@ -175,14 +175,11 @@ func TestCreate(t *testing.T) {
 					UserName: "bob",
 					Password: []byte("supersecretpass"),
 					Roles:    []string{"ece_platform_admin"},
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 404,
-					}}),
+					API:      api.NewMock(mock.New404Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
 			wantErr: true,
-			err:     errors.New("unknown error (status 404)"),
+			err:     errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Create succeeds",
diff --git a/pkg/user/delete_test.go b/pkg/user/delete_test.go
index d5cfd5f..cc40652 100644
--- a/pkg/user/delete_test.go
+++ b/pkg/user/delete_test.go
@@ -55,13 +55,13 @@ func TestDelete(t *testing.T) {
 				params: DeleteParams{
 					UserName: "user bob",
 					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
+						Body:       mock.NewStringBody(`{"error": "some error"}`),
 						StatusCode: 400,
 					}}),
 				},
 			},
 			wantErr: true,
-			err:     errors.New("unknown error (status 400)"),
+			err:     errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Delete succeeds",
diff --git a/pkg/user/get_test.go b/pkg/user/get_test.go
index c46e6bd..c27d754 100644
--- a/pkg/user/get_test.go
+++ b/pkg/user/get_test.go
@@ -109,14 +109,11 @@ func TestGet(t *testing.T) {
 			args: args{
 				params: GetParams{
 					UserName: "hermenelgilda",
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					API:      api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
 			wantErr: true,
-			err:     errors.New("unknown error (status 500)"),
+			err:     errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "Get succeeds",
diff --git a/pkg/user/list_test.go b/pkg/user/list_test.go
index c17b91e..e4ff4f1 100644
--- a/pkg/user/list_test.go
+++ b/pkg/user/list_test.go
@@ -62,14 +62,11 @@ func TestList(t *testing.T) {
 			name: "List fails due to API failure",
 			args: args{
 				params: ListParams{
-					API: api.NewMock(mock.Response{Response: http.Response{
-						Body:       mock.NewStringBody(""),
-						StatusCode: 500,
-					}}),
+					API: api.NewMock(mock.New500Response(mock.NewStringBody(`{"error": "some error"}`))),
 				},
 			},
 			wantErr: true,
-			err:     errors.New("unknown error (status 500)"),
+			err:     errors.New(`{"error": "some error"}`),
 		},
 		{
 			name: "List succeeds",