示例#1
0
文件: tests.py 项目: 18600597055/hue
def test_impersonation():
  from hbased import Hbase as thrift_hbase

  c = make_logged_in_client(username='******', is_superuser=False)
  grant_access('test_hbase', 'test_hbase', 'hbase')
  user = User.objects.get(username='******')

  proto = MockProtocol()
  client = thrift_hbase.Client(proto)

  impersonation_enabled = is_impersonation_enabled()

  get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = 'FALSE'
  try:
    client.getTableNames(doas=user.username)
  except AttributeError:
    pass # We don't mock everything
  finally:
    get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = impersonation_enabled

  assert_equal({}, proto.get_headers())


  get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = 'TRUE'

  try:
    client.getTableNames(doas=user.username)
  except AttributeError:
    pass # We don't mock everything
  finally:
    get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = impersonation_enabled

  assert_equal({'doAs': u'test_hbase'}, proto.get_headers())
示例#2
0
def test_impersonation():
    from hbased import Hbase as thrift_hbase

    c = make_logged_in_client(username='******', is_superuser=False)
    grant_access('test_hbase', 'test_hbase', 'hbase')
    user = User.objects.get(username='******')

    proto = MockProtocol()
    client = thrift_hbase.Client(proto)

    impersonation_enabled = is_impersonation_enabled()

    get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = 'FALSE'
    try:
        client.getTableNames(doas=user.username)
    except AttributeError:
        pass  # We don't mock everything
    finally:
        get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = impersonation_enabled

    assert_equal({}, proto.get_headers())

    get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = 'TRUE'

    try:
        client.getTableNames(doas=user.username)
    except AttributeError:
        pass  # We don't mock everything
    finally:
        get_conf()[_CNF_HBASE_IMPERSONATION_ENABLED] = impersonation_enabled

    assert_equal({'doAs': u'test_hbase'}, proto.get_headers())
示例#3
0
文件: views.py 项目: 18600597055/hue
def has_write_access(user):
  return user.is_superuser or user.has_hue_permission(action="write", app=DJANGO_APPS[0]) or is_impersonation_enabled()
示例#4
0
文件: views.py 项目: igloosec/hue
def has_write_access(user):
    return user.is_superuser or user.has_hue_permission(
        action="write", app=DJANGO_APPS[0]) or is_impersonation_enabled()