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))
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))
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))
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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")
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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")
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)
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)
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))
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))
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")