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

Deleting account returns error, after receiving status code 204 #18

Closed
ehaligow opened this issue Apr 22, 2022 · 4 comments · Fixed by #37
Closed

Deleting account returns error, after receiving status code 204 #18

ehaligow opened this issue Apr 22, 2022 · 4 comments · Fixed by #37
Assignees
Labels
approved Approved - can be assigned bug Something isn't working

Comments

@ehaligow
Copy link
Collaborator

ehaligow commented Apr 22, 2022

Deleting account returns error, after receiving status code 204 from BMC Simulator.

intel@ubuntu:functional_test$ ./dm deleteaccount 192.168.40.247:8888:admin:admin_1 Failed to delete device account admin_1, status code 204

According to code, receiving status codes other than 200 returns error.

@ehaligow ehaligow changed the title Deleting user returns error, after receiving status code 204 Deleting account returns error, after receiving status code 204 Apr 22, 2022
@JasonscHuang
Copy link
Collaborator

It needs to change the way to match the ID by the redfish API first and then delete the account. This test case needs to change in this way to do it.

@JasonscHuang
Copy link
Collaborator

The HTTP status code 204 means "No Content". Did you make sure you created an account before you delete it? Otherwise, you will see the 204 status code returned.

@ehaligow
Copy link
Collaborator Author

In this case, after deleting an account, BMC simulator returns 204 No Content (according to Redfish Specification the status coded 204 should be accepted for deletion). DeviceMgr accepts only code 200 for the deletion (as in the following code from accountService.go):

func (s *Server) removeDeviceAccount(deviceIPAddress string, authStr string, removeUser string) (statusNum int, err error) {
	var statusCode int
	userAuthData := s.getUserAuthData(deviceIPAddress, authStr)
	if (userAuthData == userAuth{}) {
		logrus.Errorf(ErrUserAuthNotFound.String())
		return http.StatusBadRequest, errors.New(ErrUserAuthNotFound.String())
	}
	id, status, _, _ := s.getUserLoginID(deviceIPAddress, authStr, removeUser)
	if status == true {
		_, statusCode, _ = deleteHTTPDataByRfAPI(deviceIPAddress, RfSessionServiceSessions, userAuthData, id)
		if statusCode != http.StatusOK {
			logrus.Errorf(ErrDeleteLoginFailed.String(id, strconv.Itoa(statusCode)))
			return statusCode, errors.New(ErrDeleteLoginFailed.String(id, strconv.Itoa(statusCode)))
		}
	}
	id, status = s.getAccountDataByLabel(deviceIPAddress, authStr, removeUser, "Id")
	if status == true {
		_, statusCode, _ = deleteHTTPDataByRfAPI(deviceIPAddress, RfAccountsServiceAccounts, userAuthData, id)
		if statusCode != http.StatusOK {
			logrus.Errorf(ErrDeleteUserAccount.String(removeUser, strconv.Itoa(statusCode)))
			return http.StatusNotFound, errors.New(ErrDeleteUserAccount.String(removeUser, strconv.Itoa(statusCode)))
		}
	}
...

@jcleung5549 jcleung5549 added the bug Something isn't working label May 3, 2022
@JasonscHuang
Copy link
Collaborator

@ehaligow Yes, you could add those conditions of the HTTP status code (202 and 204) to this function.

@MaciejMis MaciejMis added the approved Approved - can be assigned label Sep 13, 2022
@ehaligow ehaligow assigned ehaligow and unassigned JasonscHuang Sep 28, 2022
MaciejMis pushed a commit that referenced this issue Jan 18, 2023
Added status No content as accepted response for deleting Account (fix for Issue #18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved - can be assigned bug Something isn't working
Projects
None yet
4 participants