def testNoSQLHandleEndpointConfig(self): # set only the host as endpoint config = get_simple_handle_config(tenant_id, 'ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set proto://host as endpoint config = get_simple_handle_config(tenant_id, 'Http://ndcs.com') self._check_service_url(config, 'http', 'ndcs.com', 8080) config = get_simple_handle_config(tenant_id, 'https://ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set proto:host as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com') self._check_service_url(config, 'http', 'ndcs.com', 8080) config = get_simple_handle_config(tenant_id, 'https:ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set host:port as endpoint config = get_simple_handle_config(tenant_id, 'localhost:80') self._check_service_url(config, 'http', 'localhost', 80) config = get_simple_handle_config(tenant_id, 'localhost:443') self._check_service_url(config, 'https', 'localhost', 443) # set proto://host:port as endpoint config = get_simple_handle_config(tenant_id, 'HTTPS://ndcs.com:8080') self._check_service_url(config, 'https', 'ndcs.com', 8080) # set proto:host:port as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com:443') self._check_service_url(config, 'http', 'ndcs.com', 443)
def testNoSQLHandleConfigSetLegalSSLProtocol(self): if security(): # use default protocol config = get_simple_handle_config(tenant_id) handle = NoSQLHandle(config) self.assertEqual( config.get_ssl_context().protocol, PROTOCOL_SSLv23) handle.close() # set PROTOCOL_TLSv1_2 as ssl protocol config = get_simple_handle_config(tenant_id).set_ssl_protocol( PROTOCOL_TLSv1_2) handle = NoSQLHandle(config) self.assertEqual( config.get_ssl_context().protocol, PROTOCOL_TLSv1_2) handle.close()
def testNoSQLHandleConfigSetIllegalSSLProtocol(self): self.assertRaises(IllegalArgumentException, self.config.set_ssl_protocol, 'IllegalProtocol') self.assertRaises(IllegalArgumentException, self.config.set_ssl_protocol, -1) if security(): # set illegal protocol config = get_simple_handle_config(tenant_id).set_ssl_protocol(10) self.assertRaises(IllegalArgumentException, NoSQLHandle, config)
def testNoSQLHandleConfigSetIllegalSSLCACerts(self): self.assertRaises(IllegalArgumentException, self.config.set_ssl_ca_certs, {'IllegalCACerts': 'IllegalCACerts'}) if security(): # set illegal CA certs config = get_simple_handle_config(tenant_id).set_ssl_ca_certs( fake_key_file) self.assertRaises(IllegalArgumentException, NoSQLHandle, config)
def testNoSQLHandleConfigSetIllegalSSLCipherSuites(self): self.assertRaises(IllegalArgumentException, self.config.set_ssl_cipher_suites, {'IllegalCipherSuites': 'IllegalCipherSuites'}) if security(): # set illegal cipher suites config = get_simple_handle_config(tenant_id).set_ssl_cipher_suites( 'IllegalCipherSuites') self.assertRaises(IllegalArgumentException, NoSQLHandle, config)
def testNoSQLHandleEndpointConfig(self): # set only the host as endpoint config = get_simple_handle_config(tenant_id, 'ndcs.com') self.assertEqual(config.get_protocol(), 'https') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 443) # set proto://host as endpoint config = get_simple_handle_config(tenant_id, 'Http://ndcs.com') self.assertEqual(config.get_protocol(), 'http') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 8080) config = get_simple_handle_config(tenant_id, 'https://ndcs.com') self.assertEqual(config.get_protocol(), 'https') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 443) # set proto:host as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com') self.assertEqual(config.get_protocol(), 'http') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 8080) config = get_simple_handle_config(tenant_id, 'https:ndcs.com') self.assertEqual(config.get_protocol(), 'https') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 443) # set host:port as endpoint config = get_simple_handle_config(tenant_id, 'localhost:8080') self.assertEqual(config.get_protocol(), 'http') self.assertEqual(config.get_host(), 'localhost') self.assertEqual(config.get_port(), 8080) config = get_simple_handle_config(tenant_id, 'localhost:443') self.assertEqual(config.get_protocol(), 'https') self.assertEqual(config.get_host(), 'localhost') self.assertEqual(config.get_port(), 443) # set proto://host:port as endpoint config = get_simple_handle_config(tenant_id, 'HTTPS://ndcs.com:8080') self.assertEqual(config.get_protocol(), 'https') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 8080) # set proto:host:port as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com:443') self.assertEqual(config.get_protocol(), 'http') self.assertEqual(config.get_host(), 'ndcs.com') self.assertEqual(config.get_port(), 443)
def testNoSQLHandleConfigSetIllegalEndpoint(self): # illegal endpoint self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, None) self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, 'localhost:8080:foo') self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, 'localhost:notanint') self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, 'localhost:-1') self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, 'http://localhost:-1:x') self.assertRaises(IllegalArgumentException, NoSQLHandleConfig, 'ttp://localhost:8080') # legal endpoint format but no service at the port if security(): config = get_simple_handle_config(tenant_id, 'localhost:443') else: config = get_simple_handle_config(tenant_id, 'localhost:70') handle = NoSQLHandle(config) self.assertRaises(ConnectionError, handle.table_request, self.table_request) handle.close()
def setUp(self): self.config = get_simple_handle_config(tenant_id) self.table_request = TableRequest().set_statement( 'DROP TABLE IF EXISTS ' + table_name) self.get_request = GetRequest()
def testNoSQLHandleEndpointConfig(self): # set only the host as endpoint config = get_simple_handle_config(tenant_id, 'ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set protocol://host as endpoint config = get_simple_handle_config(tenant_id, 'Http://ndcs.com') self._check_service_url(config, 'http', 'ndcs.com', 8080) config = get_simple_handle_config(tenant_id, 'https://ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set protocol:host as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com') self._check_service_url(config, 'http', 'ndcs.com', 8080) config = get_simple_handle_config(tenant_id, 'https:ndcs.com') self._check_service_url(config, 'https', 'ndcs.com', 443) # set host:port as endpoint config = get_simple_handle_config(tenant_id, 'localhost:80') self._check_service_url(config, 'http', 'localhost', 80) config = get_simple_handle_config(tenant_id, 'localhost:443') self._check_service_url(config, 'https', 'localhost', 443) # set protocol://host:port as endpoint config = get_simple_handle_config(tenant_id, 'HTTPS://ndcs.com:8080') self._check_service_url(config, 'https', 'ndcs.com', 8080) # set protocol:host:port as endpoint config = get_simple_handle_config(tenant_id, 'Http:ndcs.com:443') self._check_service_url(config, 'http', 'ndcs.com', 443) # set a Region's id 'us-AshBURN-1' as endpoint. config = get_simple_handle_config(tenant_id, 'us-AshBURN-1') self._check_service_url( config, 'https', 'nosql.us-ashburn-1.oci.oraclecloud.com', 443) # set a Region's id 'US-LangLEY-1' as endpoint. config = get_simple_handle_config(tenant_id, 'US-LangLEY-1') self._check_service_url( config, 'https', 'nosql.us-langley-1.oci.oraclegovcloud.com', 443) # set a Region's id 'UK-GOV-LONDON-1' as endpoint. config = get_simple_handle_config(tenant_id, 'UK-GOV-LONDON-1') self._check_service_url( config, 'https', 'nosql.uk-gov-london-1.oci.oraclegovcloud.uk', 443) # set a Region's id 'Ap-CHiyODA-1' as endpoint. config = get_simple_handle_config(tenant_id, 'Ap-CHiyODA-1') self._check_service_url( config, 'https', 'nosql.ap-chiyoda-1.oci.oraclecloud8.com', 443) # set a Region Regions.US_ASHBURN_1 as endpoint. config = get_simple_handle_config(tenant_id, Regions.US_ASHBURN_1) self._check_service_url( config, 'https', 'nosql.us-ashburn-1.oci.oraclecloud.com', 443) # set a Region Regions.US_LANGLEY_1 as endpoint. config = get_simple_handle_config(tenant_id, Regions.US_LANGLEY_1) self._check_service_url( config, 'https', 'nosql.us-langley-1.oci.oraclegovcloud.com', 443) # set a Region Regions.UK_GOV_LONDON_1 as endpoint. config = get_simple_handle_config(tenant_id, Regions.UK_GOV_LONDON_1) self._check_service_url( config, 'https', 'nosql.uk-gov-london-1.oci.oraclegovcloud.uk', 443) # set a Region Regions.AP_CHIYODA_1 as endpoint. config = get_simple_handle_config(tenant_id, Regions.AP_CHIYODA_1) self._check_service_url( config, 'https', 'nosql.ap-chiyoda-1.oci.oraclecloud8.com', 443) # set a provider with region provider = SignatureProvider( tenant_id='ocid1.tenancy.oc1..tenancy', user_id='ocid1.user.oc1..user', fingerprint='fingerprint', private_key=fake_key_file, region=Regions.US_ASHBURN_1) config = NoSQLHandleConfig(provider=provider) self._check_service_url( config, 'https', 'nosql.us-ashburn-1.oci.oraclecloud.com', 443) self.assertEqual(config.get_region(), Regions.US_ASHBURN_1) # set a endpoint and provider with region config = NoSQLHandleConfig('us-ashburn-1', provider) self._check_service_url( config, 'https', 'nosql.us-ashburn-1.oci.oraclecloud.com', 443) self.assertEqual(config.get_region(), Regions.US_ASHBURN_1) provider.close()