Exemplo n.º 1
0
def test_hdfs_site():
  hadoop_home = tempfile.mkdtemp()
  finish = None

  try:
    xml = """<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
  <property>
    <name>sentry.authorization-provider.hdfs-path-prefixes</name>
    <value>/path/a,/path/b,/path/1</value>
  </property>
  <property>
    <name>sentry.hdfs.integration.path.prefixes</name>
    <value>/path/c,/path/d,/path/1</value>
  </property>
</configuration>
    """
    file(os.path.join(hadoop_home, 'hdfs-site.xml'), 'w').write(xml)

    finish = conf.HDFS_CLUSTERS['default'].HADOOP_CONF_DIR.set_for_testing(hadoop_home)
    hdfs_site.reset()

    assert_equal(set(hdfs_site.get_nn_sentry_prefixes()), set(['/path/a', '/path/b', '/path/c', '/path/d', '/path/1']))
    assert_equal(len(hdfs_site.get_nn_sentry_prefixes()), 5)
  finally:
    hdfs_site.reset()
    if finish:
      finish()
Exemplo n.º 2
0
  def is_sentry_managed(cls, path):
    prefixes = get_nn_sentry_prefixes()

    return any([path == p or path.startswith(p + '/') for p in prefixes if p])
Exemplo n.º 3
0
    def is_sentry_managed(cls, path):
        prefixes = get_nn_sentry_prefixes()

        return any(
            [path == p or path.startswith(p + '/') for p in prefixes if p])
Exemplo n.º 4
0
    def is_sentry_managed(cls, path):
        prefixes = get_nn_sentry_prefixes().split(',')

        return any([path.startswith(p) for p in prefixes if p])