Exemple #1
0
def test_config_clear_upload_key():
    config.config_file_clear_section(SECTION)
    random_key = ''.join(
        random.choices(string.ascii_uppercase + string.digits, k=12))
    config.config_file_save_upload_key(random_key, USERNAME, SECTION)
    assert config.config_file_read_upload_key(SECTION) == random_key
    config.config_file_clear_upload_key(SECTION)
    assert config.config_file_read_upload_key(SECTION) is None
Exemple #2
0
 def _get_and_save_upload_key(cls, state, username, auth_token):
     ArcsecondAPI._echo_message(state, 'Fetching Upload Key...')
     # To get API key one must fetch it with Auth token obtained via login.
     endpoint = ProfileUploadKeyAPIEndPoint(state.make_new_silent())
     endpoint.use_headers({'Authorization': 'Token ' + auth_token})
     result, error = endpoint.read(username)
     if error:
         ArcsecondAPI._echo_error(state, error)
     if result:
         config_file_save_upload_key(result['upload_key'], username, state.config_section())
         msg = f'Successful Upload key retrieval and storage in {config_file_path()}. Enjoy.'
         ArcsecondAPI._echo_message(state, msg)
     return result, error
Exemple #3
0
def test_config_file_is_logged_in_has_api_and_upload_keys():
    config.config_file_clear_section(SECTION)
    config.config_file_save_api_key(API_KEY, USERNAME, SECTION)
    config.config_file_save_upload_key(UPLOAD_KEY, USERNAME, SECTION)
    assert config.config_file_is_logged_in(SECTION) is True