use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageExample1.
// query by currentUser
@Test
public void facilitySoftwareQueryByPageExample1() throws Exception {
WormholeUserDetails userDeails = createuser();
userDeails.setUserId("5b7d208d55368540fcba1692");
Mockito.doReturn(userDeails).when(tokenService).getCurrentUser(any());
WormholeUser user = new WormholeUser();
user.setId("5b7d208d55368540fcba1692");
List<String> roles = new ArrayList<String>();
// not admin
roles.add("queryFacility");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setUserId("5b7d208d55368540fcba1692");
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftwareRepository.save(facilitySoftware);
int pageNumber = 1;
int pageSize = 5;
try {
this.mockMvc.perform(get("/v1/facilitysoftware/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize)).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(facilitySoftware.getName())).andExpect(jsonPath("$..content[0].userId").value(facilitySoftware.getUserId()));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method getInternalFacilitySoftwareConfigByTypeExample.
@Test
public void getInternalFacilitySoftwareConfigByTypeExample() throws Exception {
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
FacilitySoftwareConfig facilitySoftware1 = createFacilitySoftware();
facilitySoftware1.setName("1");
facilitySoftware1.setPassword(EncryptionGuard.encode(facilitySoftware1.getPassword()));
facilitySoftwareRepository.save(facilitySoftware1);
FacilitySoftwareConfig facilitySoftware2 = createFacilitySoftware();
facilitySoftware1.setName("2");
facilitySoftware2.setPassword(EncryptionGuard.encode(facilitySoftware2.getPassword()));
facilitySoftwareRepository.save(facilitySoftware2);
try {
this.mockMvc.perform(get("/v1/facilitysoftware/internal/type/" + facilitySoftware1.getType() + "")).andExpect(status().isOk());
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware1.getId());
facilitySoftwareRepository.deleteById(facilitySoftware2.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method updateAnFacilitySoftware.
@Test
public void updateAnFacilitySoftware() throws Exception {
NlyteAuth nlyteAuth = Mockito.mock(NlyteAuth.class);
Mockito.doReturn(false).when(nlyteAuth).auth(Mockito.any(FacilitySoftwareConfig.class));
Mockito.doReturn(nlyteAuth).when(serverValidationService).createNlyteAuth();
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftwareRepository.save(facilitySoftware);
facilitySoftware.setDescription("for generalUser");
facilitySoftware.setUserName("generalUser");
facilitySoftware.setPassword("generalUserPassword");
try {
this.mockMvc.perform(put("/v1/facilitysoftware").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(facilitySoftware))).andDo(document("facilitySoftware-update-example", requestFields(fieldWithPath("id").description("ID of the facilitySoftware, created by flowgate"), fieldWithPath("name").description("The facilitySoftware name."), fieldWithPath("description").description("The facilitySoftware description."), fieldWithPath("serverURL").description("The server's address, it can be an IP or FQDN."), fieldWithPath("userName").description("An username used to obtain authorization"), fieldWithPath("password").description(" A password used to obtain authorization."), fieldWithPath("type").description("A type for facilitySoftware,forExample Nlyte,PowerIQ,Device42,OtherDCIM or OtherCMDB").type(AssetSubCategory.class).optional(), fieldWithPath("userId").description("userId"), fieldWithPath("subCategory").description("subCategory"), fieldWithPath("verifyCert").description("Whether to verify the certificate when accessing the serverURL."), fieldWithPath("advanceSetting").description("advanceSetting"), fieldWithPath("integrationStatus.status").type(IntegrationStatus.Status.class).description("The status of integration.").optional(), fieldWithPath("integrationStatus.detail").type(String.class).description("If the status is error, it means error message").optional(), fieldWithPath("integrationStatus.retryCounter").type(JsonFieldType.NUMBER).description("Retry counter").optional())));
facilitySoftware.setPassword(null);
this.mockMvc.perform(put("/v1/facilitysoftware").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(facilitySoftware))).andDo(document("facilitySoftware-update-example", requestFields(fieldWithPath("id").description("ID of the facilitySoftware, created by flowgate"), fieldWithPath("name").description("The facilitySoftware name."), fieldWithPath("description").description("The facilitySoftware description."), fieldWithPath("serverURL").description("The server's address, it can be an IP or FQDN."), fieldWithPath("userName").description("An username used to obtain authorization"), fieldWithPath("password").description(" A password used to obtain authorization."), fieldWithPath("type").description("A type for facilitySoftware,forExample Nlyte,PowerIQ,Device42,OtherDCIM or OtherCMDB").type(AssetSubCategory.class).optional(), fieldWithPath("userId").description("userId"), fieldWithPath("subCategory").description("subCategory"), fieldWithPath("verifyCert").description("Whether to verify the certificate when accessing the serverURL."), fieldWithPath("advanceSetting").description("advanceSetting"), fieldWithPath("integrationStatus.status").type(IntegrationStatus.Status.class).description("The status of integration.").optional(), fieldWithPath("integrationStatus.detail").type(String.class).description("If the status is error, it means error message").optional(), fieldWithPath("integrationStatus.retryCounter").type(JsonFieldType.NUMBER).description("Retry counter").optional())));
} catch (Exception e) {
TestCase.fail();
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareDeleteExample.
@Test
public void facilitySoftwareDeleteExample() throws Exception {
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware = facilitySoftwareRepository.save(facilitySoftware);
this.mockMvc.perform(delete("/v1/facilitysoftware/{Id}", facilitySoftware.getId())).andExpect(status().isOk()).andDo(document("facilitySoftware-delete-example", pathParameters(parameterWithName("Id").description("The id of facilitysoftwareConfig, generated by flowgate."))));
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method getFacilitySoftwareConfigByTypeExample.
@Test
public void getFacilitySoftwareConfigByTypeExample() throws Exception {
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
FacilitySoftwareConfig facilitySoftware1 = createFacilitySoftware();
facilitySoftware1.setName("1");
facilitySoftware1.setPassword(EncryptionGuard.encode(facilitySoftware1.getPassword()));
facilitySoftwareRepository.save(facilitySoftware1);
FacilitySoftwareConfig facilitySoftware2 = createFacilitySoftware();
facilitySoftware1.setName("2");
facilitySoftware2.setPassword(EncryptionGuard.encode(facilitySoftware2.getPassword()));
facilitySoftwareRepository.save(facilitySoftware2);
FieldDescriptor[] fieldpath = new FieldDescriptor[] { fieldWithPath("id").description("ID of FacilitySoftwareConfig, created by flowgate"), fieldWithPath("name").description("The facilitySoftware name."), fieldWithPath("description").description("The facilitySoftware 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 facilitySoftware,forExample Nlyte,PowerIQ,Device42,OtherDCIM or OtherCMDB").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."), fieldWithPath("advanceSetting").description("Advance setting.").type(JsonFieldType.OBJECT) };
try {
this.mockMvc.perform(get("/v1/facilitysoftware/type/{type}", facilitySoftware1.getType())).andExpect(status().isOk()).andDo(document("facilitySoftware-getFacilitySoftwareConfigByType-example", pathParameters(parameterWithName("type").description("The type of FacilitySoftwareConfig. Sample value: Nlyte/PowerIQ/InfoBlox/OpenManage/Labsdb, you can use anyone of these options")), responseFields(fieldWithPath("[]").description("An array of facility software configs")).andWithPrefix("[].", fieldpath)));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware1.getId());
facilitySoftwareRepository.deleteById(facilitySoftware2.getId());
}
}
Aggregations