Ejemplo n.º 1
0
 def test_http_get_status_check_false(self):
     """Confirm the truth check for status response code OK is False for non-existent site"""
     http = HTTP('http://www.abogussitename.com')
     self.assertEqual(http.get_status_ok(), False)
     self.assertEqual(
         http.res, None
     )  # confirm that the response object is None when site does not exist
Ejemplo n.º 2
0
 def test_http_get_status_check_true(self):
     """Confirm the truth check for status response code OK (=200) is True when should be true"""
     http = HTTP('http://httpbin.org/status/200')
     self.assertEqual(http.get_status_ok(), True)
     self.assertEqual(
         http.res.status_code, 200
     )  #confirm that the response object is set after the get_status_ok() call
Ejemplo n.º 3
0
def _pull_official_repository_json():
    package = OfficialPackage()
    master_package_json_url = package.get_master_package_description_json_url()
    http = HTTP(master_package_json_url)
    try:
        if http.get_status_ok():
            master_list = http.res.text
            return master_list.strip()   # strip additional spaces, blank end lines off of the list
        else:
            stderr("[!] Unable to pull the remote repository package descriptions (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull the remote repository package descriptions. Error: " + str(e), exit=1)  
Ejemplo n.º 4
0
def _pull_official_repository_descriptions():
    package = OfficialPackage()
    master_package_descriptions = package.get_master_package_description_json_url()
    http = HTTP(master_package_descriptions)
    try:
        if http.get_status_ok():
            master_descriptions = http.res.text
            return master_descriptions.strip()
        else:
            stderr("[!] doxx: Unable to pull remote repository descriptions (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull remote repository descriptions Error: " + str(e) + ")", exit=1)
        
Ejemplo n.º 5
0
Archivo: pull.py Proyecto: tstyle/doxx
def pull_text_file(url, text_file_name):
    """pulls a remote text file and writes to disk"""
    # pull the binary file data
    http = HTTP(url)
    try:
        if http.get_status_ok():
            text_data = http.res.text
            # write text data to disk
            try:
                fw = FileWriter(text_file_name)
                fw.write(text_data)
            except Exception as e:
                stderr("[!] doxx: File write failed for '" + text_file_name + "'.  Error: " + str(e), exit=1)
        else:
            fail_status_code = http.res.status_code
            stderr("[!] doxx: Unable to pull '" + url + "' (HTTP status code " + str(fail_status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull '" + url + "'. Error: " + str(e), exit=1)
Ejemplo n.º 6
0
def run_pullkey(package_name):
    normalized_package_name = package_name.lower().strip()
    package = OfficialPackage()
    key_file_url = package.get_package_key_url(normalized_package_name)
    try:
        stdout("[*] doxx: Pulling the remote key file...")
        http = HTTP(key_file_url)
        if http.get_status_ok():
            key_file_text = http.res.text
            fr = FileWriter('key.yaml')
            try:
                fr.write(key_file_text)
            except Exception as e:
                stderr("[!] doxx: Unable to write the 'key.yaml' file to disk. Error: " + str(e), exit=1)
            stdout("[*] doxx: Key file pull complete")
        elif http.res.status_code == 404:
            stderr("[!] doxx: Unable to pull the key file because the requested package could not be found. (HTTP status code: 404)", exit=1)
        else:
            stderr("[!] doxx: Unable to pull the key file.  (HTTP status code: " + str(http.res.status_code) + ")", exit=1)
    except Exception as e:
        stderr("[!] doxx: Unable to pull the key file. Error: " + str(e), exit=1)
        
Ejemplo n.º 7
0
 def test_http_get_status_check_false(self):
     """Confirm the truth check for status response code OK is False for non-existent site"""
     http = HTTP('http://www.abogussitename.com')
     self.assertEqual(http.get_status_ok(), False)
     self.assertEqual(http.res, None) # confirm that the response object is None when site does not exist
Ejemplo n.º 8
0
 def test_http_get_status_check_true(self):
     """Confirm the truth check for status response code OK (=200) is True when should be true"""
     http = HTTP('http://httpbin.org/status/200')
     self.assertEqual(http.get_status_ok(), True)
     self.assertEqual(http.res.status_code, 200) #confirm that the response object is set after the get_status_ok() call