Пример #1
0
    def get_authenticated(self):
        try:
            self.user = self.default_user
            self.passwrd = self.default_pw
            self.url = self.default_url
        except Exception as e:
            self.user = "******"
            self.passwrd = "password123"
            self.url = "0.0.0.0"

        self.version = self.get_version()
        print(self.version)
        if self.version >= 5:
            self.cluster = Cluster('couchbase://{}'.format(self.url))
            self.authenticator = PasswordAuthenticator(self.user, self.passwrd)
            self.cluster.authenticate(self.authenticator)
            self.main = self.cluster.open_bucket('main')
            self.hxn = self.cluster.open_bucket('hxn')
            self.main._cntlstr("operation_timeout", "5000")
        else:
            self.cluster = Cluster('couchbase://{}'.format(self.url))
            self.cluster.authenticate(
                ClassicAuthenticator(buckets={
                    'main': '',
                    'hxn': ''
                }))
            self.main = self.cluster.open_bucket('main')
            self.hxn = self.cluster.open_bucket('hxn')
Пример #2
0
    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_class=self.factory)
        cluster.authenticate(ClassicAuthenticator(buckets={bucket: password}))
        return cluster, bucket
Пример #3
0
 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_class=self.factory)
     cluster.authenticate(ClassicAuthenticator(buckets={bucket: password}))
     return cluster, bucket
 def _authenticator(self):
     if self.is_mock:
         return ClassicAuthenticator(self.cluster_info.admin_username,
                                     self.cluster_info.admin_password)
     return PasswordAuthenticator(self.cluster_info.admin_username,
                                  self.cluster_info.admin_password)