Skip to content

Commit e5e65b9

Browse files
committed
fix: Go back to v1 high priority instead v3. V1 is the newer API, not the old.
1 parent fc5ac5e commit e5e65b9

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

rancher2/util.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ func DoUserLogin(url, provider, user, pass, ttl, desc, cacert string, insecure b
181181
errPrefix := "Doing user login"
182182

183183
// Login with user and pass
184-
respBody, resp, err := DoPost(v3loginURL, string(payload), cacert, insecure, loginHead)
184+
respBody, resp, err := DoPost(loginURL, string(payload), cacert, insecure, loginHead)
185185
if resp != nil && resp.StatusCode == http.StatusNotFound {
186-
// /v3-public/login endpoint is not available
187-
// try to fall back to /v1-public endpoint.
188-
respBody, _, err = DoPost(loginURL, string(payload), cacert, insecure, loginHead)
186+
// /v1-public/login endpoint is not available
187+
// try to fall back to /v3-public endpoint.
188+
respBody, _, err = DoPost(v3loginURL, string(payload), cacert, insecure, loginHead)
189189
if err != nil {
190190
return "", "", fmt.Errorf("%s: %v", errPrefix, err)
191191
}

rancher2/util_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestDoUserLogin(t *testing.T) {
2929

3030
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3131
assert.Equal(t, http.MethodPost, r.Method)
32-
assert.Equal(t, "/v3-public/localProviders/local", r.URL.Path)
32+
assert.Equal(t, "/v1-public/login", r.URL.Path)
3333
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
3434

3535
var reqBody loginInput
@@ -125,15 +125,15 @@ func TestDoUserLogin(t *testing.T) {
125125
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
126126
callCount++
127127

128-
if r.URL.Path == "/v3-public/localProviders/local" {
129-
assert.Equal(t, "login", r.URL.Query().Get("action"))
128+
if r.URL.Path == "/v1-public/login" {
130129
// Simulate v3 endpoint not available
131130
w.WriteHeader(http.StatusNotFound)
132131
w.Write([]byte(http.StatusText(http.StatusNotFound)))
133132
return
134133
}
135134

136-
if r.URL.Path == "/v1-public/login" {
135+
if r.URL.Path == "/v3-public/localProviders/local" {
136+
assert.Equal(t, "login", r.URL.Query().Get("action"))
137137

138138
var reqBody loginInput
139139
err := json.NewDecoder(r.Body).Decode(&reqBody)

0 commit comments

Comments
 (0)