Example #1
0
 def revoke_access(self, username, hostname, database):
     """Revoke a user's permission to use a given database."""
     user = self._get_user(username, hostname)
     with self.local_sql_client(self.mysql_app.get_engine()) as client:
         r = sql_query.Revoke(database=database,
                              user=user.name,
                              host=user.host)
         t = text(str(r))
         client.execute(t)
Example #2
0
 def revoke_access(self, username, hostname, database):
     """Give a user permission to use a given database."""
     user = self._get_user(username, hostname)
     with LocalSqlClient(get_engine()) as client:
         r = sql_query.Revoke(database=database,
                              user=user.name,
                              host=user.host,
                              hashed=user.password)
         t = text(str(r))
         client.execute(t)
Example #3
0
    def revoke_replication_privilege(self):
        LOG.info(_("Revoking Replication Slave privilege."))

        with LocalSqlClient(get_engine()) as client:
            g = sql_query.Revoke(permissions=['REPLICATION SLAVE'],
                                 user=REPLICATION_USER,
                                 clear=REPLICATION_PASSWORD)

            t = text(str(g))
            client.execute(t)
Example #4
0
    def revoke_replication_privilege(self):
        LOG.info(_("Revoking Replication Slave privilege."))

        with LocalSqlClient(get_engine()) as client:
            results = client.execute('SHOW SLAVE STATUS').fetchall()
            slave_status_info = results[0]

            r = sql_query.Revoke(permissions=['REPLICATION SLAVE'],
                                 user=slave_status_info['master_user'])

            t = text(str(r))
            client.execute(t)
Example #5
0
 def test_user_host(self):
     r = sql_query.Revoke()
     r.user = '******'
     r.host = 'y'
     self.assertEqual("REVOKE ALL ON *.* FROM `x`@`y`;", str(r))
Example #6
0
 def test_user(self):
     r = sql_query.Revoke()
     r.user = '******'
     self.assertEqual("REVOKE ALL ON *.* FROM `x`@`%`;", str(r))
Example #7
0
 def test_table(self):
     r = sql_query.Revoke()
     r.user = '******'
     r.database = 'foo'
     r.table = 'bar'
     self.assertEqual("REVOKE ALL ON `foo`.'bar' FROM `x`@`%`;", str(r))
Example #8
0
 def test_permissions(self):
     r = sql_query.Revoke()
     r.user = '******'
     r.permissions = ['CREATE', 'DELETE', 'DROP']
     self.assertEqual("REVOKE CREATE, DELETE, DROP ON *.* FROM `x`@`%`;",
                      str(r))
Example #9
0
 def test_defaults(self):
     r = sql_query.Revoke()
     # Technically, this isn't valid for MySQL.
     self.assertEqual("REVOKE ALL ON *.* FROM ``@`%`;", str(r))
Example #10
0
 def test_database(self):
     r = sql_query.Revoke()
     r.user = '******'
     r.database = 'foo'
     self.assertEqual(str(r), "REVOKE ALL ON `foo`.* FROM `x`@`%`;")