From 16ac1f84b20ec21524483cad12f02576d6726558 Mon Sep 17 00:00:00 2001 From: arkxu Date: Mon, 25 Apr 2016 15:56:57 -0700 Subject: [PATCH] failure fast if not 200 when authenticating Change-Id: Ibe1c38f632d1f0155830f00354de2135ee5aceb6 --- openstack/auth.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openstack/auth.go b/openstack/auth.go index 40af41b..ed4c78e 100644 --- a/openstack/auth.go +++ b/openstack/auth.go @@ -18,6 +18,7 @@ package openstack import ( "encoding/json" "errors" + "fmt" "io/ioutil" "strings" "time" @@ -91,6 +92,11 @@ func DoAuthRequest(authopts AuthOpts) (AuthRef, error) { if err != nil { return nil, errors.New("error reading response body") } + + if resp.StatusCode != 200 { + return nil, fmt.Errorf("auth error: %s", rbody) + } + if err = json.Unmarshal(rbody, &auth); err != nil { return nil, errors.New("error unmarshalling response body") }