Esempio n. 1
0
    def test_ssl_all_phrase(self):
        """Function:  test_ssl_all_phrase

        Description:  Test with all ssl arguments and phrase present.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   conf_file=self.conf_file,
                                   ssl_client_key=self.ssl_client_key,
                                   ssl_client_cert=self.ssl_client_cert,
                                   ssl_client_ca=self.ssl_client_ca,
                                   ssl_client_phrase=self.ssl_client_phrase,
                                   repset=self.repset)

        self.assertEqual((mongo.ssl_client_key, mongo.ssl_client_cert,
                          mongo.ssl_client_ca, mongo.ssl_client_phrase),
                         (self.ssl_client_key, self.ssl_client_cert,
                          self.ssl_client_ca, self.ssl_client_phrase))
Esempio n. 2
0
    def test_no_conn_list1(self):
        """Function:  test_no_conn_list2

        Description:  Test with no connections passed.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.cfg.name,
                                   self.cfg.user,
                                   self.cfg.japd,
                                   host=self.cfg.host,
                                   port=self.cfg.port,
                                   use_uri=self.cfg.use_uri,
                                   auth=self.cfg.auth,
                                   use_arg=self.cfg.use_arg,
                                   auth_db=self.cfg.auth_db,
                                   conf_file=self.cfg.conf_file,
                                   repset=self.cfg.repset)
        mongo.connect()

        self.assertEqual((mongo.name, mongo.user, mongo.japd, mongo.host,
                          mongo.port, mongo.repset_hosts),
                         (self.cfg.name, self.cfg.user, self.cfg.japd,
                          self.cfg.host, self.cfg.port, None))
Esempio n. 3
0
    def test_fail_get_srv_attr(self):
        """Function:  test_fail_get_srv_attr

        Description:  Test with failed get_srv_attr call.

        Arguments:

        """

        msg = "Authentication failed."
        errmsg = "Error:  Auth flag or login params is incorrect: %s" % msg

        mongo = mongo_class.RepSet(self.cfg.name,
                                   self.cfg.user,
                                   "mytestpd",
                                   host=self.cfg.host,
                                   port=self.cfg.port,
                                   use_uri=True,
                                   auth=self.cfg.auth,
                                   use_arg=False,
                                   auth_db=self.cfg.auth_db,
                                   conf_file=self.cfg.conf_file,
                                   repset=self.cfg.repset)

        self.assertEqual(mongo.connect(), (False, errmsg))
Esempio n. 4
0
    def test_default_conf_file(self):

        """Function:  test_default_conf_file

        Description:  Test using the default conf_file setting.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port)

        self.assertFalse(mongo.conf_file)
Esempio n. 5
0
    def test_repset_attr(self):

        """Function:  test_repset_attr

        Description:  Test repset attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, repset=self.cfg.repset)

        self.assertEqual(mongo.repset, self.cfg.repset)
Esempio n. 6
0
    def test_repset_hosts_attr2(self):

        """Function:  test_repset_hosts_attr2

        Description:  Test repset_hosts attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, repset_hosts=None)

        self.assertFalse(mongo.repset_hosts)
Esempio n. 7
0
    def test_config_attr2(self):

        """Function:  test_config_attr2

        Description:  Test with MONGODB-CR setting.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, auth_mech=self.auth_mech)

        self.assertEqual(mongo.config, self.config)
Esempio n. 8
0
    def test_config_attr3(self):

        """Function:  test_config_attr3

        Description:  Test with SCRAM-SHA-1 setting.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, auth_mech=self.auth_mech2)

        self.assertEqual(mongo.config, self.config2)
Esempio n. 9
0
    def test_conn_attr(self):

        """Function:  test_conn_attr

        Description:  Test conn attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, repset_hosts=self.cfg.repset_hosts)

        self.assertFalse(mongo.conn)
Esempio n. 10
0
    def test_default_auth_mech(self):

        """Function:  test_default_auth_mech

        Description:  Test auth_mech default setting.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, repset_hosts=self.cfg.repset_hosts)

        self.assertEqual(mongo.auth_mech, self.auth_mech2)
Esempio n. 11
0
    def test_ssl_client_ca(self):

        """Function:  test_ssl_client_ca

        Description:  Test with ssl_client_ca attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, repset_hosts=self.cfg.repset_hosts)

        self.assertEqual(mongo.ssl_client_ca, None)
Esempio n. 12
0
    def test_using_uri(self):

        """Function:  test_using_uri

        Description:  Test using the uri connection.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, use_uri=True)

        self.assertTrue(mongo.use_uri)
Esempio n. 13
0
    def test_using_auth_db(self):

        """Function:  test_using_auth_db

        Description:  Test using the auth_db attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, auth_db=self.cfg.auth_db)

        self.assertEqual(mongo.auth_db, self.cfg.auth_db)
Esempio n. 14
0
    def test_using_conf_file(self):

        """Function:  test_using_conf_file

        Description:  Test using the conf_file connection.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, conf_file="myfile")

        self.assertEqual(mongo.conf_file, "myfile")
Esempio n. 15
0
    def test_default_auth(self):

        """Function:  test_default_auth

        Description:  Test using the default auth setting.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port)

        self.assertTrue(mongo.auth)
Esempio n. 16
0
    def test_conn_list_attr(self):

        """Function:  test_conn_list_attr

        Description:  Test setting the conn_list attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port)

        self.assertEqual(mongo.conn_list, self.conn_list)
Esempio n. 17
0
    def test_using_auth(self):

        """Function:  test_using_auth

        Description:  Test using the auth connection.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, auth=False)

        self.assertFalse(mongo.auth)
Esempio n. 18
0
    def test_auth_mech(self):

        """Function:  test_auth_mech

        Description:  Test passing arg to auth_mech attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, auth_mech=self.auth_mech2,
            repset_hosts=self.cfg.repset_hosts)

        self.assertEqual(mongo.auth_mech, self.auth_mech2)
Esempio n. 19
0
    def test_repset_attr(self):
        """Function:  test_repset_attr

        Description:  Test setting the repset attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   repset=self.repset)

        self.assertEqual(mongo.repset, self.repset)
Esempio n. 20
0
    def test_db_path_attr(self):
        """Function:  test_db_path_attr

        Description:  Test db_path attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   host=self.host,
                                   port=self.port,
                                   repset=self.repset)

        self.assertFalse(mongo.db_path)
Esempio n. 21
0
    def test_name_attr(self):
        """Function:  test_name_attr

        Description:  Test name attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   host=self.host,
                                   port=self.port,
                                   repset=self.repset)

        self.assertEqual(mongo.name, self.name)
Esempio n. 22
0
    def test_test_ssl_client_key(self):
        """Function:  test_test_ssl_client_key

        Description:  Test with ssl_client_key attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   host=self.host,
                                   port=self.port,
                                   repset=self.repset)

        self.assertEqual(mongo.ssl_client_key, None)
Esempio n. 23
0
    def test_ssl_client_ca3(self):

        """Function:  test_ssl_client_ca3

        Description:  Test with ssl_client_ca only present.

        Arguments:

        """

        mongo = mongo_class.RepSet(
            self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host,
            port=self.cfg.port, conf_file=self.conf_file,
            ssl_client_ca=self.ssl_client_ca,
            repset_hosts=self.cfg.repset_hosts)

        self.assertEqual(mongo.ssl_client_ca, self.ssl_client_ca)
Esempio n. 24
0
    def test_no_auth_uri(self):
        """Function:  test_no_auth_uri

        Description:  Test with auth and no uri present.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   repset=self.repset)

        self.assertFalse(mongo.use_uri)
Esempio n. 25
0
    def test_using_no_auth_db(self):
        """Function:  test_using_no_auth_db

        Description:  Test using no auth_db attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   repset=self.repset)

        self.assertEqual(mongo.auth_db, "admin")
Esempio n. 26
0
    def test_no_auth_attr(self):
        """Function:  test_no_auth_attr

        Description:  Test no auth attribute passed.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   repset=self.repset)

        self.assertTrue(mongo.auth)
Esempio n. 27
0
    def test_no_conf_file_attr(self):
        """Function:  test_no_conf_file_attr

        Description:  Test no conf_file attribute passed.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   self.host,
                                   self.port,
                                   repset=self.repset)

        self.assertFalse(mongo.conf_file)
Esempio n. 28
0
    def test_no_conn_list(self, mock_get):

        """Function:  test_no_conn_list

        Description:  Test with no connections passed.

        Arguments:

        """

        mock_get.return_value = (True, None)

        mongo = mongo_class.RepSet(self.name, self.user, self.japd,
                                   self.host, self.port, repset=self.repset)
        mongo.conn = True

        self.assertEqual(mongo.connect(), (True, None))
Esempio n. 29
0
    def test_conn_false(self, mock_get, mock_mongo):

        """Function:  test_conn_false

        Description:  Test with conn set to false.

        Arguments:

        """

        mock_get.return_value = (True, None)
        mock_mongo.return_value = self.conn

        mongo = mongo_class.RepSet(self.name, self.user, self.japd,
                                   self.host, self.port, repset=self.repset)

        self.assertEqual(mongo.connect(), (True, None))
Esempio n. 30
0
    def test_ssl_client_phrase2(self):
        """Function:  test_ssl_client_phrase2

        Description:  Test with ssl_client_phrase attribute.

        Arguments:

        """

        mongo = mongo_class.RepSet(self.name,
                                   self.user,
                                   self.japd,
                                   host=self.host,
                                   port=self.port,
                                   ssl_client_phrase="Phrase",
                                   repset=self.repset)

        self.assertEqual(mongo.ssl_client_phrase, "Phrase")