mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
api: fix new password is applied on host when update host password with update_passwd_on_host=false (#7092)
This commit is contained in:
parent
9366c4ea01
commit
536a387326
@ -23,6 +23,7 @@ import org.apache.cloudstack.api.Parameter;
|
|||||||
import org.apache.cloudstack.api.response.ClusterResponse;
|
import org.apache.cloudstack.api.response.ClusterResponse;
|
||||||
import org.apache.cloudstack.api.response.HostResponse;
|
import org.apache.cloudstack.api.response.HostResponse;
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -67,7 +68,7 @@ public class UpdateHostPasswordCmd extends BaseCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getUpdatePasswdOnHost() {
|
public Boolean getUpdatePasswdOnHost() {
|
||||||
return updatePasswdOnHost == null ? false : true;
|
return BooleanUtils.isTrue(updatePasswdOnHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.resource.ResourceService;
|
import com.cloud.resource.ResourceService;
|
||||||
@ -94,4 +95,15 @@ public class UpdateHostPasswordCmdTest extends TestCase {
|
|||||||
assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
|
assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||||
verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
|
verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetUpdatePasswdOnHostValues() {
|
||||||
|
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||||
|
|
||||||
|
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", false);
|
||||||
|
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||||
|
|
||||||
|
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", true);
|
||||||
|
assertTrue(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user