Skip to content

Commit 2577cf6

Browse files
committed
allow https
1 parent a58d24a commit 2577cf6

File tree

6 files changed

+2
-28
lines changed

6 files changed

+2
-28
lines changed

src/main/java/ru/mystamps/web/controller/SeriesController.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ public String processInput(
196196
DownloadResult.Code code = (DownloadResult.Code)downloadResultErrorCode;
197197
switch (code) {
198198
case INVALID_URL:
199-
case INVALID_PROTOCOL:
200-
// Protocol is being validated by @URL, to avoid showing error message
199+
// Url is being validated by @URL, to avoid showing error message
201200
// twice we're skipping error from an interceptor
202201
break;
203202
case INSUFFICIENT_PERMISSIONS:

src/main/java/ru/mystamps/web/service/HttpURLConnectionDownloaderService.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ public DownloadResult download(String fileUrl) {
5353
try {
5454
URL url = new URL(fileUrl);
5555

56-
Code validationResult = validateUrl(url);
57-
if (validationResult != Code.SUCCESS) {
58-
return DownloadResult.failed(validationResult);
59-
}
60-
6156
HttpURLConnection conn = openConnection(url);
6257
if (conn == null) {
6358
return DownloadResult.failed(Code.UNEXPECTED_ERROR);
@@ -73,7 +68,7 @@ public DownloadResult download(String fileUrl) {
7368
}
7469

7570
try (InputStream stream = new BufferedInputStream(conn.getInputStream())) {
76-
validationResult = validateConnection(conn);
71+
Code validationResult = validateConnection(conn);
7772
if (validationResult != Code.SUCCESS) {
7873
return DownloadResult.failed(validationResult);
7974
}
@@ -98,17 +93,6 @@ public DownloadResult download(String fileUrl) {
9893

9994
}
10095

101-
private static Code validateUrl(URL url) {
102-
// TODO: make it configurable
103-
String protocol = url.getProtocol();
104-
if ("http".equals(protocol)) {
105-
return Code.SUCCESS;
106-
}
107-
108-
LOG.debug("Couldn't download file: unsupported protocol '{}'", protocol);
109-
return Code.INVALID_PROTOCOL;
110-
}
111-
11296
private static HttpURLConnection openConnection(URL url) throws IOException {
11397
URLConnection connection = url.openConnection();
11498
if (!(connection instanceof HttpURLConnection)) {

src/main/java/ru/mystamps/web/service/dto/DownloadResult.java

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public boolean hasFailed() {
4646
public enum Code {
4747
SUCCESS,
4848
INVALID_URL,
49-
INVALID_PROTOCOL,
5049
INVALID_REDIRECT,
5150
INVALID_FILE_TYPE,
5251
INVALID_FILE_SIZE,

src/main/resources/ru/mystamps/i18n/ValidationMessages.properties

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ru.mystamps.web.validation.jsr303.MaxFileSize.message = File size must be not gr
2626
ru.mystamps.web.validation.jsr303.RequireImageOrImageUrl.message = Image or image URL must be specified
2727

2828
ru.mystamps.web.service.dto.DownloadResult.INVALID_URL = Invalid URL
29-
ru.mystamps.web.service.dto.DownloadResult.INVALID_PROTOCOL = Invalid protocol in the URL
3029
ru.mystamps.web.service.dto.DownloadResult.INVALID_REDIRECT = URL must not redirect to another address
3130
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_TYPE = Invalid file type
3231
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_SIZE = Invalid file size

src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ru.mystamps.web.validation.jsr303.MaxFileSize.message = Размер файла
2626
ru.mystamps.web.validation.jsr303.RequireImageOrImageUrl.message = Необходимо выбрать изображение либо указать ссылку на него
2727

2828
ru.mystamps.web.service.dto.DownloadResult.INVALID_URL = Неправильный URL
29-
ru.mystamps.web.service.dto.DownloadResult.INVALID_PROTOCOL = Недопустимый протокол в URL
3029
ru.mystamps.web.service.dto.DownloadResult.INVALID_REDIRECT = URL не должен перенаправлять на другой адрес
3130
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_TYPE = Недопустимый тип файла
3231
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_SIZE = Недопустимый размер файла

src/test/robotframework/series/creation/validation.robot

-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ Create series with empty image
3838
Submit Form id=add-series-form
3939
Element Text Should Be id=image.errors File must not be empty
4040

41-
Create series with unsupported protocol in the image URL
42-
[Documentation] Verify validation of URL with unsupported protocol
43-
Input Text id=image-url https://127.0.0.1:8080/invalid-imge-url-protocol
44-
Submit Form id=add-series-form
45-
Element Text Should Be id=image-url.errors Value must be a valid URL
46-
4741
Create series with image URL with invalid response
4842
[Documentation] Verify validation of invalid response from a server
4943
Input Text id=image-url ${SITE_URL}/test/invalid/response-400

0 commit comments

Comments
 (0)