Search in sources :

Example 1 with SettingsProxyTestAction

use of com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction in project hub-alert by blackducksoftware.

the class SettingsProxyTestActionTestIT method testUrlWithBadResponseTest.

@Test
void testUrlWithBadResponseTest() {
    SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
    AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
    settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck("http://thisUrlWillReturnFailures", settingsProxyModel);
    assertTrue(testResult.isSuccessful());
    assertTrue(testResult.getContent().isPresent());
    ValidationResponseModel validationResponseModel = testResult.getContent().get();
    assertTrue(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with SettingsProxyTestAction

use of com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction in project hub-alert by blackducksoftware.

the class SettingsProxyTestActionTestIT method malformedTargetUrlTest.

@Test
void malformedTargetUrlTest() {
    SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
    AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
    settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck("Not a valid url", settingsProxyModel);
    assertTrue(testResult.isSuccessful());
    assertTrue(testResult.getContent().isPresent());
    ValidationResponseModel validationResponseModel = testResult.getContent().get();
    assertTrue(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with SettingsProxyTestAction

use of com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction in project hub-alert by blackducksoftware.

the class SettingsProxyTestActionTest method blankTestUrlTest.

@Test
void blankTestUrlTest() {
    ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
    SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ConfigurationTestResult testResult = settingsProxyTestAction.testConfigModelContent("", defaultSettingsProxyModel);
    assertFalse(testResult.isSuccess());
}
Also used : SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) ProxyTestService(com.synopsys.integration.alert.common.rest.proxy.ProxyTestService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 4 with SettingsProxyTestAction

use of com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction in project hub-alert by blackducksoftware.

the class SettingsProxyTestActionTest method testConfigModelContentTest.

@Test
void testConfigModelContentTest() {
    ConfigurationTestResult configurationTestResult = ConfigurationTestResult.success();
    ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
    Mockito.when(proxyTestService.pingHost(Mockito.eq(TEST_URL), Mockito.any())).thenReturn(configurationTestResult);
    SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ConfigurationTestResult testResult = settingsProxyTestAction.testConfigModelContent(TEST_URL, defaultSettingsProxyModel);
    assertEquals(configurationTestResult, testResult);
}
Also used : SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) ProxyTestService(com.synopsys.integration.alert.common.rest.proxy.ProxyTestService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 5 with SettingsProxyTestAction

use of com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction in project hub-alert by blackducksoftware.

the class SettingsProxyTestActionTest method testWithPermissionCheckTest.

@Test
void testWithPermissionCheckTest() {
    ConfigurationTestResult configurationTestResult = ConfigurationTestResult.success();
    ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
    Mockito.when(proxyTestService.pingHost(Mockito.eq(TEST_URL), Mockito.any())).thenReturn(configurationTestResult);
    SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ActionResponse<ValidationResponseModel> actionResponse = settingsProxyTestAction.testWithPermissionCheck(TEST_URL, defaultSettingsProxyModel);
    assertTrue(actionResponse.isSuccessful());
    assertTrue(actionResponse.hasContent());
    Optional<ValidationResponseModel> validationResponseModel = actionResponse.getContent();
    assertTrue(validationResponseModel.isPresent());
    assertFalse(validationResponseModel.get().hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) ProxyTestService(com.synopsys.integration.alert.common.rest.proxy.ProxyTestService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Aggregations

SettingsProxyTestAction (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction)12 Test (org.junit.jupiter.api.Test)12 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)9 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)8 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)7 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)7 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)5 ProxyTestService (com.synopsys.integration.alert.common.rest.proxy.ProxyTestService)5