Search in sources :

Example 1 with MockLoginRestModel

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());
}
Also used : TestProperties(com.blackducksoftware.integration.hub.alert.TestProperties) MockLoginRestModel(com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test)

Example 2 with MockLoginRestModel

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"));
}
Also used : MockLoginRestModel(com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test) HubConnectionTest(com.blackducksoftware.integration.test.annotation.HubConnectionTest)

Aggregations

MockLoginRestModel (com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel)2 Test (org.junit.Test)2 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)1 TestProperties (com.blackducksoftware.integration.hub.alert.TestProperties)1 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)1 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)1 HubConnectionTest (com.blackducksoftware.integration.test.annotation.HubConnectionTest)1 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)1