|
| 1 | +""" |
| 2 | +Copyright (c) 2022, Oracle and/or its affiliates. |
| 3 | +Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. |
| 4 | +""" |
| 5 | +import unittest |
| 6 | + |
| 7 | +from wlsdeploy.tool.create import atp_helper |
| 8 | + |
| 9 | +class AtpHelperTestCase(unittest.TestCase): |
| 10 | + |
| 11 | + def testFixingDescriptionList(self): |
| 12 | + src_url = '(description_list=(failover=on)(load_balance=off)(description=(retry_count=15)(retry_delay=3)' \ |
| 13 | + '(address=(protocol=tcps)(port=1522)(host=somewhere-in.oraclecloud.com))' \ |
| 14 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 15 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))' \ |
| 16 | + '(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=somewhere2-in.oraclecloud.com))' \ |
| 17 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 18 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))' \ |
| 19 | + '(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1523)(host=somewhere2-in.oraclecloud.com))' \ |
| 20 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 21 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")) ) )' |
| 22 | + |
| 23 | + expected_url = '(description_list=(failover=on)(load_balance=off)(description=(retry_count=15)(retry_delay=3)' \ |
| 24 | + '(address=(protocol=tcps)(port=1522)(host=somewhere-in.oraclecloud.com))' \ |
| 25 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 26 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))' \ |
| 27 | + '(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=somewhere2-in.oraclecloud.com))' \ |
| 28 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 29 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))' \ |
| 30 | + '(description=(retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1523)(host=somewhere2-in.oraclecloud.com))' \ |
| 31 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 32 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US"))))' |
| 33 | + |
| 34 | + |
| 35 | + fixed_url = atp_helper.cleanup_connect_string(src_url) |
| 36 | + self.assertEqual(fixed_url, expected_url) |
| 37 | + return |
| 38 | + |
| 39 | + def testFixingNonDescriptionList(self): |
| 40 | + src_url = '(description= (address=(protocol=tcps)(port=1522)(host=some-cn-in.oraclecloud.com))' \ |
| 41 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 42 | + '(security=(ssl_server_cert_dn= "CN=some-cn-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")) )' |
| 43 | + |
| 44 | + expected_url = '(description=(address=(protocol=tcps)(port=1522)(host=some-cn-in.oraclecloud.com))' \ |
| 45 | + '(connect_data=(service_name=some-service-in.oraclecloud.com))' \ |
| 46 | + '(security=(ssl_server_cert_dn="CN=some-cn-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))' |
| 47 | + |
| 48 | + fixed_url = atp_helper.cleanup_connect_string(src_url) |
| 49 | + |
| 50 | + self.assertEqual(fixed_url, expected_url) |
| 51 | + return |
0 commit comments