Skip to content

Commit

Permalink
Merge pull request #34 from TaoZou1/bugfix
Browse files Browse the repository at this point in the history
Fix endpoint_test UT
  • Loading branch information
TaoZou1 authored Jan 18, 2022
2 parents e932dd5 + 83cd991 commit b605465
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/nsx/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (ep *Endpoint) keepAlive() error {
ep.setStatus(UP)
return nil
}
ep.setStatus(DOWN)
log.Error(err, "failed to validate API cluster", "endpoint", ep.Host(), "healthy", a)
return err
}
Expand Down Expand Up @@ -298,7 +299,7 @@ func (ep *Endpoint) createAuthSession(certProvider auth.ClientCertProvider, toke
body, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
err = fmt.Errorf("unexpected status code %d", resp.StatusCode)
err = fmt.Errorf("session creation failed, unexpected status code %d", resp.StatusCode)
}
if err != nil {
log.Error(err, "session creation failed", "endpoint", u.Host, "statusCode", resp.StatusCode, "headerDate", resp.Header["Date"], "body", body)
Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestCreateAuthSession(t *testing.T) {
err = ep.createAuthSession(nil, nil, "admin", "password", jar)
mockObj.AssertCalled(t, "Host")
mockObj.AssertCalled(t, "Scheme")
assert.Equal(err.Error(), "session creation failed for response error 403", "Auth should be failed")
assert.Equal(err.Error(), "session creation failed, unexpected status code 403", "Auth should be failed")

err = ep.createAuthSession(nil, nil, "admin", "password", jar)
assert.Equal(err.Error(), "no token in response", "Auth should be failed")
Expand Down

0 comments on commit b605465

Please sign in to comment.