def test_can_authenticate_with_cert_path_and_username_password_via_kwargs( self): cluster = Cluster('couchbases://{host}?certpath={certpath}'.format( host=self.cluster_info.host, certpath=CERT_PATH)) self._test_allow_cert_path_with_SSL_mock_errors( cluster.open_bucket, self.cluster_info.bucket_name, username=self.cluster_info.admin_username, password=self.cluster_info.admin_password)
def test_PYCBC_488(self): cluster = Cluster( 'couchbases://10.142.175.101?certpath=/Users/daschl/tmp/ks/chain.pem&keypath=/Users/daschl/tmp/ks/pkey.key' ) with self.assertRaises(MixedAuthException) as maerr: cluster.open_bucket("pixels", password=self.cluster_info.bucket_password) exception = maerr.exception self.assertIsInstance(exception, MixedAuthException) self.assertRegex(exception.message, r'.*CertAuthenticator.*password.*')
def test_can_authenticate_with_cert_path_and_username_password_via_ClassicAuthenticator( self): cluster = Cluster('couchbases://{host}?certpath={certpath}'.format( host=self.cluster_info.host, certpath=CERT_PATH)) authenticator = ClassicAuthenticator( buckets={ self.cluster_info.bucket_name: self.cluster_info.bucket_password }, cluster_username=self.cluster_info.admin_username, cluster_password=self.cluster_info.admin_password) cluster.authenticate(authenticator) self._test_allow_cert_path_with_SSL_mock_errors( cluster.open_bucket, self.cluster_info.bucket_name)
def _create_cluster_clean(self, authenticator): connargs = self.make_connargs() connstr = ConnectionString.parse(str( connargs.pop('connection_string'))) connstr.clear_option('username') bucket = connstr.bucket connstr.bucket = None password = connargs.get('password', None) keys_to_skip = authenticator.get_credentials(bucket)['options'].keys() for entry in keys_to_skip: connstr.clear_option(entry) cluster = Cluster(connstr, bucket_factory=self.factory) cluster.authenticate(ClassicAuthenticator(buckets={bucket: password})) return cluster, bucket
def test_PYCBC_489(self): from couchbase_v2.cluster import Cluster with self.assertRaises(MixedAuthException) as maerr: cluster = Cluster( 'couchbases://10.142.175.101?certpath=/Users/daschl/tmp/ks/chain.pem&keypath=/Users/daschl/tmp/ks/pkey.key' ) cb = cluster.open_bucket('pixels', password='******') cb.upsert( 'u:king_arthur', { 'name': 'Arthur', 'email': '*****@*****.**', 'interests': ['Holy Grail', 'African Swallows'] }) exception = maerr.exception self.assertIsInstance(exception, MixedAuthException) self.assertRegex(exception.message, r'.*CertAuthenticator-style.*password.*')
def _create_cluster(self): connargs = self.make_connargs() connstr = ConnectionString.parse(str( connargs.pop('connection_string'))) connstr.clear_option('username') bucket = connstr.bucket connstr.bucket = None password = connargs.get('password', '') # Can I open a new bucket via open_bucket? cluster = Cluster(connstr, bucket_factory=self.factory) cluster.authenticate( ClassicAuthenticator( buckets={bucket: password}, cluster_password=self.cluster_info.admin_password, cluster_username=self.cluster_info.admin_username)) return cluster, bucket