use of com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel in project hub-alert by blackducksoftware.
the class LoginControllerTestIT method testLogin.
@Test
public void testLogin() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(loginUrl);
final TestProperties testProperties = new TestProperties();
final MockLoginRestModel mockLoginRestModel = new MockLoginRestModel();
mockLoginRestModel.setHubUsername(testProperties.getProperty(TestPropertyKey.TEST_USERNAME));
mockLoginRestModel.setHubPassword(testProperties.getProperty(TestPropertyKey.TEST_PASSWORD));
globalProperties.setHubTrustCertificate(Boolean.valueOf(testProperties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT)));
globalProperties.setHubUrl(testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
final String restModel = mockLoginRestModel.getRestModelJson();
request.content(restModel);
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testAuthenticateUserFailIT.
@Test
public void testAuthenticateUserFailIT() throws IntegrationException, IOException {
mockLoginRestModel.setHubUsername(properties.getProperty(TestPropertyKey.TEST_ACTIVE_USER));
final LoginActions loginActions = new LoginActions(new TestGlobalProperties());
final MockLoginRestModel badRestModel = new MockLoginRestModel();
badRestModel.setHubPassword("badpassword");
final boolean userAuthenticated = loginActions.authenticateUser(badRestModel.createRestModel(), new Slf4jIntLogger(logger));
assertFalse(userAuthenticated);
assertTrue(outputLogger.isLineContainingText("User not authenticated"));
}
Aggregations