Skip to content

Commit 59581d7

Browse files
committed
fixed gitlab regex bug not identifying multi-digit project repos. added more logging + unit tests for http-request
1 parent 6fa9c53 commit 59581d7

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

2G-Service/admin-ansible-config-2g/shell-definition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
33
metadata:
44
template_name: Admin Ansible Config 2G
55
template_author: Quali
6-
template_version: 1.0.2
6+
template_version: 1.0.3
77
template_icon: shell-icon.png
88

99
description: >

2G-Service/admin-ansible-config-2g/src/helper_code/gitlab_api_url_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def is_base_path_gitlab_api(url):
1313
ex input - http://192.168.85.62/api/v4/projects/4/repository/files/hello_world.sh/raw?ref=master
1414
:param str url: the user input url
1515
"""
16-
base_path_pattern = "api/v\d/projects/\d/repository/files"
16+
base_path_pattern = "api/v\d/projects/\d+/repository/files"
1717
matching = re.search(base_path_pattern, url)
1818
if not matching:
1919
return False
@@ -32,7 +32,7 @@ def validate_full_path_gitlab_url(url):
3232
raise Exception("Gitlab Base Path validation failed. Should be of form '{}'".format(BASE_PATH_SAMPLE))
3333

3434
# VALIDATE ENTIRE GITLAB URL STRING
35-
gitlab_api_pattern = "https?://.+/api/v\d/projects/\d/repository/files/.+/raw\?ref=.+"
35+
gitlab_api_pattern = "https?://.+/api/v\d+/projects/\d/repository/files/.+/raw\?ref=.+"
3636
matching = re.match(gitlab_api_pattern, url)
3737
if not matching:
3838
sample_url = "http://<SERVER_IP>/api/4/projects/<PROJECT_ID>/repository/files/<PROJECT_PATH>/raw?ref=<GIT_BRANCH>"

2G-Service/ansible-config-2g/shell-definition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
33
metadata:
44
template_name: Ansible Config 2G
55
template_author: Quali
6-
template_version: 1.0.2
6+
template_version: 1.0.3
77
template_icon: shell-icon.png
88

99
description: >

2G-Service/ansible-config-2g/src/helper_code/gitlab_api_url_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def is_base_path_gitlab_api(url):
1313
ex input - http://192.168.85.62/api/v4/projects/4/repository/files/hello_world.sh/raw?ref=master
1414
:param str url: the user input url
1515
"""
16-
base_path_pattern = "api/v\d/projects/\d/repository/files"
16+
base_path_pattern = "api/v\d/projects/\d+/repository/files"
1717
matching = re.search(base_path_pattern, url)
1818
if not matching:
1919
return False
@@ -32,7 +32,7 @@ def validate_full_path_gitlab_url(url):
3232
raise Exception("Gitlab Base Path validation failed. Should be of form '{}'".format(BASE_PATH_SAMPLE))
3333

3434
# VALIDATE ENTIRE GITLAB URL STRING
35-
gitlab_api_pattern = "https?://.+/api/v\d/projects/\d/repository/files/.+/raw\?ref=.+"
35+
gitlab_api_pattern = "https?://.+/api/v\d/projects/\d+/repository/files/.+/raw\?ref=.+"
3636
matching = re.match(gitlab_api_pattern, url)
3737
if not matching:
3838
sample_url = "http://<SERVER_IP>/api/4/projects/<PROJECT_ID>/repository/files/<PROJECT_PATH>/raw?ref=<GIT_BRANCH>"

package/tests/test_http_request_service.py

Whitespace-only changes.

0 commit comments

Comments
 (0)