Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix endpoint_test UT #34

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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