def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "vm-test-group" successfully added.',
                         '/group/add/',
                         form_data={
                             'group_name': 'vm-test-group',
                             'condor_central_manager': 'vm-test-group-one.ca',
                             'username': ut_id(gvar, '')[:-1]
                         })

    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud "vm-test-group::vm-test-cloud" successfully added.',
        '/cloud/add/',
        form_data={
            'group': 'vm-test-group',
            'cloud_name': 'vm-test-cloud',
            'authurl': 'vm-test-cloud.ca',
            'project': 'vm-test-cloud',
            'username': '******',
            'password': '******',
            'region': 'vm-test-cloud',
            'cloud_type': 'local'
        })
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    group_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'group'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'group')),
                             'is_superuser':
                             1
                         })

    # group to be changed in group_update
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg4')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg4'),
                             'condor_central_manager':
                             'unit-test-group-four.ca'
                         })

    # group to be changed in group_yaml_*
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg5'),
                             'condor_central_manager':
                             'unit-test-group-five.ca',
                         })

    # group to be deleted in group_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg6')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg6'),
                             'condor_central_manager':
                             'unit-test-group-six.ca',
                         })

    # group with no users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'gtg7')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'gtg7'),
                             'condor_central_manager':
                             'unit-test-group-seven.ca',
                         })

    # unprivileged user in groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar, 'group')),
                             'group_name.1':
                             ut_id(gvar, 'gtg4'),
                             'group_name.2':
                             ut_id(gvar, 'gtg5')
                         })

    # privileged user in group gtg5,6
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu5')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu5'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'is_superuser':
                             1,
                             'cert_cn':
                             '{} test user five'.format(ut_id(gvar, 'group')),
                             'group_name.1':
                             ut_id(gvar, 'gtg4'),
                             'group_name.2':
                             ut_id(gvar, 'gtg5'),
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty4')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty4'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty5')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty5'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty5.yaml')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty5.yaml'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    # metadata to be deleted in a cloud exception
    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gty6')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'metadata_name': ut_id(gvar, 'gty6'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)

    # unprivileged user to be added to groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'gtu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'gtu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'group'))
                         })

    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'gtg5'), ut_id(gvar, 'gtc1')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'gtg5'),
                             'cloud_name': ut_id(gvar, 'gtc1'),
                             'authurl': 'group-test-cloud-one.ca',
                             'project': 'group-test-cloud-one',
                             'username': ut_id(gvar, 'gtu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'gtc1-r'),
                             'cloud_type': 'local',
                             'metadata_name': ut_id(gvar, 'gty6')
                         },
                         server_user=ut_id(gvar, 'gtu3'),
                         server_pw=user_secret)
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    server_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'server'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'server')),
                             'is_superuser':
                             1
                         })

    # group without users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'stg1')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'stg1'),
                             'condor_central_manager': 'unit-test-group-one.ca'
                         })

    # group with users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'stg2')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'stg2'),
                             'condor_central_manager': 'unit-test-group-two.ca'
                         })

    # unprivileged user in group
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar,
                                                               'server')),
                             'group_name':
                             ut_id(gvar, 'stg2'),
                         })

    # privileged user in group
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'stu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'stu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'is_superuser':
                             1,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'server')),
                             'group_name':
                             ut_id(gvar, 'stg2'),
                         })
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()

    cloud_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu1')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu1'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user one'.format(ut_id(gvar, 'cloud'))
                         })

    # privileged user in no groups
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu2')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu2'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user two'.format(ut_id(gvar, 'cloud')),
                             'is_superuser':
                             1
                         })

    # group with users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'ctg1'),
                             'condor_central_manager': 'unit-test-group-one.ca'
                         })

    # group without users
    execute_csv2_request(gvar,
                         0,
                         None,
                         'group "{}" successfully added.'.format(
                             ut_id(gvar, 'ctg2')),
                         '/group/add/',
                         form_data={
                             'group_name': ut_id(gvar, 'ctg2'),
                             'condor_central_manager': 'unit-test-group-two.ca'
                         })

    # unprivileged user in ctg1
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu3')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu3'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user three'.format(ut_id(gvar, 'cloud')),
                             'group_name.1':
                             ut_id(gvar, 'ctg1')
                         })

    # privileged user in ctg1
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully added.'.format(
                             ut_id(gvar, 'ctu4')),
                         '/user/add/',
                         form_data={
                             'username':
                             ut_id(gvar, 'ctu4'),
                             'password1':
                             user_secret,
                             'password2':
                             user_secret,
                             'cert_cn':
                             '{} test user four'.format(ut_id(gvar, 'cloud')),
                             'is_superuser':
                             1,
                             'group_name.1':
                             ut_id(gvar, 'ctg1')
                         })

    # cloud to be deleted in test_cloud_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc1')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc1'),
                             'authurl': 'unit-test-cloud-one.ca',
                             'project': 'unit-test-cloud-one',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc1-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # cloud to be listed in test_cloud_list
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc2')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc2'),
                             'authurl': 'unit-test-cloud-two.ca',
                             'project': 'unit-test-cloud-two',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc2-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # cloud to be changed in test_cloud_update, test_cloud_metadata_add, test_cloud_metadata_delete
    execute_csv2_request(gvar,
                         0,
                         None,
                         'cloud "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3')),
                         '/cloud/add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'cloud_name': ut_id(gvar, 'ctc3'),
                             'authurl': 'unit-test-cloud-three.ca',
                             'project': 'unit-test-cloud-three',
                             'username': ut_id(gvar, 'ctu3'),
                             'password': user_secret,
                             'region': ut_id(gvar, 'ctc3-r'),
                             'cloud_type': 'local'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # metadata to be deleted in test_cloud_metadata_delete
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty2')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty2'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be updated in test_cloud_metadata_update
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar, 'cty3')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty3'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be updated in test_cloud_metadata_update
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc3'), ut_id(gvar,
                                                            'cty3.yaml')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc3'),
            'metadata_name': ut_id(gvar, 'cty3.yaml'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    # metadata to be fetched in test_cloud_metadata_fetch and test_cloud_metadata_list
    execute_csv2_request(
        gvar,
        0,
        None,
        'cloud metadata file "{}::{}::{}" successfully added.'.format(
            ut_id(gvar, 'ctg1'), ut_id(gvar, 'ctc2'), ut_id(gvar, 'cty1')),
        '/cloud/metadata-add/',
        form_data={
            'cloud_name': ut_id(gvar, 'ctc2'),
            'metadata_name': ut_id(gvar, 'cty1'),
            'metadata': '- example: yes'
        },
        server_user=ut_id(gvar, 'ctu3'),
        server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty1')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty1'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    # group metadata for metadata exceptions in test_cloud_add and test_cloud_update
    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty2')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty2'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)

    execute_csv2_request(gvar,
                         0,
                         None,
                         'file "{}::{}" successfully added.'.format(
                             ut_id(gvar, 'ctg1'), ut_id(gvar, 'cty3')),
                         '/group/metadata-add/',
                         form_data={
                             'group': ut_id(gvar, 'ctg1'),
                             'metadata_name': ut_id(gvar, 'cty3'),
                             'metadata': '- example: yaml'
                         },
                         server_user=ut_id(gvar, 'ctu3'),
                         server_pw=user_secret)
Exemple #5
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])

    new_secret = generate_secret()

    # 1
    execute_csv2_request(gvar,
                         2,
                         None,
                         'HTTP response code 401, unauthorized.',
                         '/user/settings/',
                         server_user='******',
                         server_pw=user_secret)

    # 2
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu1')),
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu1'),
                         server_pw=user_secret)

    # 3
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'user "{}" is not a member of any group.'.format(
                             ut_id(gvar, 'utu2')),
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu2'),
                         server_pw=user_secret)

    # 4
    execute_csv2_request(gvar,
                         1,
                         'UV16',
                         'invalid method "GET" specified.',
                         '/user/settings/',
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 5
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'cannot switch to invalid group "invalid-unit-test".',
                         '/user/settings/',
                         form_data={'group': 'invalid-unit-test'},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 6
    execute_csv2_request(gvar,
                         1,
                         'UV17',
                         'cannot switch to invalid group "{}".'.format(
                             ut_id(gvar, 'utg2')),
                         '/user/settings/',
                         form_data={'group': ut_id(gvar, 'utg2')},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 7
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'request contained a unnamed/bad parameter "invalid-unit-test".',
        '/user/settings/',
        form_data={'invalid-unit-test': 'invalid-unit-test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 8
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less than 6 characters.',
        '/user/settings/',
        form_data={'password': '******'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 9
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/settings/',
        form_data={'password': '******'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 10
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={'password': new_secret},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 11
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={'password': user_secret},
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=new_secret)

    # 12
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'password update received a password but no verify password; both are required.',
        '/user/settings/',
        form_data={'password1': 'test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 13
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'password update received a verify password but no password; both are required.',
        '/user/settings/',
        form_data={'password2': 'test'},
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 14
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less than 6 characters.',
        '/user/settings/',
        form_data={
            'password1': 'test',
            'password2': 'test'
        },
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 15
    execute_csv2_request(
        gvar,
        1,
        'UV15',
        'value specified for a password is less then 16 characters, and does not contain a mixture of upper, lower, and numerics.',
        '/user/settings/',
        form_data={
            'password1': 'invalid',
            'password2': 'invalid'
        },
        server_user=ut_id(gvar, 'utu3'),
        server_pw=user_secret)

    # 16
    execute_csv2_request(gvar,
                         1,
                         'UV15',
                         'values specified for passwords do not match.',
                         '/user/settings/',
                         form_data={
                             'password1': 'Abc123',
                             'password2': '321cbA'
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 17
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={
                             'password1': new_secret,
                             'password2': new_secret
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=user_secret)

    # 18
    execute_csv2_request(gvar,
                         0,
                         None,
                         'user "{}" successfully updated.'.format(
                             ut_id(gvar, 'utu3')),
                         '/user/settings/',
                         form_data={
                             'password1': user_secret,
                             'password2': user_secret
                         },
                         server_user=ut_id(gvar, 'utu3'),
                         server_pw=new_secret)
Exemple #6
0
def main(gvar, user_secret):
    if not gvar:
        gvar = {}
        if len(argv) > 1:
            initialize_csv2_request(gvar, argv[0], selections=argv[1])
        else:
            initialize_csv2_request(gvar, argv[0])
    if not user_secret:
        user_secret = generate_secret()
    
    cli_requests_cleanup.main(gvar)

    # unprivileged user in no groups
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu1')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu1'),
            'password1': user_secret,
            'password2': user_secret,
            'cert_cn': ut_id(gvar, 'command line user one')
        }
    )
    
    # privileged user in no groups
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu2')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu2'),
            'password1': user_secret,
            'password2': user_secret,
            'cert_cn': ut_id(gvar, 'command line user two'),
            'is_superuser': 1
        }
    )

    # user for unprivleged tests
    execute_csv2_request(
        gvar, 0, None, None,
        '/user/add/', form_data={
            'username': ut_id(gvar, 'test'),
            'password1': user_secret,
            'password2': user_secret,
            'cert_cn': ut_id(gvar, 'test'),
            'is_superuser': 0,
        }
    )

    # group with users
    execute_csv2_request(
        gvar, 0, None, 'group "{}" successfully added.'.format(ut_id(gvar, 'clg1')),
        '/group/add/', form_data={
            'group_name': ut_id(gvar, 'clg1'),
            'condor_central_manager': 'unit-test-group-one.ca',
            'username.1': ut_id(gvar, '')[:-1],
            'username.2': ut_id(gvar, 'test'),
        }
    )

    # group without users
    execute_csv2_request(
        gvar, 0, None, 'group "{}" successfully added.'.format(ut_id(gvar, 'clg2')),
        '/group/add/', form_data={
            'group_name': ut_id(gvar, 'clg2'),
            'condor_central_manager': 'unit-test-group-two.ca'
        }
    )

    # group to be deleted without users
    execute_csv2_request(
        gvar, 0, None, 'group "{}" successfully added.'.format(ut_id(gvar, 'clg3')),
        '/group/add/', form_data={
            'group_name': ut_id(gvar, 'clg3'),
            'condor_central_manager': 'unit-test-group-three.ca'
        }
    )

    # group to be deleted with users
    execute_csv2_request(
        gvar, 0, None, 'group "{}" successfully added.'.format(ut_id(gvar, 'clg4')),
        '/group/add/', form_data={
            'group_name': ut_id(gvar, 'clg4'),
            'condor_central_manager': 'unit-test-group-four.ca'
        }
    )

    # unprivileged user in clg1
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu3')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu3'),
            'password1': user_secret,
            'password2': user_secret,
            'cert_cn': ut_id(gvar, 'command line user three'),
            'group_name.1': ut_id(gvar, 'clg1')
        }
    )
    
    # privileged user in clg1
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu4')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu4'),
            'password1': user_secret,
            'password2': user_secret,
            'cert_cn': ut_id(gvar, 'command line user four'),
            'is_superuser': 1,
            'group_name.1': ut_id(gvar, 'clg1'),
            'group_name.2': ut_id(gvar, 'clg4')
        }
    )

    # user to be deleted in no groups
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu5')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu5'),
            'password': user_secret,
            'cert_cn': ut_id(gvar, 'command line user five')
        }
    )

    # user to be deleted in groups
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu6')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu6'),
            'password': user_secret,
            'cert_cn': ut_id(gvar, 'command line user six'),
            'group_name': ut_id(gvar, 'clg1')
        }
    )

    # user to be updated
    execute_csv2_request(
        gvar, 0, None, 'user "{}" successfully added.'.format(ut_id(gvar, 'clu7')),
        '/user/add/', form_data={
            'username': ut_id(gvar, 'clu7'),
            'password': user_secret,
            'cert_cn': ut_id(gvar, 'command line user seven')
        }
    )

    # cloud to be deleted
    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc1')),
        '/cloud/add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'cloud_name': ut_id(gvar, 'clc1'),
            'authurl': 'unit-test-cloud-one.ca',
            'project': 'unit-test-cloud-one',
            'username': ut_id(gvar, 'clc1'),
            'password': '******',
            'region': ut_id(gvar, 'clc1-r'),
            'cloud_type': 'local'
        }
    )

    # cloud to be deleted
    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc3')),
        '/cloud/add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'cloud_name': ut_id(gvar, 'clc3'),
            'authurl': 'unit-test-cloud-three.ca',
            'project': 'unit-test-cloud-three',
            'username': ut_id(gvar, 'clc3'),
            'password': '******',
            'region': ut_id(gvar, 'clc3-r'),
            'cloud_type': 'local'
        }
    )

    # cloud to be listed and edited
    execute_csv2_request(
        gvar, 0, None, 'cloud "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2')),
        '/cloud/add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'cloud_name': ut_id(gvar, 'clc2'),
            'authurl': 'unit-test-cloud-two.ca',
            'project': 'unit-test-cloud-two',
            'username': ut_id(gvar, 'clc2'),
            'password': '******',
            'region': ut_id(gvar, 'clc2-r'),
            'cloud_type': 'local'
        }
    )

    # group metadata to be deleted
    execute_csv2_request(
        gvar, 0, None, 'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clm1')),
        '/group/metadata-add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'metadata_name': ut_id(gvar, 'clm1'),
            'metadata': '- example: yaml'
        }
    )

    # group metadata to be edited
    execute_csv2_request(
        gvar, 0, None, 'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clm2')),
        '/group/metadata-add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'metadata_name': ut_id(gvar, 'clm2'),
            'metadata': '- example: yaml'
        }
    )

    execute_csv2_request(
        gvar, 0, None, 'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clm2.yaml')),
        '/group/metadata-add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'metadata_name': ut_id(gvar, 'clm2.yaml'),
            'metadata': '- example: yaml'
        }
    )

    execute_csv2_request(
        gvar, 0, None, 'file "{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clm3')),
        '/group/metadata-add/', form_data={
            'group': ut_id(gvar, 'clg1'),
            'metadata_name': ut_id(gvar, 'clm3'),
            'metadata': '- example: yaml'
        }
    )

    # cloud metadata to be deleted
    execute_csv2_request(
        gvar, 0, None, 'cloud metadata file "{}::{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2'), ut_id(gvar, 'clm1')),
        '/cloud/metadata-add/', form_data={
            'cloud_name': ut_id(gvar, 'clc2'),
            'metadata_name': ut_id(gvar, 'clm1'),
            'metadata': '- example: yes'
        }
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud metadata file "{}::{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2'), ut_id(gvar, 'clm3')),
        '/cloud/metadata-add/', form_data={
            'cloud_name': ut_id(gvar, 'clc2'),
            'metadata_name': ut_id(gvar, 'clm3'),
            'metadata': '- example: yes'
        }
    )

    # cloud metadata to be edited
    execute_csv2_request(
        gvar, 0, None, 'cloud metadata file "{}::{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2'), ut_id(gvar, 'clm2')),
        '/cloud/metadata-add/', form_data={
            'cloud_name': ut_id(gvar, 'clc2'),
            'metadata_name': ut_id(gvar, 'clm2'),
            'metadata': '- example: yes'
        }
    )

    execute_csv2_request(
        gvar, 0, None, 'cloud metadata file "{}::{}::{}" successfully added.'.format(ut_id(gvar, 'clg1'), ut_id(gvar, 'clc2'), ut_id(gvar, 'clm2.yaml')),
        '/cloud/metadata-add/', form_data={
            'cloud_name': ut_id(gvar, 'clc2'),
            'metadata_name': ut_id(gvar, 'clm2.yaml'),
            'metadata': '- example: yes'
        }
    )
    
    execute_csv2_command(
        gvar, 0, None, None,
        ['cloudscheduler', 'defaults', 'set', '-s', 'unit-test-un', '-su', ut_id(gvar, 'test'), '-spw', user_secret]
    )