Пример #1
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())
Пример #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
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
def has_write_access(user):
    return user.is_superuser or user.has_hue_permission(
        action="write", app=DJANGO_APPS[0]) or is_impersonation_enabled()