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))
    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"))
    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
Example #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)
Example #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)
Example #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)
Example #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)
Example #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")
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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")
Example #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)
    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)
    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)
    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)
Example #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)
Example #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)
    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())
Example #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)
Example #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)
Example #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())
    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)
Example #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)
Example #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))
Example #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)
Example #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)