Exemplo n.º 1
0
def test4(cluster):
    tid = "testx4"
    uid = "tester4"
    subid = "test4"

    display_name = "Test_User_4"
    cmd = t.build_cmd(
        '--tenant', tid,
        '--uid', uid,
        '--display-name', display_name,
        '--subuser', '%s:%s' % (uid, subid),
        '--key-type', 'swift',
        '--access', 'full',
        "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))

    # Note that this tests a way to identify a fully-qualified subuser
    # without --tenant and --uid. This is a historic use that we support.
    swift_secret = "test3pass"
    cmd = t.build_cmd(
        '--subuser', "'%s$%s:%s'" % (tid, uid, subid),
        '--key-type', 'swift',
        '--secret', swift_secret,
        "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))
    # These tests easily can throw KeyError, needs a try: XXX
    skj = outj['swift_keys'][0]
    if skj['secret_key'] != swift_secret:
        raise TestException(
            "command: key create --uid %s, returned swift key %s" %
            (tid_uid, skj['secret_key']))
Exemplo n.º 2
0
def test4(cluster):
    tid = "testx4"
    uid = "tester4"
    subid = "test4"

    display_name = "Test_User_4"
    cmd = t.build_cmd('--tenant', tid, '--uid', uid, '--display-name',
                      display_name, '--subuser', '%s:%s' % (uid, subid),
                      '--key-type', 'swift', '--access', 'full', "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))

    # Note that this tests a way to identify a fully-qualified subuser
    # without --tenant and --uid. This is a historic use that we support.
    swift_secret = "test3pass"
    cmd = t.build_cmd('--subuser', "'%s$%s:%s'" % (tid, uid, subid),
                      '--key-type', 'swift', '--secret', swift_secret,
                      "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))
    # These tests easily can throw KeyError, needs a try: XXX
    skj = outj['swift_keys'][0]
    if skj['secret_key'] != swift_secret:
        raise TestException(
            "command: key create --uid %s, returned swift key %s" %
            (tid_uid, skj['secret_key']))
Exemplo n.º 3
0
def test5_make_user(cluster, tid, uid, subid):
    """
    :param tid: Tenant ID string or None for the legacy tenant
    :param uid: User ID string
    :param subid: Subuser ID, may be None for S3-only users
    """
    display_name = "'Test User %s'" % uid

    cmd = ""
    if tid:
        cmd = t.build_cmd(cmd,
            '--tenant', tid)
    cmd = t.build_cmd(cmd,
        '--uid', uid,
        '--display-name', display_name)
    if subid:
        cmd = t.build_cmd(cmd,
            '--subuser', '%s:%s' % (uid, subid),
            '--key-type', 'swift')
    cmd = t.build_cmd(cmd,
        '--access', 'full',
        "user create")

    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)
    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))

    #
    # For now, this uses hardcoded passwords based on uid.
    # They are all different for ease of debugging in case something crosses.
    #
    test5_add_s3_key(cluster, tid, uid)
    if subid:
        test5_add_swift_key(cluster, tid, uid, subid)
Exemplo n.º 4
0
def test5_add_swift_key(cluster, tid, uid, subid):
    secret = "%spass" % uid
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid

    cmd = t.build_cmd('--subuser', "'%s:%s'" % (tid_uid, subid), '--key-type',
                      'swift', '--secret', secret, "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
    # XXX checking wrong thing here (S3 key)
    skj = outj['keys'][0]
    if skj['secret_key'] != secret:
        raise TestException(
            "command: key create --uid %s, returned s3 key %s" %
            (uid, skj['secret_key']))
Exemplo n.º 5
0
def test3(cluster):
    tid = "testx3"
    uid = "tester3"
    display_name = "Test_User_3"
    access_key = "tester3KEY"
    s3_secret = "test3pass"
    cmd = t.build_cmd(
        '--tenant', tid,
        '--uid', uid,
        '--display-name', display_name,
        '--access-key', access_key,
        '--secret', s3_secret,
        "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))
Exemplo n.º 6
0
def test5_add_swift_key(cluster, tid, uid, subid):
    secret = "%spass" % uid
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid

    cmd = t.build_cmd(
        '--subuser', "'%s:%s'" % (tid_uid, subid),
        '--key-type', 'swift',
        '--secret', secret,
        "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
    # XXX checking wrong thing here (S3 key)
    skj = outj['keys'][0]
    if skj['secret_key'] != secret:
        raise TestException(
            "command: key create --uid %s, returned s3 key %s" %
            (uid, skj['secret_key']))
Exemplo n.º 7
0
def test5_add_s3_key(cluster, tid, uid):
    secret = "%spass" % uid
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid

    cmd = t.build_cmd(
        '--uid', "'%s'" % (tid_uid,),
        '--access-key', uid,
        '--secret', secret,
        "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out.decode('utf-8'))
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
    skj = outj['keys'][0]
    if skj['secret_key'] != secret:
        raise TestException(
            "command: key create --uid %s, returned s3 key %s" %
            (uid, skj['secret_key']))
def test5_add_s3_key(cluster, tid, uid):
    secret = "%spass" % uid
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid

    cmd = t.build_cmd('--uid', "'%s'" % (tid_uid, ), '--access-key', uid,
                      '--secret', secret, "key create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: key create --uid %s" % uid)

    try:
        outj = json.loads(out.decode('utf-8'))
    except ValueError:
        raise TestException("invalid json after: key create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: key create --uid %s" % uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: key create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
    skj = outj['keys'][0]
    if skj['secret_key'] != secret:
        raise TestException(
            "command: key create --uid %s, returned s3 key %s" %
            (uid, skj['secret_key']))
Exemplo n.º 9
0
def test5_make_user(cluster, tid, uid, subid):
    """
    :param tid: Tenant ID string or None for the legacy tenant
    :param uid: User ID string
    :param subid: Subuser ID, may be None for S3-only users
    """
    display_name = "'Test User %s'" % uid

    cmd = ""
    if tid:
        cmd = t.build_cmd(cmd, '--tenant', tid)
    cmd = t.build_cmd(cmd, '--uid', uid, '--display-name', display_name)
    if subid:
        cmd = t.build_cmd(cmd, '--subuser', '%s:%s' % (uid, subid),
                          '--key-type', 'swift')
    cmd = t.build_cmd(cmd, '--access', 'full', "user create")

    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)
    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    if tid:
        tid_uid = "%s$%s" % (tid, uid)
    else:
        tid_uid = uid
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))

    #
    # For now, this uses hardcoded passwords based on uid.
    # They are all different for ease of debugging in case something crosses.
    #
    test5_add_s3_key(cluster, tid, uid)
    if subid:
        test5_add_swift_key(cluster, tid, uid, subid)
Exemplo n.º 10
0
def test2(cluster):
    uid = "tester2"
    display_name = "'Test User 2'"
    access_key = "tester2KEY"
    s3_secret = "test3pass"
    cmd = t.build_cmd('--uid', uid, '--display-name', display_name,
                      '--access-key', access_key, '--secret', s3_secret,
                      "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out)
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    if outj['user_id'] != uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
Exemplo n.º 11
0
def test2(cluster):
    uid = "tester2"
    display_name = "'Test User 2'"
    access_key = "tester2KEY"
    s3_secret = "test3pass"
    cmd = t.build_cmd('--uid', uid,
                    '--display-name', display_name,
                    '--access-key', access_key,
                    '--secret', s3_secret,
                    "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out.decode('utf-8'))
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    if outj['user_id'] != uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (uid, outj['user_id']))
Exemplo n.º 12
0
def test3(cluster):
    tid = "testx3"
    uid = "tester3"
    display_name = "Test_User_3"
    access_key = "tester3KEY"
    s3_secret = "test3pass"
    cmd = t.build_cmd('--tenant', tid, '--uid', uid, '--display-name',
                      display_name, '--access-key', access_key, '--secret',
                      s3_secret, "user create")
    out, ret = cluster.rgw_admin(cmd, check_retcode=False)
    if ret != 0:
        raise TestException("failed command: user create --uid %s" % uid)

    try:
        outj = json.loads(out.decode('utf-8'))
    except ValueError:
        raise TestException("invalid json after: user create --uid %s" % uid)
    if not isinstance(outj, dict):
        raise TestException("bad json after: user create --uid %s" % uid)
    tid_uid = "%s$%s" % (tid, uid)
    if outj['user_id'] != tid_uid:
        raise TestException(
            "command: user create --uid %s, returned user_id %s" %
            (tid_uid, outj['user_id']))