Skip to content

Commit 9ea75bc

Browse files
authored
Fix for new atp format without server dn entries (#1356)
* Fix for new atp format without server dn entries * comment
1 parent 806813f commit 9ea75bc

File tree

2 files changed

+63
-18
lines changed

2 files changed

+63
-18
lines changed

core/src/main/python/wlsdeploy/tool/create/atp_helper.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,36 @@ def cleanup_connect_string(connect_string):
103103
104104
Input:
105105
(description= (address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(ssl_server_cert_dn= "CN=somewhere-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")) )
106+
or
107+
(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
106108
Output Parts:
107109
1. (description=(address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(
108110
2. ssl_server_cert_dn=
109111
3. "CN=somewhere-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US"
110112
4. )))
111113
:param connect_string:
112-
:return:
114+
:return: fixed connection string without white spaces
113115
"""
114116

115-
toks = connect_string.split('(description=')
116-
pattern = "(.*)(ssl_server_cert_dn=)\s*(\".*\")(.*)"
117117
result = ''
118-
for token in toks:
119-
if token.find("(ssl_server_cert_dn=") > 0:
120-
match = re.search(pattern, token)
121-
if match:
122-
part1 = match.group(1).replace(' ','')
123-
part2 = match.group(2).replace(' ', '')
124-
# We don't want to remove the spaces from serverDN part.
125-
part3 = match.group(3)
126-
part4 = match.group(4).replace(' ', '')
127-
result += "(description=%s%s%s%s" % (part1, part2, part3, part4)
128-
else:
129-
result += token.replace(' ', '')
130-
131-
if result == '':
132-
result = connect_string
118+
if connect_string.find("(ssl_server_cert_dn=") > 0:
119+
toks = connect_string.split('(description=')
120+
# can have multiples
121+
pattern = "(.*)(ssl_server_cert_dn=)\s*(\".*\")(.*)"
122+
for token in toks:
123+
if token.find("(ssl_server_cert_dn=") > 0:
124+
match = re.search(pattern, token)
125+
if match:
126+
part1 = match.group(1).replace(' ','')
127+
part2 = match.group(2).replace(' ', '')
128+
# We don't want to remove the spaces from serverDN part.
129+
part3 = match.group(3)
130+
part4 = match.group(4).replace(' ', '')
131+
result += "(description=%s%s%s%s" % (part1, part2, part3, part4)
132+
else:
133+
result += token.replace(' ', '')
134+
else:
135+
result = connect_string.replace(' ','')
133136

134137
return result
135138

core/src/test/python/atp_helper_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,45 @@ def testFixingNonDescriptionList(self):
4949

5050
self.assertEqual(fixed_url, expected_url)
5151
return
52+
53+
def testFixingDescriptionListWithoutServerDN(self):
54+
src_url = '(description_list=(failover=on)(load_balance=off)(description=(retry_count=15)(retry_delay=3)' \
55+
'(address=(protocol=tcps)(port=1522)(host=somewhere-in.oraclecloud.com))' \
56+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
57+
'(security=(ssl_server_dn_match=yes)))' \
58+
'(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=somewhere2-in.oraclecloud.com))' \
59+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
60+
'(security=(ssl_server_dn_match=yes)))' \
61+
'(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1523)(host=somewhere2-in.oraclecloud.com))' \
62+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
63+
'(security=(ssl_server_dn_match=yes)))'
64+
65+
expected_url = '(description_list=(failover=on)(load_balance=off)(description=(retry_count=15)(retry_delay=3)' \
66+
'(address=(protocol=tcps)(port=1522)(host=somewhere-in.oraclecloud.com))' \
67+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
68+
'(security=(ssl_server_dn_match=yes)))' \
69+
'(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=somewhere2-in.oraclecloud.com))' \
70+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
71+
'(security=(ssl_server_dn_match=yes)))' \
72+
'(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1523)(host=somewhere2-in.oraclecloud.com))' \
73+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
74+
'(security=(ssl_server_dn_match=yes)))'
75+
76+
77+
fixed_url = atp_helper.cleanup_connect_string(src_url)
78+
self.assertEqual(fixed_url, expected_url)
79+
return
80+
81+
def testFixingNonDescriptionListWithoutServerDN(self):
82+
src_url = '(description= (address=(protocol=tcps)(port=1522)(host=some-cn-in.oraclecloud.com))' \
83+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
84+
'(security=(ssl_server_dn_match=yes)) )'
85+
86+
expected_url = '(description=(address=(protocol=tcps)(port=1522)(host=some-cn-in.oraclecloud.com))' \
87+
'(connect_data=(service_name=some-service-in.oraclecloud.com))' \
88+
'(security=(ssl_server_dn_match=yes)))'
89+
90+
fixed_url = atp_helper.cleanup_connect_string(src_url)
91+
92+
self.assertEqual(fixed_url, expected_url)
93+
return

0 commit comments

Comments
 (0)