def test_exec_read(config):

    grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

    test_info = AddTestInfo(
        'Test with read permission on buckets for all users')

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:

        # test case starts

        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count)

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)

        all_user_details.pop(0)

        u1 = ObjectOps(config, user1)

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info('canonical id of u2: %s' % u2_canonical_id)

            grants['user_id'] = u2_canonical_id

            u1.grants = None
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

            # set permissions and read

            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

        test_info.success_status('test completed')

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec_write(config):
    test_info = AddTestInfo(
        "test with write persmission on objects and buckets for all users")
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        u1.create_bucket()
        log.info("user1: %s" % user1)
        all_user_details.pop(0)
        for each_user in all_user_details:
            print("iter ------------------>")
            log.info("user2: %s" % each_user)
            u2 = ObjectOps(config, each_user)
            u2_canonical_id = u2.canonical_id
            log.info("canonical id of u2: %s" % u2_canonical_id)
            log.info("setting only read permission")
            grants = {"permission": "READ", "user_id": None, "recursive": True}
            log.info("write persmission are not set")
            grants["user_id"] = u2_canonical_id
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    "no write permission set and hence failing to create object"
                )
            elif key_created:
                raise AssertionError("object created even with no permission")
            log.info("setting permission to write also")
            grants = {
                "permission": "WRITE",
                "user_id": u2_canonical_id,
                "recursive": True,
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info("object created after permission set")
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
Exemple #3
0
def test_exec_write(config):
    test_info = AddTestInfo(
        "test with write persmission on objects and buckets")
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info("canonical id of u2: %s" % u2_canonical_id)
        grants = {"permission": "READ", "user_id": None, "recursive": True}
        log.info("write persmission are not set")
        grants["user_id"] = u2_canonical_id
        u1.grants = grants
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info(
                "no write permission set and hence failing to create object")
        log.info("setting permission to write also")
        grants = {
            "permission": "WRITE",
            "user_id": u2_canonical_id,
            "recursive": True
        }
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info("object created after permission set")
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
Exemple #4
0
def test_exec_write(config):
    test_info = AddTestInfo('test with write persmission on objects and buckets for all users')
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info('user1: %s' % user1)
        all_user_details.pop(0)
        for each_user in all_user_details:
            print('iter ------------------>')
            log.info('user2: %s' % each_user)
            u2 = ObjectOps(config, each_user)
            u2_canonical_id = u2.canonical_id
            log.info('canonical id of u2: %s' % u2_canonical_id)
            log.info('setting only read permission')
            grants = {'permission': 'READ', 'user_id': None, 'recursive': True}
            log.info('write persmission are not set')
            grants['user_id'] = u2_canonical_id
            u1.grants = grants
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info('no write permission set and hence failing to create object')
            elif key_created:
                raise AssertionError("object created even with no permission")
            log.info('setting permission to write also')
            grants = {'permission': 'WRITE', 'user_id': u2_canonical_id, 'recursive': True}
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets, object_base_name=str(u2.canonical_id) + ".key")
            if key_created:
                log.info('object created after permission set')
        test_info.success_status('test completed')
    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
Exemple #5
0
def test_exec_write(config):
    test_info = AddTestInfo('test with write persmission on objects and buckets')
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info('canonical id of u2: %s' % u2_canonical_id)
        grants = {'permission': 'READ', 'user_id': None, 'recursive': True}
        log.info('write persmission are not set')
        grants['user_id'] = u2_canonical_id
        u1.grants = grants
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info('no write permission set and hence failing to create object')
        log.info('setting permission to write also')
        grants = {'permission': 'WRITE', 'user_id': u2_canonical_id, 'recursive': True}
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info('object created after permission set')
        test_info.success_status('test completed')
    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
Exemple #6
0
def test_exec_read(config):
    """
    config.bucket_count = 3
    config.objects_count = 3
    config.objects_size_range = {'min': 50, 'max': 100}
    """
    grants = {"permission": "READ", "user_id": None, "recursive": True}
    test_info = AddTestInfo("Test with read permission on buckets")
    add_io_info = AddIOInfo()
    add_io_info.initialize()
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info("canonical id of u2: %s" % u2_canonical_id)
        grants["user_id"] = u2_canonical_id
        u1.grants = None
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        u2.set_bucket_properties()
        # set permissions and read
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        u2.set_bucket_properties()
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec_write(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo(
        "give the permission for all the users and then reset it")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:

            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                })

        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info("user1: %s" % user1)

        all_user_details.pop(0)

        for each_user in all_user_details:

            print("iter ------------------>")

            log.info("user2: %s" % each_user)

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info("canonical id of u2: %s" % u2_canonical_id)

            log.info("setting only read permission")

            grants = {"permission": "READ", "user_id": None, "recursive": True}

            log.info("write persmission are not set")
            grants["user_id"] = u2_canonical_id

            u1.grants = grants

            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            u2.create_bucket()
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    "no write permission set and hence failing to create object"
                )

            elif key_created:
                raise AssertionError("object created even with no permission")

            log.info("setting permission to write also")

            grants = {
                "permission": "WRITE",
                "user_id": u2_canonical_id,
                "recursive": True,
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info("object created after permission set")

        log.info(
            "***************** removing grants and making the bucket private *****************"
        )
        u1.grants = None
        u1.acls = "private"
        u1.set_bucket_properties()

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            print("iter ------------------>")

            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            buckets = u2.set_bucket_properties()

            if not buckets:
                log.info("bucket init failed: %s" % buckets)
            elif buckets:

                key_created = u2.upload(buckets)
                if not key_created:
                    log.info(
                        "no write permission set and hence failing to create object"
                    )

                elif key_created:
                    raise AssertionError(
                        "object created even with no permission")

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
Exemple #8
0
def test_exec_write(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    test_info = AddTestInfo(
        'give the permission for all the users and then reset it')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:

            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info('user1: %s' % user1)

        all_user_details.pop(0)

        for each_user in all_user_details:

            print('iter ------------------>')

            log.info('user2: %s' % each_user)

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info('canonical id of u2: %s' % u2_canonical_id)

            log.info('setting only read permission')

            grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

            log.info('write persmission are not set')
            grants['user_id'] = u2_canonical_id

            u1.grants = grants

            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            u2.create_bucket()
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    'no write permission set and hence failing to create object'
                )

            elif key_created:
                raise AssertionError("object created even with no permission")

            log.info('setting permission to write also')

            grants = {
                'permission': 'WRITE',
                'user_id': u2_canonical_id,
                'recursive': True
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info('object created after permission set')

        log.info(
            '***************** removing grants and making the bucket private *****************'
        )
        u1.grants = None
        u1.acls = 'private'
        u1.set_bucket_properties()

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            print('iter ------------------>')

            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download

            u2.grants = None
            buckets = u2.set_bucket_properties()

            if not buckets:
                log.info('bucket init failed: %s' % buckets)
            elif buckets:

                key_created = u2.upload(buckets)
                if not key_created:
                    log.info(
                        'no write permission set and hence failing to create object'
                    )

                elif key_created:
                    raise AssertionError(
                        "object created even with no permission")

        test_info.success_status('test completed')

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
Exemple #9
0
def test_exec_read(config):

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    grants = {"permission": "READ", "user_id": None, "recursive": True}

    test_info = AddTestInfo("Test with read permission on buckets for all users")

    try:

        # test case starts

        test_info.started_info()

        with open("user_details") as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    "user_id": each_user["user_id"],
                    "access_key": each_user["access_key"],
                    "secret_key": each_user["secret_key"],
                }
            )

        user1 = all_user_details[0]
        log.info("user1: %s" % user1)

        all_user_details.pop(0)

        u1 = ObjectOps(config, user1)

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info("canonical id of u2: %s" % u2_canonical_id)

            grants["user_id"] = u2_canonical_id

            u1.grants = None
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

            # set permissions and read

            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

        test_info.success_status("test completed")

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
Exemple #10
0
def test_exec_read(config):
    """
    config.bucket_count = 3
    config.objects_count = 3
    config.objects_size_range = {'min': 50, 'max': 100}
    """

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

    test_info = AddTestInfo('Test with read permission on buckets')

    try:

        # test case starts

        test_info.started_info()

        with open('user_details') as fout:
            all_user_details = simplejson.load(fout)

        for each_user in all_user_details:
            add_io_info.add_user_info(
                **{
                    'user_id': each_user['user_id'],
                    'access_key': each_user['access_key'],
                    'secret_key': each_user['secret_key']
                })

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)

        u1 = ObjectOps(config, user1)

        u2 = ObjectOps(config, user2)

        u2_canonical_id = u2.canonical_id

        log.info('canonical id of u2: %s' % u2_canonical_id)

        grants['user_id'] = u2_canonical_id

        u1.grants = None
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.grants = None
        u2.set_bucket_properties()

        # set permissions and read

        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created

        u2.grants = None
        u2.set_bucket_properties()

        test_info.success_status('test completed')

    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)