|
| 1 | +/* |
| 2 | + * Copyright 2024 EPAM Systems |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.epam.reportportal.extension.bugtracking.rally.validator; |
| 18 | + |
| 19 | +import com.epam.reportportal.rules.exception.ReportPortalException; |
| 20 | +import com.epam.ta.reportportal.entity.integration.Integration; |
| 21 | +import com.epam.ta.reportportal.entity.integration.IntegrationParams; |
| 22 | +import java.util.HashMap; |
| 23 | +import java.util.Map; |
| 24 | +import org.junit.jupiter.api.Assertions; |
| 25 | +import org.junit.jupiter.params.ParameterizedTest; |
| 26 | +import org.junit.jupiter.params.provider.CsvSource; |
| 27 | + |
| 28 | +class IntegrationValidatorTest { |
| 29 | + |
| 30 | + @ParameterizedTest |
| 31 | + @CsvSource(value = { |
| 32 | + "https://rally1.rallydev.com", |
| 33 | + "https://rally1.rallydev.com/" |
| 34 | + }, delimiter = ',') |
| 35 | + void validateThirdPartyUrl(String url) { |
| 36 | + Assertions.assertDoesNotThrow(() -> |
| 37 | + IntegrationValidator.validateThirdPartyUrl(getIntegration(url))); |
| 38 | + } |
| 39 | + |
| 40 | + @ParameterizedTest |
| 41 | + @CsvSource(value = { |
| 42 | + "http://rally1.rallydev.com", |
| 43 | + "https://zloi.hacker.com" |
| 44 | + }, delimiter = ',') |
| 45 | + void validateThirdPartyUrlFailed(String url) { |
| 46 | + Assertions.assertThrows(ReportPortalException.class, () -> |
| 47 | + IntegrationValidator.validateThirdPartyUrl(getIntegration(url))); |
| 48 | + } |
| 49 | + |
| 50 | + private static Integration getIntegration(String url) { |
| 51 | + Map<String, Object> params = new HashMap<>(); |
| 52 | + params.put("url", url); |
| 53 | + |
| 54 | + IntegrationParams integrationParams = new IntegrationParams(); |
| 55 | + integrationParams.setParams(params); |
| 56 | + |
| 57 | + Integration integration = new Integration(); |
| 58 | + integration.setParams(integrationParams); |
| 59 | + |
| 60 | + return integration; |
| 61 | + } |
| 62 | + |
| 63 | +} |
0 commit comments