From 4be029c6c11686049b285bc6c13270c9b4d57454 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Thu, 23 Feb 2017 19:20:50 -0800 Subject: [PATCH] storage/kubernetes: fix kubernetes storage conformance test failures --- storage/kubernetes/client.go | 3 +++ storage/kubernetes/storage.go | 2 +- storage/kubernetes/types.go | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/storage/kubernetes/client.go b/storage/kubernetes/client.go index dc238a9c..9f5d0d3f 100644 --- a/storage/kubernetes/client.go +++ b/storage/kubernetes/client.go @@ -135,6 +135,9 @@ func checkHTTPErr(r *http.Response, validStatusCodes ...int) error { if r.StatusCode == http.StatusNotFound { return storage.ErrNotFound } + if r.Request.Method == "POST" && r.StatusCode == http.StatusConflict { + return storage.ErrAlreadyExists + } var url, method string if r.Request != nil { diff --git a/storage/kubernetes/storage.go b/storage/kubernetes/storage.go index 421b74c9..fd7f04ad 100644 --- a/storage/kubernetes/storage.go +++ b/storage/kubernetes/storage.go @@ -31,7 +31,7 @@ const ( resourceRefreshToken = "refreshtokens" resourceKeys = "signingkeies" // Kubernetes attempts to pluralize. resourcePassword = "passwords" - resourceOfflineSessions = "offlinesessions" + resourceOfflineSessions = "offlinesessionses" // Again attempts to pluralize. ) // Config values for the Kubernetes storage type. diff --git a/storage/kubernetes/types.go b/storage/kubernetes/types.go index 81dc01c3..c362452f 100644 --- a/storage/kubernetes/types.go +++ b/storage/kubernetes/types.go @@ -502,9 +502,14 @@ func (cli *client) fromStorageOfflineSessions(o storage.OfflineSessions) Offline } func toStorageOfflineSessions(o OfflineSessions) storage.OfflineSessions { - return storage.OfflineSessions{ + s := storage.OfflineSessions{ UserID: o.UserID, ConnID: o.ConnID, Refresh: o.Refresh, } + if s.Refresh == nil { + // Server code assumes this will be non-nil. + s.Refresh = make(map[string]*storage.RefreshTokenRef) + } + return s }