def test_change_pass(self):
        """Function:  test_change_pass

        Description:  Test change passwd and update config.

        Arguments:

        """

        global KEY1
        global KEY2

        new_config = {KEY1 + KEY2: self.new_sql_pass}

        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     os_type=self.machine,
                                     defaults_file=self.defaults_file)
        mysqldb.sql_pass = self.new_sql_pass
        mysqldb.set_pass_config()

        self.assertEqual((mysqldb.config, mysqldb.sql_pass),
                         (new_config, self.new_sql_pass))
예제 #2
0
    def test_value(self, mock_sysvar):
        """Function:  test_value

        Description:  Test with values returned.

        Arguments:

        """

        mock_sysvar.side_effect = [{
            "log_bin": "ON"
        }, {
            "read_only": "YES"
        }, {
            "log_slave_updates": "YES"
        }, {
            "sync_master_info": "NO"
        }, {
            "sync_relay_log": "ON"
        }, {
            "sync_relay_log_info": "YES"
        }]
        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     self.machine,
                                     defaults_file=self.defaults_file)

        mysqldb.upd_slv_rep_stat()

        self.assertEqual((mysqldb.log_bin, mysqldb.sync_rly_info),
                         ("ON", "YES"))
예제 #3
0
    def setUp(self):
        """Function:  setUp

        Description:  Initialization for unit testing.

        Arguments:

        """

        key1 = "pass"
        key2 = "wd"
        self.base_dir = "test/integration"
        self.config_dir = os.path.join(self.base_dir, "config")
        self.config_name = "mysql_cfg"
        cfg = gen_libs.load_module(self.config_name, self.config_dir)
        self.svr = mysql_class.Server(cfg.name,
                                      cfg.sid,
                                      cfg.user,
                                      cfg.japd,
                                      os_type=getattr(machine, cfg.serv_os)(),
                                      host=cfg.host,
                                      port=cfg.port,
                                      defaults_file=cfg.cfg_file)

        self.ssl_client_ca = "CAFile"
        self.ssl_client_key = "KeyFile"
        self.ssl_client_cert = "CertFile"
        self.ssl_client_flag = mysql.connector.ClientFlag.SSL

        self.config = {}
        self.config[key1 + key2] = self.svr.sql_pass
        self.config["ssl_ca"] = "CAFile"
        self.config["client_flags"] = [mysql.connector.ClientFlag.SSL]
        self.config["ssl_disabled"] = False
        self.config["ssl_verify_identity"] = False
        self.config["ssl_verify_cert"] = False

        self.config2 = {}
        self.config2[key1 + key2] = self.svr.sql_pass
        self.config2["ssl_key"] = "KeyFile"
        self.config2["ssl_cert"] = "CertFile"
        self.config2["client_flags"] = [mysql.connector.ClientFlag.SSL]
        self.config2["ssl_ca"] = ""
        self.config2["ssl_disabled"] = False
        self.config2["ssl_verify_identity"] = False

        self.config3 = {}
        self.config3[key1 + key2] = self.svr.sql_pass
        self.config3["ssl_ca"] = "CAFile"
        self.config3["ssl_key"] = "KeyFile"
        self.config3["ssl_cert"] = "CertFile"
        self.config3["client_flags"] = [mysql.connector.ClientFlag.SSL]
        self.config3["ssl_disabled"] = False
        self.config3["ssl_verify_identity"] = False
        self.config3["ssl_verify_cert"] = False
예제 #4
0
    def test_no_extra_def_file(self):

        """Function:  test_no_extra_def_file

        Description:  Test with no extra_def_file arg.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.extra_def_file, None)
예제 #5
0
    def test_config(self):

        """Function:  test_config

        Description:  Test with config attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.config, self.config)
예제 #6
0
    def test_version(self):

        """Function:  test_version

        Description:  Test with version attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.version, None)
예제 #7
0
    def test_indb_buf_write(self):

        """Function:  test_indb_buf_write

        Description:  Test with indb_buf_write attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.indb_buf_write, None)
예제 #8
0
    def test_ssl_client_ca2(self):

        """Function:  test_ssl_client_ca2

        Description:  Test with ssl_client_ca attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_ca="CAFile")

        self.assertEqual(mysqldb.ssl_client_ca, "CAFile")
예제 #9
0
    def test_ssl_client_key(self):

        """Function:  test_ssl_client_key

        Description:  Test with ssl_client_key attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.ssl_client_key, None)
예제 #10
0
    def test_ssl_client_flag2(self):

        """Function:  test_ssl_client_flag2

        Description:  Test with ssl_client_flag attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_flag=4096)

        self.assertEqual(mysqldb.ssl_client_flag, 4096)
예제 #11
0
    def test_ssl_disabled(self):

        """Function:  test_ssl_disabled

        Description:  Test with ssl_disabled attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.ssl_disabled, False)
예제 #12
0
    def test_ssl_verify_id2(self):

        """Function:  test_ssl_verify_id2

        Description:  Test with ssl_verify_id attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_verify_id=True)

        self.assertEqual(mysqldb.ssl_verify_id, True)
예제 #13
0
    def test_ssl_config(self):

        """Function:  test_ssl_config

        Description:  Test config with ssl attributes set.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_ca="CAFile")

        self.assertEqual(mysqldb.config, self.config2)
예제 #14
0
    def test_no_port(self):

        """Function:  test_no_port

        Description:  Test with no port arg.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.port, 3306)
예제 #15
0
    def test_no_host(self):

        """Function:  test_no_host

        Description:  Test with no host arg.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.host, "localhost")
예제 #16
0
    def test_no_default(self):

        """Function:  test_no_default

        Description:  Test with no default file.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.defaults_file, self.results)
예제 #17
0
    def test_ssl_client_ca(self):

        """Function:  test_ssl_client_ca

        Description:  Test with ssl_client_ca only present.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_ca=self.ssl_client_ca)

        self.assertEqual(mysqldb.ssl_client_ca, self.ssl_client_ca)
예제 #18
0
    def test_ssl_client_key_cert3(self):

        """Function:  test_ssl_client_key_cert3

        Description:  Test with both cert and key present.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_key=self.ssl_client_key,
            ssl_client_cert=self.ssl_client_cert)

        self.assertEqual(mysqldb.config, self.config2)
예제 #19
0
    def test_key_cert_no_ca4(self):

        """Function:  test_key_cert_no_ca4

        Description:  Test with cert and key present, but no ca.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_key=self.ssl_client_key,
            ssl_client_cert=self.ssl_client_cert, ssl_disabled=True)

        self.assertEqual(mysqldb.config, self.config7)
예제 #20
0
    def test_ssl_client_flag(self):

        """Function:  test_ssl_client_flag

        Description:  Test with ssl_client_flag attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine)

        self.assertEqual(mysqldb.ssl_client_flag,
                         mysql.connector.ClientFlag.SSL)
예제 #21
0
    def test_ssl_verify_id(self):
        """Function:  test_ssl_verify_id

        Description:  Test with ssl_verify_id attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.cfg.name,
                                     self.cfg.sid,
                                     self.cfg.user,
                                     self.cfg.japd,
                                     os_type=self.machine)

        self.assertEqual(mysqldb.ssl_verify_id, False)
예제 #22
0
    def test_is_connected_false(self):
        """Function:  test_is_connected_false

        Description:  Test is_connected is False.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     self.machine,
                                     defaults_file=self.defaults_file)

        self.assertFalse(mysqldb.is_connected())
예제 #23
0
    def test_ssl_client_flag(self):
        """Function:  test_ssl_client_flag

        Description:  Test with ssl_client_flag present.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     os_type=self.machine)
        mysqldb.setup_ssl(ssl_client_flag=self.ssl_client_flag)

        self.assertEqual(mysqldb.ssl_client_flag, self.ssl_client_flag)
예제 #24
0
    def test_ssl_config4(self):

        """Function:  test_ssl_config4

        Description:  Test config with ssl attributes set.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_ca="CAFile",
            ssl_client_key="KeyFile", ssl_client_cert="CertFile",
            ssl_client_flag=4096)

        self.assertEqual(mysqldb.config, self.config5)
예제 #25
0
    def test_chg_db_none(self):
        """Function:  test_chg_db_none

        Description:  Test with no database is passed.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     os_type=self.machine,
                                     defaults_file=self.defaults_file)

        self.assertFalse(mysqldb.chg_db())
예제 #26
0
    def test_key_cert_yes_ca5(self):

        """Function:  test_key_cert_yes_ca5

        Description:  Test with cert and key present and with ca.

        Arguments:

        """

        mysqldb = mysql_class.Server(
            self.name, self.server_id, self.sql_user, self.sql_pass,
            os_type=self.machine, ssl_client_key=self.ssl_client_key,
            ssl_client_cert=self.ssl_client_cert,
            ssl_client_ca=self.ssl_client_ca, ssl_verify_id=True)

        self.assertEqual(mysqldb.config, self.config10)
예제 #27
0
    def test_default(self):
        """Function:  test_default

        Description:  Test get_name method.

        Arguments:

        """

        mysqlrep = mysql_class.Server(self.name,
                                      self.server_id,
                                      self.sql_user,
                                      self.sql_pass,
                                      self.machine,
                                      defaults_file=self.defaults_file)

        self.assertEqual(mysqlrep.get_name(), self.name)
예제 #28
0
    def test_silent_exception(self):
        """Function:  test_silent_exception

        Description:  Test silent connection method exception.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.name,
                                     self.server_id,
                                     self.sql_user,
                                     self.sql_pass,
                                     self.machine,
                                     defaults_file=self.defaults_file)

        self.assertFalse(mysqldb.connect(silent=True))
예제 #29
0
    def test_ssl_disabled2(self):
        """Function:  test_ssl_disabled2

        Description:  Test with ssl_disabled attribute.

        Arguments:

        """

        mysqldb = mysql_class.Server(self.cfg.name,
                                     self.cfg.sid,
                                     self.cfg.user,
                                     self.cfg.japd,
                                     os_type=self.machine,
                                     ssl_disabled=self.cfg.ssl_disabled)

        self.assertEqual(mysqldb.ssl_disabled, True)
예제 #30
0
    def test_version(self, mock_sysvar):

        """Function:  test_version

        Description:  Test with no innodb_support_xa in MySQL 8.0.

        Arguments:

        """

        mock_sysvar.side_effect = self.fetch_vars2
        mysqldb = mysql_class.Server(self.name, self.server_id, self.sql_user,
                                     self.sql_pass, self.machine,
                                     defaults_file=self.defaults_file)

        mysqldb.upd_mst_rep_stat()
        self.assertEqual(mysqldb.innodb_xa, None)