use of com.vmware.flowgate.auth.OpenManageAuth in project flowgate by vmware.
the class FacilitySoftwareControllerTest method createOpenManageThrowNotFoundException.
@Test
public void createOpenManageThrowNotFoundException() throws JsonProcessingException, Exception {
OpenManageAuth openmanageAuth = Mockito.mock(OpenManageAuth.class);
Mockito.doThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND, "Not Found")).when(openmanageAuth).auth(Mockito.any(FacilitySoftwareConfig.class));
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
Mockito.doReturn(openmanageAuth).when(serverValidationService).createOpenManageAuth();
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Unknown Host.Please check your server IP.");
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setType(SoftwareType.OpenManage);
facilitySoftware.setName("myOpenManage");
MvcResult result = this.mockMvc.perform(post("/v1/facilitysoftware").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(facilitySoftware))).andExpect(status().is4xxClientError()).andReturn();
if (result.getResolvedException() != null) {
throw result.getResolvedException();
} else {
TestCase.fail();
}
}
use of com.vmware.flowgate.auth.OpenManageAuth in project flowgate by vmware.
the class FacilitySoftwareControllerTest method createOpenManageThrowAuthException.
@Test
public void createOpenManageThrowAuthException() throws JsonProcessingException, Exception {
OpenManageAuth openmanageAuth = Mockito.mock(OpenManageAuth.class);
Mockito.doReturn(false).when(openmanageAuth).auth(Mockito.any(FacilitySoftwareConfig.class));
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
Mockito.doReturn(openmanageAuth).when(serverValidationService).createOpenManageAuth();
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Invalid user name or password");
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setType(SoftwareType.OpenManage);
facilitySoftware.setName("myOpenManage");
MvcResult result = this.mockMvc.perform(post("/v1/facilitysoftware").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(facilitySoftware))).andExpect(status().is4xxClientError()).andReturn();
if (result.getResolvedException() != null) {
throw result.getResolvedException();
} else {
TestCase.fail();
}
}
Aggregations