def test_add_cloud(self, pretty_print, owner_api_token): """Test case for add_cloud Add cloud """ add_cloud_request = setup_data.get( 'add_cloud', {}).get('request_body') or json.loads("""{ "name" : "my-cloud", "provider" : "google", "credentials" : { "projectId" : "projectId", "privateKey" : "privateKey", "email" : "email" } }""", strict=False) uri = MIST_URL + '/api/v2/clouds' request = MistRequests(api_token=owner_api_token, uri=uri, json=add_cloud_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'add_cloud' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_run_script(self, pretty_print, owner_api_token): """Test case for run_script Run script """ run_script_request = setup_data.get( 'run_script', {}).get('request_body') or json.loads("""{ "su" : "false", "machine" : "my-machine", "job_id" : "ab74e2f0b7ae4999b1e4013e20dac418", "params" : "-v", "env" : "EXAMPLE_VAR=123" }""", strict=False) uri = MIST_URL + '/api/v2/scripts/{script}'.format( script=setup_data.get('run_script', {}).get('script') or setup_data.get('script') or 'my-script') request = MistRequests(api_token=owner_api_token, uri=uri, json=run_script_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'run_script' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_create_cluster(self, pretty_print, owner_api_token): """Test case for create_cluster Create cluster """ create_cluster_request = setup_data.get( 'create_cluster', {}).get('request_body') or json.loads( """{ "name" : "my-cluster", "cloud" : "my-cloud", "provider" : "google", "location" : "my-location" }""", strict=False) uri = MIST_URL + '/api/v2/clusters' request = MistRequests(api_token=owner_api_token, uri=uri, json=create_cluster_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'create_cluster' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_list_org_teams(self, pretty_print, owner_api_token): """Test case for list_org_teams List org teams """ query_string = setup_data.get('list_org_teams', {}).get('query_string') or [ ('search', 'name:finance'), ('sort', '-name'), ('start', '50'), ('limit', '56'), ('only', 'id'), ('deref', 'auto') ] uri = MIST_URL + '/api/v2/orgs/{org}/teams'.format( org=setup_data.get('list_org_teams', {}).get('org') or setup_data.get('org') or 'my-org') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'list_org_teams' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_create_volume(self, pretty_print, owner_api_token): """Test case for create_volume Create volume """ create_volume_request = setup_data.get( 'create_volume', {}).get('request_body') or json.loads( """{ "template" : "{}", "quantity" : 0, "ex_disk_type" : "pd-standard", "ex_volume_type" : "standard", "save" : true, "dry" : true, "tags" : "{}", "cloud" : "my-cloud", "ex_iops" : "ex_iops", "size" : 1, "extra" : "{}", "name" : "my-volume", "location" : "us-central1-a" }""", strict=False) uri = MIST_URL + '/api/v2/volumes' request = MistRequests(api_token=owner_api_token, uri=uri, json=create_volume_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'create_volume' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_add_script(self, pretty_print, owner_api_token): """Test case for add_script Add script """ add_script_request = setup_data.get( 'add_script', {}).get('request_body') or json.loads("""{ "entrypoint" : "entrypoint.sh", "name" : "my-script", "description" : "description", "exec_type" : "executable", "script" : "#!/usr/bin/env bash\necho Hello, World!", "location_type" : "inline" }""", strict=False) uri = MIST_URL + '/api/v2/scripts' request = MistRequests(api_token=owner_api_token, uri=uri, json=add_script_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'add_script' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_create_network(self, pretty_print, owner_api_token): """Test case for create_network Create network """ create_network_request = setup_data.get( 'create_network', {}).get('request_body') or json.loads( """{ "cloud" : "my-cloud", "template" : "{}", "extra" : "{}", "name" : "my-network", "save" : true, "dry" : true, "tags" : "{}" }""", strict=False) uri = MIST_URL + '/api/v2/networks' request = MistRequests(api_token=owner_api_token, uri=uri, json=create_network_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'create_network' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_delete_key(self, pretty_print, owner_api_token): """Test case for delete_key Delete key """ uri = MIST_URL + '/api/v2/keys/{key}'.format(key=setup_data.get( 'delete_key', {}).get('key') or setup_data.get('key') or 'my-key') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'DELETE'.lower()) response = request_method() if 'delete_key' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_edit_zone(self, pretty_print, owner_api_token): """Test case for edit_zone Edit zone """ uri = MIST_URL + '/api/v2/zones/{zone}'.format( zone=setup_data.get('edit_zone', {}).get('zone') or setup_data.get('zone') or 'my-zone') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'PUT'.lower()) response = request_method() if 'edit_zone' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_download_script(self, pretty_print, owner_api_token): """Test case for download_script Download script """ uri = MIST_URL + '/api/v2/scripts/{script}/file'.format( script=setup_data.get('download_script', {}).get('script') or setup_data.get('script') or 'my-script') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'download_script' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_list_snapshots(self, pretty_print, owner_api_token): """Test case for list_snapshots List machine snapshots """ uri = MIST_URL + '/api/v2/machines/{machine}/snapshots'.format( machine=setup_data.get('list_snapshots', {}).get('machine') or setup_data.get('machine') or 'my-machine') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'list_snapshots' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_job(self, pretty_print, owner_api_token): """Test case for get_job Get job """ uri = MIST_URL + '/api/v2/jobs/{job_id}'.format( job_id=setup_data.get('get_job', {}).get('job_id') or setup_data.get('job_id') or 'ab74e2f0b7ae4999b1e4013e20dac418') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_job' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_destroy_cluster(self, pretty_print, owner_api_token): """Test case for destroy_cluster Destroy cluster """ uri = MIST_URL + '/api/v2/clusters/{cluster}'.format( cluster=setup_data.get('destroy_cluster', {}).get('cluster') or setup_data.get('cluster') or 'my-cluster') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'DELETE'.lower()) response = request_method() if 'destroy_cluster' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_remove_cloud(self, pretty_print, owner_api_token): """Test case for remove_cloud Remove cloud """ uri = MIST_URL + '/api/v2/clouds/{cloud}'.format( cloud=setup_data.get('remove_cloud', {}).get('cloud') or setup_data.get('cloud') or 'my-cloud') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'DELETE'.lower()) response = request_method() if 'remove_cloud' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_remove_snapshot(self, pretty_print, owner_api_token): """Test case for remove_snapshot Remove snapshot """ uri = MIST_URL + '/api/v2/machines/{machine}/snapshots/{snapshot}'.format( machine=setup_data.get('remove_snapshot', {}).get('machine') or setup_data.get('machine') or 'my-machine', snapshot=setup_data.get('remove_snapshot', {}).get('snapshot') or setup_data.get('snapshot') or 'my-snapshot') request = MistRequests(api_token=owner_api_token, uri=uri) request_method = getattr(request, 'DELETE'.lower()) response = request_method() if 'remove_snapshot' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_size(self, pretty_print, owner_api_token): """Test case for get_size Get size """ query_string = setup_data.get('get_size', {}).get('query_string') or [('only', 'id'), ('deref', 'auto')] uri = MIST_URL + '/api/v2/sizes/{size}'.format( size=setup_data.get('get_size', {}).get('size') or setup_data.get('size') or 'n2-highcpu-2 (2 vCPUs 2 GB RAM)') request = MistRequests( api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_size' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_org(self, pretty_print, owner_api_token): """Test case for get_org Get Org """ query_string = setup_data.get( 'get_org', {}).get('query_string') or [('only', 'id'), ('deref', 'auto')] uri = MIST_URL + '/api/v2/orgs/{org}'.format(org=setup_data.get( 'get_org', {}).get('org') or setup_data.get('org') or 'my-org') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_org' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_rule(self, pretty_print, owner_api_token): """Test case for get_rule Get rule """ query_string = setup_data.get( 'get_rule', {}).get('query_string') or [('sort', '-name'), ('only', 'id')] uri = MIST_URL + '/api/v2/rules/{rule}'.format(rule=setup_data.get( 'get_rule', {}).get('rule') or setup_data.get('rule') or 'my-rule') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_rule' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_toggle_rule(self, pretty_print, owner_api_token): """Test case for toggle_rule Toggle rule """ query_string = setup_data.get( 'toggle_rule', {}).get('query_string') or [('action', 'disable')] uri = MIST_URL + '/api/v2/rules/{rule}'.format( rule=setup_data.get('toggle_rule', {}).get('rule') or setup_data.get('rule') or 'my-rule') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'PUT'.lower()) response = request_method() if 'toggle_rule' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_edit_key(self, pretty_print, owner_api_token): """Test case for edit_key Edit key """ query_string = setup_data.get( 'edit_key', {}).get('query_string') or [('name', 'my-renamed-key'), ('default', 'True')] uri = MIST_URL + '/api/v2/keys/{key}'.format(key=setup_data.get( 'edit_key', {}).get('key') or setup_data.get('key') or 'my-key') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'PUT'.lower()) response = request_method() if 'edit_key' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_list_keys(self, pretty_print, owner_api_token): """Test case for list_keys List keys """ query_string = setup_data.get('list_keys', {}).get('query_string') or [ ('search', 'owned_by:[email protected]'), ('sort', '-name'), ('start', '50'), ('limit', '56'), ('only', 'id'), ('deref', 'auto') ] uri = MIST_URL + '/api/v2/keys' request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'list_keys' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_image(self, pretty_print, owner_api_token): """Test case for get_image Get image """ query_string = setup_data.get( 'get_image', {}).get('query_string') or [('only', 'id'), ('deref', 'auto')] uri = MIST_URL + '/api/v2/images/{image}'.format( image=setup_data.get('get_image', {}).get('image') or setup_data.get('image') or 'ubuntu-1604-xenial-v20210928') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_image' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_location(self, pretty_print, owner_api_token): """Test case for get_location Get location """ query_string = setup_data.get( 'get_location', {}).get('query_string') or [('only', 'id'), ('deref', 'auto')] uri = MIST_URL + '/api/v2/locations/{location}'.format( location=setup_data.get('get_location', {}).get('location') or setup_data.get('location') or 'us-central1-a') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_location' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_delete_network(self, pretty_print, owner_api_token): """Test case for delete_network Delete network """ query_string = setup_data.get( 'delete_network', {}).get('query_string') or [('cloud', 'my-cloud') ] uri = MIST_URL + '/api/v2/networks/{network}'.format( network=setup_data.get('delete_network', {}).get('network') or setup_data.get('network') or 'my-network') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'DELETE'.lower()) response = request_method() if 'delete_network' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_get_key(self, pretty_print, owner_api_token): """Test case for get_key Get key """ query_string = setup_data.get( 'get_key', {}).get('query_string') or [('private', 'False'), ('sort', '-name'), ('only', 'id'), ('deref', 'auto')] uri = MIST_URL + '/api/v2/keys/{key}'.format(key=setup_data.get( 'get_key', {}).get('key') or setup_data.get('key') or 'my-key') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'get_key' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_list_networks(self, pretty_print, owner_api_token): """Test case for list_networks List networks """ query_string = setup_data.get( 'list_networks', {}).get('query_string') or [ ('cloud', '0194030499e74b02bdf68fa7130fb0b2'), ('search', 'cinet3'), ('sort', '-name'), ('start', '50'), ('limit', '56'), ('only', 'id'), ('deref', 'auto') ] uri = MIST_URL + '/api/v2/networks' request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'GET'.lower()) response = request_method() if 'list_networks' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_create_snapshot(self, pretty_print, owner_api_token): """Test case for create_snapshot Create snapshot """ query_string = setup_data.get('create_snapshot', {}).get('query_string') or [ ('name', 'my-snapshot') ] uri = MIST_URL + '/api/v2/machines/{machine}/snapshots'.format( machine=setup_data.get('create_snapshot', {}).get('machine') or setup_data.get('machine') or 'my-machine') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'create_snapshot' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_edit_volume(self, pretty_print, owner_api_token): """Test case for edit_volume Edit volume """ query_string = setup_data.get('edit_volume', {}).get('query_string') or [ ('name', 'my-renamed-volume') ] uri = MIST_URL + '/api/v2/volumes/{volume}'.format( volume=setup_data.get('edit_volume', {}).get('volume') or setup_data.get('volume') or 'my-volume') request = MistRequests(api_token=owner_api_token, uri=uri, params=query_string) request_method = getattr(request, 'PUT'.lower()) response = request_method() if 'edit_volume' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_add_key(self, pretty_print, owner_api_token): """Test case for add_key Add key """ add_key_request = setup_data.get( 'add_key', {}).get('request_body') or json.loads("""{ "name" : "my-key", "private" : "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh 3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2 pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ 37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----END RSA PRIVATE KEY-----" }""", strict=False) uri = MIST_URL + '/api/v2/keys' request = MistRequests(api_token=owner_api_token, uri=uri, json=add_key_request) request_method = getattr(request, 'POST'.lower()) response = request_method() if 'add_key' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')
def test_edit_cloud(self, pretty_print, owner_api_token): """Test case for edit_cloud Edit cloud """ edit_cloud_request = setup_data.get( 'edit_cloud', {}).get('request_body') or json.loads("""{ "name" : "my-renamed-cloud" }""", strict=False) uri = MIST_URL + '/api/v2/clouds/{cloud}'.format( cloud=setup_data.get('edit_cloud', {}).get('cloud') or setup_data.get('cloud') or 'my-cloud') request = MistRequests(api_token=owner_api_token, uri=uri, json=edit_cloud_request) request_method = getattr(request, 'PUT'.lower()) response = request_method() if 'edit_cloud' in REDIRECT_OPERATIONS: assert_response_found(response) else: assert_response_ok(response) print('Success!!!')