def _get_security(self): principal = get_sentry_server_principal() if principal: kerberos_principal_short_name = principal.split('/', 1)[0] else: kerberos_principal_short_name = None use_sasl = get_sentry_server_authentication() == 'KERBEROS' mechanism = SentryClient.SENTRY_MECHANISMS[get_sentry_server_authentication()] return { 'kerberos_principal_short_name': kerberos_principal_short_name, 'use_sasl': use_sasl, 'mechanism': mechanism }
def test_security_plain(): tmpdir = tempfile.mkdtemp() finish = SENTRY_CONF_DIR.set_for_testing(tmpdir) try: xml = sentry_site_xml(provider='default') file(os.path.join(tmpdir, 'sentry-site.xml'), 'w').write(xml) sentry_site.reset() assert_equal('test/[email protected]', get_sentry_server_principal()) assert_equal(['hive', 'impala', 'hue'], get_sentry_server_admin_groups()) security = SentryClient('test.com', 11111, 'test')._get_security() assert_equal('test', security['kerberos_principal_short_name']) assert_equal(False, security['use_sasl']) assert_equal('NOSASL', security['mechanism']) finally: sentry_site.reset() finish() shutil.rmtree(tmpdir)