|
46 | 46 | import org.apache.cloudstack.api.ResponseObject; |
47 | 47 | import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse; |
48 | 48 | import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; |
| 49 | +import org.apache.cloudstack.api.response.ConfigurationResponse; |
49 | 50 | import org.apache.cloudstack.api.response.ConsoleSessionResponse; |
50 | 51 | import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; |
51 | 52 | import org.apache.cloudstack.api.response.GuestOSCategoryResponse; |
|
57 | 58 | import org.apache.cloudstack.api.response.UsageRecordResponse; |
58 | 59 | import org.apache.cloudstack.api.response.TrafficTypeResponse; |
59 | 60 | import org.apache.cloudstack.context.CallContext; |
| 61 | +import org.apache.cloudstack.framework.config.impl.ConfigurationVO; |
60 | 62 | import org.apache.cloudstack.usage.UsageService; |
61 | 63 | import org.apache.cloudstack.vm.UnmanagedInstanceTO; |
62 | 64 |
|
63 | 65 | import com.cloud.capacity.Capacity; |
| 66 | +import com.cloud.configuration.ConfigurationManager; |
64 | 67 | import com.cloud.configuration.Resource; |
65 | 68 | import com.cloud.domain.DomainVO; |
66 | 69 | import com.cloud.host.HostVO; |
|
93 | 96 | import com.cloud.user.UserDataVO; |
94 | 97 | import com.cloud.user.UserVO; |
95 | 98 | import com.cloud.user.dao.UserDataDao; |
| 99 | +import com.cloud.utils.Pair; |
96 | 100 | import com.cloud.utils.net.Ip; |
97 | 101 | import com.cloud.vm.ConsoleSessionVO; |
98 | 102 | import com.cloud.vm.NicSecondaryIp; |
@@ -137,6 +141,9 @@ public class ApiResponseHelperTest { |
137 | 141 | @Mock |
138 | 142 | ResourceIconManager resourceIconManager; |
139 | 143 |
|
| 144 | + @Mock |
| 145 | + ConfigurationManager configurationManagerMock; |
| 146 | + |
140 | 147 | @Mock |
141 | 148 | private ConsoleSessionVO consoleSessionMock; |
142 | 149 | @Mock |
@@ -800,4 +807,15 @@ public void createConsoleSessionResponseTestShouldReturnFullResponse() { |
800 | 807 | Assert.assertEquals(expected.getVmName(), response.getVmName()); |
801 | 808 | } |
802 | 809 | } |
| 810 | + |
| 811 | + @Test |
| 812 | + public void testCreateConfigurationResponseSecureValueIsReturnedAsStored() { |
| 813 | + ConfigurationVO cfg = new ConfigurationVO("Secure", "DEFAULT", "test", "test.secure.setting", null, "test"); |
| 814 | + ReflectionTestUtils.setField(cfg, "value", "storedEncryptedValue"); |
| 815 | + Mockito.when(configurationManagerMock.getConfigurationGroupAndSubGroup(cfg.getName())).thenReturn(new Pair<>("Miscellaneous", "Others")); |
| 816 | + |
| 817 | + ConfigurationResponse response = apiResponseHelper.createConfigurationResponse(cfg); |
| 818 | + |
| 819 | + assertEquals("storedEncryptedValue", response.getValue()); |
| 820 | + } |
803 | 821 | } |
0 commit comments