Skip to content

Commit adb35ff

Browse files
committed
fix: unit test
1 parent e4f53d7 commit adb35ff

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

aws_advanced_python_wrapper/utils/rdsutils.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from re import search, sub, Match
16-
from typing import Optional, Dict
15+
from re import Match, search, sub
16+
from typing import Dict, Optional
1717

1818
from aws_advanced_python_wrapper.utils.rds_url_type import RdsUrlType
1919

@@ -59,37 +59,37 @@ class RdsUtils:
5959
"""
6060

6161
AURORA_DNS_PATTERN = r"(?P<instance>.+)\." \
62-
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
62+
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?" \
6363
r"(?P<domain>[a-zA-Z0-9]+\." \
64-
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$)"
64+
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
6565
AURORA_INSTANCE_PATTERN = r"(?P<instance>.+)\." \
6666
r"(?P<domain>[a-zA-Z0-9]+\." \
67-
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$)"
67+
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
6868
AURORA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
6969
r"(?P<dns>cluster-|cluster-ro-)+" \
7070
r"(?P<domain>[a-zA-Z0-9]+\." \
71-
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$)"
71+
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
7272
AURORA_CUSTOM_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
7373
r"(?P<dns>cluster-custom-)+" \
7474
r"(?P<domain>[a-zA-Z0-9]+\." \
75-
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$)"
75+
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
7676
AURORA_PROXY_DNS_PATTERN = r"(?P<instance>.+)\." \
7777
r"(?P<dns>proxy-)+" \
7878
r"(?P<domain>[a-zA-Z0-9]+\." \
79-
r"(?P<region>[a-zA-Z0-9\\-]+)\.rds\.amazonaws\.com)(?!\.cn$)"
80-
AURORA_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
81-
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
79+
r"(?P<region>[a-zA-Z0-9\\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
80+
AURORA_OLD_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
81+
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?" \
8282
r"(?P<domain>[a-zA-Z0-9]+\." \
8383
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com\.cn)"
84-
AURORA_OLD_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
85-
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
84+
AURORA_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
85+
r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?" \
8686
r"(?P<domain>[a-zA-Z0-9]+\." \
8787
r"rds\.(?P<region>[a-zA-Z0-9\-]+)\.amazonaws\.com\.cn)"
88-
AURORA_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
88+
AURORA_OLD_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
8989
r"(?P<dns>cluster-|cluster-ro-)+" \
9090
r"(?P<domain>[a-zA-Z0-9]+\." \
9191
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com\.cn)"
92-
AURORA_OLD_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
92+
AURORA_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
9393
r"(?P<dns>cluster-|cluster-ro-)+" \
9494
r"(?P<domain>[a-zA-Z0-9]+\." \
9595
r"rds\.(?P<region>[a-zA-Z0-9\-]+)\.amazonaws\.com\.cn)"
@@ -105,7 +105,7 @@ class RdsUtils:
105105

106106
IP_V4 = r"^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){1}" \
107107
r"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
108-
IP_V6 = r"^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$"
108+
IP_V6 = r"^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}"
109109
IP_V6_COMPRESSED = r"^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)"
110110

111111
DNS_GROUP = "dns"
@@ -203,7 +203,7 @@ def is_ipv4(self, host: str) -> bool:
203203
def is_ipv6(self, host: str) -> bool:
204204
if host is None or not host.strip():
205205
return False
206-
return search(RdsUtils.IP_V6_COMPRESSED, host) is not None and search(RdsUtils.IP_V6, host) is not None
206+
return search(RdsUtils.IP_V6_COMPRESSED, host) is not None or search(RdsUtils.IP_V6, host) is not None
207207

208208
def is_dns_pattern_valid(self, host: str) -> bool:
209209
return "?" in host
@@ -244,6 +244,8 @@ def _find(self, host: str, patterns: list):
244244
return None
245245

246246
def _get_regex_group(self, pattern: Match[str], group_name: str):
247+
if pattern is None:
248+
return None
247249
return pattern.group(group_name)
248250

249251
def _get_group(self, host: str, group: str):

0 commit comments

Comments
 (0)