def test_security_kerberos(): tmpdir = tempfile.mkdtemp() finish = HBASE_CONF_DIR.set_for_testing(tmpdir) try: xml = hbase_site_xml(authentication='kerberos') file(os.path.join(tmpdir, 'hbase-site.xml'), 'w').write(xml) reset() assert_equal('KERBEROS', get_server_authentication()) assert_equal('test', get_server_principal()) security = HbaseApi._get_security() assert_equal('test', security['kerberos_principal_short_name']) assert_equal(True, security['use_sasl']) finally: reset() finish() shutil.rmtree(tmpdir)