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)
Beispiel #4
0
 def testListUsers(self):
     # show users.
     results = self.handle.list_users()
     if security():
         self.assertGreaterEqual(len(results), 1)
         for result in results:
             self.assertTrue(isinstance(result, UserInfo))
             self.assertTrue(self._is_str(result.get_id()))
             self.assertTrue(self._is_str(result.get_name()))
     else:
         self.assertIsNone(results)
 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 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()