use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method updateAnSDDCSoftwareConfig.
/**
* Update SDDCSoftwareConfig Test case three:Whether can be saved successfully,when modify only
* the server name or server description save success and test pass
*/
@Test
public void updateAnSDDCSoftwareConfig() throws JsonProcessingException, Exception {
AuthVcUser vcAuth = Mockito.mock(AuthVcUser.class);
Mockito.doNothing().when(vcAuth).authenticateUser(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(vcAuth).when(serverValidationService).getVcAuth(Mockito.any(SDDCSoftwareConfig.class));
SDDCSoftwareConfig sddcCreate = createSDDCSoftwareConfig(SoftwareType.VCENTER);
SDDCSoftwareConfig sddc = sddcRepository.save(sddcCreate);
sddc.setName("test update name");
this.mockMvc.perform(put("/v1/sddc/").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(sddc))).andExpect(status().isOk()).andReturn();
sddcRepository.deleteById(sddc.getId());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method updateSDDCSoftwareConfigIsVerifyCert.
/**
* Update SDDCSoftwareConfig Test case one:To update the IsVerifyCert.Whether can be saved
* successfully,when the VerifyCert is true. The message 'Certificate verification error' will be
* throwed,when the VerifyCert is true.
*/
@Test
public void updateSDDCSoftwareConfigIsVerifyCert() throws Exception {
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Certificate verification error");
SDDCSoftwareConfig sddcCreate = createSDDCSoftwareConfig(SoftwareType.VCENTER);
SDDCSoftwareConfig sddc = sddcRepository.save(sddcCreate);
sddc.setVerifyCert(true);
AuthVcUser vcAuth = Mockito.mock(AuthVcUser.class);
Mockito.doThrow(new SSLException("I will failed")).when(vcAuth).authenticateUser(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(vcAuth).when(serverValidationService).getVcAuth(Mockito.any(SDDCSoftwareConfig.class));
try {
MvcResult result = this.mockMvc.perform(put("/v1/sddc/").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(sddc))).andDo(document("SDDCSoftware-update-example", requestFields(fieldWithPath("id").description("ID of the SDDCSoftwareConfig, created by flowgate"), fieldWithPath("name").description("The SDDCSoftwareConfig name."), fieldWithPath("description").description("The SDDCSoftwareConfig description."), fieldWithPath("serverURL").description("An ip address for a SDDCSoftwareConfig"), fieldWithPath("userName").description("An username used to obtain authorization"), fieldWithPath("password").description(" A password used to obtain authorization."), fieldWithPath("type").description("A type for SDDCSoftwareConfig,forExample VRO, VCENTER, OTHERS").type(SoftwareType.class).optional(), fieldWithPath("userId").description("userId"), fieldWithPath("subCategory").description("subCategory"), fieldWithPath("verifyCert").description("Whether to verify the certificate when accessing the serverURL."), subsectionWithPath("integrationStatus").description("The status of integration.")))).andReturn();
if (result.getResolvedException() != null) {
throw result.getResolvedException();
}
} catch (Exception e) {
throw e;
} finally {
sddcRepository.deleteById(sddc.getId());
}
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method getVROServerConfigsExample.
@Test
public void getVROServerConfigsExample() throws Exception {
SDDCSoftwareConfig sddc1Create = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddc1Create.setType(SoftwareType.VRO);
sddc1Create.setName("flowgate");
sddc1Create.setDescription("flowgate cluster");
SDDCSoftwareConfig sddc2Create = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddc2Create.setType(SoftwareType.VRO);
sddc1Create.setPassword(EncryptionGuard.encode(sddc1Create.getPassword()));
sddc2Create.setPassword(EncryptionGuard.encode(sddc2Create.getPassword()));
sddcRepository.save(sddc1Create);
sddcRepository.save(sddc2Create);
FieldDescriptor[] fieldpath = new FieldDescriptor[] { fieldWithPath("id").description("ID of SDDCSoftwareConfig, created by flowgate"), fieldWithPath("name").description("The SDDCSoftwareConfig name."), fieldWithPath("description").description("The SDDCSoftwareConfig description."), fieldWithPath("userName").description("An username used to obtain authorization"), fieldWithPath("password").description(" A password used to obtain authorization."), fieldWithPath("serverURL").description("The server's address, it can be an IP or FQDN."), fieldWithPath("type").description("A type for SDDCSoftwareConfig,forExample VRO, VCENTER, OTHERS, VROPSMP").type(SoftwareType.class).optional(), fieldWithPath("userId").description("userId"), fieldWithPath("subCategory").description("subCategory"), fieldWithPath("verifyCert").description("Whether to verify the certificate when accessing the serverURL.").type(JsonFieldType.BOOLEAN), subsectionWithPath("integrationStatus").description("The status of integration.").optional() };
MvcResult result = this.mockMvc.perform(get("/v1/sddc/vrops")).andExpect(status().isOk()).andDo(document("SDDCSoftware-getVROServerConfigs-example", responseFields(fieldWithPath("[]").description("An array of VROPs server configs")).andWithPrefix("[].", fieldpath))).andReturn();
ObjectMapper mapper = new ObjectMapper();
String res = result.getResponse().getContentAsString();
SDDCSoftwareConfig[] sddcs = mapper.readValue(res, SDDCSoftwareConfig[].class);
for (SDDCSoftwareConfig sddc : sddcs) {
if (sddc.getName().equals("flowgate")) {
TestCase.assertEquals("flowgate cluster", sddc.getDescription());
}
}
sddcRepository.deleteById(sddc1Create.getId());
sddcRepository.deleteById(sddc2Create.getId());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method SDDCSoftwareQueryByPageExample.
@Test
public void SDDCSoftwareQueryByPageExample() throws Exception {
SDDCSoftwareConfig sddcCreate = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddcCreate.setPassword(EncryptionGuard.encode(sddcCreate.getPassword()));
SDDCSoftwareConfig sddc = sddcRepository.save(sddcCreate);
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
int pageNumber = 1;
int pageSize = 5;
this.mockMvc.perform(get("/v1/sddc/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize)).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(sddc.getName())).andExpect(jsonPath("$..content[0].userId").value(sddc.getUserId())).andDo(document("SDDCSoftware-query-example", pathParameters(parameterWithName("pageNumber").description("The page you want to get"), parameterWithName("pageSize").description("The number of SDDCSoftwares you want to get by every request.Default value: 20")), responseFields(subsectionWithPath("content").type(JsonFieldType.ARRAY).description("SDDCSoftwareConfig's array."), fieldWithPath("totalPages").description("content's total pages."), fieldWithPath("totalElements").description("content's total elements."), fieldWithPath("last").description("Is the last."), fieldWithPath("number").description("The page number."), fieldWithPath("size").description("The page size."), fieldWithPath("sort").description("The sort."), fieldWithPath("numberOfElements").description("The number of Elements."), fieldWithPath("first").description("Is the first."), subsectionWithPath("pageable").description("pageable.").ignored(), subsectionWithPath("sort").description("sorted.").ignored(), fieldWithPath("empty").description("Is empty.").ignored())));
sddcRepository.deleteById(sddc.getId());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SystemSummaryTest method createSDDC.
SDDCSoftwareConfig createSDDC() {
SDDCSoftwareConfig sddc = new SDDCSoftwareConfig();
sddc.setId(UUID.randomUUID().toString());
return sddc;
}
Aggregations