コード例 #1
0
ファイル: make.py プロジェクト: INAP-LABS/noc-orchestrator
    def run(self):
        if self.app_name == None:
            i = InfoCompiler(None)
            data_container = i.getSetupFileInfo()
        else:
            i = InfoCompiler(self.app_name)
            data_container = i.getUserInfo()

        db = DirectoryBuilder(data_container)
        db.build()
        fb = FileBuilder(data_container)
        if fb.build_and_write(): # file writes were successful
            main_script_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'app.py')
            settings_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'settings.py')
            command_dir = make_path(data_container.app_name, 'lib', data_container.app_name, 'commands')
            setuppy_path = make_path(data_container.app_name, 'setup.py')
            print(" ")
            print(data_container.app_name + " was successfully built.")
            print(" ")
            print("-----")
            print("Main application script:  " + main_script_path)
            print("Settings file:  " + settings_path)
            print("Commands directory:  " + command_dir)
            print("setup.py file:  " + setuppy_path)
            print("-----")
            print(" ")
            print("Use 'python setup.py develop' from the top level of your project and you can begin testing your application with the executable, " + data_container.app_name)
            exit_success()
コード例 #2
0
ファイル: build.py プロジェクト: tstyle/doxx
 def unpack_and_get_keypath(self, project_path):
     # unpack the archive and get the root directory from the archive
     root_directory = unpack_run(project_path)
     
     if root_directory is None or root_directory == "":
         key_path = None
         try:
             for root, dirs, files in os.path.walk(cwd()):
                 for test_file in files:
                     if test_file == "project.yaml":
                         key_path = make_path(root, dirs, test_file)
         except Exception as e:
             stderr("[!] doxx: Unable to locate the 'project.yaml' project settings file in your unpacked archive. Error: " + str(e), exit=1)
             
         if key_path is None:  # can't find key path
             stderr("[!] doxx: Unable to locate the 'project.yaml' project settings file in your unpacked archive.", exit=1)
         else:
             return key_path  # return key path to the calling method
     else:
         if root_directory == ".":
             key_path = 'project.yaml'  # in current working directory
         else:
             # make the path to the key file
             root_directory = make_path(cwd(), root_directory)
             key_path = make_path(root_directory, 'project.yaml')
         # return the key path to the calling method
         return key_path
コード例 #3
0
    def test_escape_tar_encrypt(self):
        try:
            # change to the sub test directory for tar tests
            os.chdir("testdir11")
            command = "crypto --tar testtar"
            child = self.submit_same_esc_passphrase(command)
            self.assertTrue(file_exists("testtar.tar.crypt"))  # test new encrypted archive exists
            child.close()

            shutil.move('testtar', 'testtar_temp')

            decrypt_command = "decrypto testtar.tar.crypt"
            child = self.submit_same_esc_passphrase(decrypt_command)
            self.assertTrue(dir_exists(make_path("testtar")))  # test decrypted tar archive exists
            self.assertTrue(file_exists(make_path("testtar", "esc_test.txt")))
            self.assertTrue(file_exists(make_path("testtar", "esc_test2.txt")))
            child.close()

            # cleanup
            os.remove(make_path("testtar.tar.crypt"))  # remove encrypted archive
            shutil.rmtree(make_path("testtar"))        # remove the decrypted, unpacked directory
            shutil.move('testtar_temp', 'testtar')  # move the original tar testing dir back to original path
        except Exception as e:
            # return to top level testing directory
            os.chdir(self.cwd)
            raise e
        finally:
            # return to top level testing directory
            os.chdir(self.cwd)
コード例 #4
0
    def run(self):
        if self.app_name == None:
            i = InfoCompiler(None)
            data_container = i.getSetupFileInfo()
        else:
            i = InfoCompiler(self.app_name)
            data_container = i.getUserInfo()

        db = DirectoryBuilder(data_container)
        db.build()
        fb = FileBuilder(data_container)
        if fb.build_and_write():  # file writes were successful
            main_script_path = make_path(data_container.app_name, 'lib',
                                         data_container.app_name, 'app.py')
            settings_path = make_path(data_container.app_name, 'lib',
                                      data_container.app_name, 'settings.py')
            command_dir = make_path(data_container.app_name, 'lib',
                                    data_container.app_name, 'commands')
            setuppy_path = make_path(data_container.app_name, 'setup.py')
            print(" ")
            print(data_container.app_name + " was successfully built.")
            print(" ")
            print("-----")
            print("Main application script:  " + main_script_path)
            print("Settings file:  " + settings_path)
            print("Commands directory:  " + command_dir)
            print("setup.py file:  " + setuppy_path)
            print("-----")
            print(" ")
            print(
                "Use 'python setup.py develop' from the top level of your project and you can begin testing your application with the executable, "
                + data_container.app_name)
            exit_success()
コード例 #5
0
    def test_escape_tar_encrypt(self):
        try:
            # change to the sub test directory for tar tests
            os.chdir("testdir11")
            command = "crypto --tar testtar"
            child = self.submit_same_esc_passphrase(command)
            self.assertTrue(file_exists(
                "testtar.tar.crypt"))  # test new encrypted archive exists
            child.close()

            shutil.move('testtar', 'testtar_temp')

            decrypt_command = "decrypto testtar.tar.crypt"
            child = self.submit_same_esc_passphrase(decrypt_command)
            self.assertTrue(dir_exists(
                make_path("testtar")))  # test decrypted tar archive exists
            self.assertTrue(file_exists(make_path("testtar", "esc_test.txt")))
            self.assertTrue(file_exists(make_path("testtar", "esc_test2.txt")))
            child.close()

            # cleanup
            os.remove(
                make_path("testtar.tar.crypt"))  # remove encrypted archive
            shutil.rmtree(make_path(
                "testtar"))  # remove the decrypted, unpacked directory
            shutil.move(
                'testtar_temp', 'testtar'
            )  # move the original tar testing dir back to original path
        except Exception as e:
            # return to top level testing directory
            os.chdir(self.cwd)
            raise e
        finally:
            # return to top level testing directory
            os.chdir(self.cwd)
コード例 #6
0
ファイル: test_SYSTEM.py プロジェクト: chrisidefix/naked
	def setUp(self):
		self.sysfilepath = make_path("testfiles", "testdir", "systest.txt")
		self.sysdirpath = make_path("testfiles", "testdir")
		self.bogusfilepath = make_path("testfiles", "testdir", "bogusfile.text")
		self.metafilepath = make_path("testfiles", "keep", "metadata.txt")
		self.dir_file_path = make_path("testfiles", "keep")
		self.dir_file_list = ["file1.txt", "file2.txt", "file3.py", "metadata.txt", "test.tar.gz"]
		FileWriter(self.sysfilepath).write("test")
コード例 #7
0
    def test_decrypt_singlefile_ascfile(self):
        command = "decrypto testdir5/test3.txt.asc"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir5", "test3.txt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir5", "test3.txt"))
コード例 #8
0
    def test_decrypt_singlefile_ascfile(self):
        command = "decrypto testdir5/test3.txt.asc"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir5", "test3.txt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir5", "test3.txt"))
コード例 #9
0
ファイル: test_single-file.py プロジェクト: privacee/crypto
    def test_singlefile_encrypt_jpg(self):
        command = "crypto testdir1/tiger.jpg"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "tiger.jpg.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "tiger.jpg.crypt"))
コード例 #10
0
ファイル: test_single-file.py プロジェクト: privacee/crypto
    def test_singlefile_encrypt_gif(self):
        command = "crypto testdir1/banana.gif"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "banana.gif.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "banana.gif.crypt"))
コード例 #11
0
ファイル: test_single-file.py プロジェクト: privacee/crypto
    def test_singlefile_encrypt_dotfile(self):
        command = "crypto testdir1/.testfile"
        child = self.submit_same_passphrase(command)
        child.close()
        self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt")))

        # cleanup
        os.remove(make_path("testdir1", ".testfile.crypt"))
コード例 #12
0
    def test_unicode_passphrase_single_file_encrypt(self):
        command = "crypto testdir7/uni_test.txt"
        child = self.submit_same_uni_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir7", "uni_test.txt.crypt"))) #test that new encrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir7","uni_test.txt.crypt"))
コード例 #13
0
    def test_asciifile_encrypt_png(self):
        command = "crypto -a testdir1/star.png"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "star.png.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "star.png.crypt"))
コード例 #14
0
ファイル: test_ascii-armored.py プロジェクト: CamTosh/crypto
    def test_asciifile_encrypt_png(self):
        command = "crypto -a testdir1/star.png"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "star.png.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "star.png.crypt"))
コード例 #15
0
ファイル: test_single-file.py プロジェクト: privacee/crypto
    def test_singlefile_encrypt_txt(self):
        command = "crypto testdir1/test1.txt"
        child = self.submit_same_passphrase(command)
        #stdout_string = child.logfile.getvalue()
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) #test that new encrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir1","test1.txt.crypt"))
コード例 #16
0
    def test_multifile_goodbad_filepath(self):
        command = "crypto testdir1/test1.txt testdir1/bogusfile.txt"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt")))
        self.assertFalse(file_exists(make_path("testdir1", "bogusfile.txt.crypt"))) #should not be present when original does not exist
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "test1.txt.crypt"))
コード例 #17
0
    def build(self):
        top_level_dir = self.data_container.app_name
        second_level_dirs = ['docs', 'lib', 'tests']
        lib_subdir = make_path(self.data_container.app_name, 'commands')

        for xdir in second_level_dirs:
            make_dirs(make_path(top_level_dir, xdir))

        make_dirs(make_path(top_level_dir, 'lib', lib_subdir))
コード例 #18
0
ファイル: make.py プロジェクト: INAP-LABS/noc-orchestrator
    def build(self):
        top_level_dir = self.data_container.app_name
        second_level_dirs = ['docs', 'lib', 'tests']
        lib_subdir = make_path(self.data_container.app_name, 'commands')

        for xdir in second_level_dirs:
            make_dirs(make_path(top_level_dir, xdir))

        make_dirs(make_path(top_level_dir, 'lib', lib_subdir))
コード例 #19
0
    def test_asciifile_encrypt_multiple_files(self):
        command = "crypto --armor testdir1/.testfile testdir1/test1.txt"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt")))
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", ".testfile.crypt"))
        os.remove(make_path("testdir1", "test1.txt.crypt"))
コード例 #20
0
ファイル: test_ascii-armored.py プロジェクト: CamTosh/crypto
    def test_asciifile_encrypt_multiple_files(self):
        command = "crypto --armor testdir1/.testfile testdir1/test1.txt"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt")))
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", ".testfile.crypt"))
        os.remove(make_path("testdir1", "test1.txt.crypt"))
コード例 #21
0
    def test_multifile_encrypt_txt(self):
        command = "crypto testdir1/test1.txt testdir2/test1.txt"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) #test that new encrypted file exists
        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1","test1.txt.crypt"))
        os.remove(make_path("testdir2","test1.txt.crypt"))
コード例 #22
0
    def test_multifile_encrypt_image(self):
        command = "crypto testdir1/star.png testdir1/tiger.jpg"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "star.png.crypt")))
        self.assertTrue(file_exists(make_path("testdir1", "tiger.jpg.crypt")))
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "star.png.crypt"))
        os.remove(make_path("testdir1", "tiger.jpg.crypt"))
コード例 #23
0
    def test_multifile_encrypt_withdotfile(self):
        command = "crypto testdir1/test1.txt testdir1/.testfile"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt"))) #should encrypt an explicitly included dotfile
        child.close()

        # cleanup
        os.remove(make_path("testdir1", "test1.txt.crypt"))
        os.remove(make_path("testdir1", ".testfile.crypt"))
コード例 #24
0
    def test_singledir_file_encrypt(self):
        command = "crypto testdir2"
        child = self.submit_same_passphrase(command)
        child.close()
        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))
        self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt")))

        os.remove(make_path("testdir2","test1.txt.crypt"))
        os.remove(make_path("testdir2","test2.txt.crypt"))
コード例 #25
0
 def test_decrypt_singlegpgfile_overwrite_shortflag(self):
     command = "decrypto -o testdir6/test2.txt.gpg"
     child = pexpect.spawn(command)
     child.expect("Please enter your passphrase: ")
     child.sendline("test")
     child.expect("Please enter your passphrase again: ")
     child.sendline("test")
     child.expect("'testdir6/test2.txt.gpg' decrypted to 'testdir6/test2.txt'")
     child.close()
     self.assertTrue(file_exists(make_path("testdir6", "test2.txt"))) # confirm decrypted file present
     self.assertFalse(file_exists(make_path("testdir6", "test2.txt.tmp"))) # confirm tmp file erased
コード例 #26
0
    def test_multifile_encrypt_withencryptedfile(self):
        command = "crypto testdir2/test1.txt testdir2/test2.txt testdir2/testcrypt.txt.crypt"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))
        self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))) # assert that did not encrypt previously encrypted file
        child.close()

        # cleanup
        os.remove(make_path("testdir2", "test1.txt.crypt"))
        os.remove(make_path("testdir2", "test2.txt.crypt"))
コード例 #27
0
    def test_unicode_passphrase_single_file_encrypt(self):
        command = "crypto testdir7/uni_test.txt"
        child = self.submit_same_uni_passphrase(command)
        self.assertTrue(
            file_exists(make_path(
                "testdir7",
                "uni_test.txt.crypt")))  #test that new encrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir7", "uni_test.txt.crypt"))
コード例 #28
0
 def setUp(self):
     self.sysfilepath = make_path("testfiles", "testdir", "systest.txt")
     self.sysdirpath = make_path("testfiles", "testdir")
     self.bogusfilepath = make_path("testfiles", "testdir",
                                    "bogusfile.text")
     self.metafilepath = make_path("testfiles", "keep", "metadata.txt")
     self.dir_file_path = make_path("testfiles", "keep")
     self.dir_file_list = [
         "file1.txt", "file2.txt", "file3.py", "metadata.txt", "test.tar.gz"
     ]
     FileWriter(self.sysfilepath).write("test")
コード例 #29
0
    def test_multidir_bad_single_dir_path(self):
        command = "crypto bogusdir1 testdir2"
        child = self.submit_same_passphrase(command)

        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))

        self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt")))

        # cleanup
        os.remove(make_path("testdir2","test1.txt.crypt"))
        os.remove(make_path("testdir2","test2.txt.crypt"))
コード例 #30
0
 def test_decrypt_singlefile_nosuffix(self):
     command = "decrypto testdir5/test5"
     child = pexpect.spawn(command)
     child.expect("Could not confirm that the requested file is encrypted based upon the file type.  Attempting decryption.  Keep your fingers crossed...")
     child.expect("Please enter your passphrase: ")
     child.sendline("test")
     child.expect("Please enter your passphrase again: ")
     child.sendline("test")
     child.interact()
     self.assertTrue(file_exists(make_path("testdir5", "test5.decrypt")))
     child.close()
     # cleanup
     os.remove(make_path("testdir5", "test5.decrypt"))
コード例 #31
0
    def test_asciifile_single_directory(self):
        command = "crypto --armor testdir2"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))
        self.assertFalse(
            file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))
        )  # test that did not encrypt previously encrypted file
        child.close()

        # cleanup
        os.remove(make_path("testdir2", "test1.txt.crypt"))
        os.remove(make_path("testdir2", "test2.txt.crypt"))
コード例 #32
0
    def test_multidir_bad_single_dir_path(self):
        command = "crypto bogusdir1 testdir2"
        child = self.submit_same_passphrase(command)

        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))

        self.assertFalse(
            file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt")))

        # cleanup
        os.remove(make_path("testdir2", "test1.txt.crypt"))
        os.remove(make_path("testdir2", "test2.txt.crypt"))
コード例 #33
0
ファイル: test_ascii-armored.py プロジェクト: CamTosh/crypto
    def test_asciifile_single_directory(self):
        command = "crypto --armor testdir2"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt")))
        self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt")))
        self.assertFalse(
            file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))
        )  # test that did not encrypt previously encrypted file
        child.close()

        # cleanup
        os.remove(make_path("testdir2", "test1.txt.crypt"))
        os.remove(make_path("testdir2", "test2.txt.crypt"))
コード例 #34
0
    def test_escape_passphrase_with_unicode_chars_and_spaces(self):
        command = "crypto testdir11/esc_test.txt"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ")
        child.expect("Please enter your passphrase again: ")
        child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ")
        child.interact()
        self.assertTrue(file_exists(make_path("testdir11", "esc_test.txt.crypt")))  # test new encrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir11", "esc_test.txt.crypt"))
コード例 #35
0
    def test_decrypt_multifile_bad_filepath(self):
        command = "decrypto testdir5/bogusfile.txt.crypt testdir5/test1.txt.crypt"
        child = pexpect.spawn(command)
        child.expect("'testdir5/bogusfile.txt.crypt' does not appear to be an existing file or directory.  Aborting decryption attempt for this request.")
        child.expect("Please enter your passphrase: ")
        child.sendline("test")
        child.expect("Please enter your passphrase again: ")
        child.sendline("test")
        child.interact()
        child.close()
        self.assertTrue(file_exists(make_path("testdir5", "test1.txt")))

        # cleanup
        os.remove(make_path("testdir5", "test1.txt"))
コード例 #36
0
    def test_escape_directory_encrypt_decrypt(self):
        command = "crypto testdir11"
        child = self.submit_same_esc_passphrase(command)
        self.assertTrue(
            file_exists(make_path(
                "testdir11",
                "esc_test.txt.crypt")))  # test new encrypted file exists
        self.assertTrue(
            file_exists(make_path(
                "testdir11",
                "esc_test2.txt.crypt")))  # test new encrypted file exists
        child.close()

        os.rename("testdir11/esc_test.txt.crypt",
                  "testdir11/SUBTEST1.txt.crypt")
        os.rename("testdir11/esc_test2.txt.crypt",
                  "testdir11/SUBTEST2.txt.crypt")

        decrypt_command = "decrypto testdir11"
        child = self.submit_same_esc_passphrase(decrypt_command)
        self.assertTrue(file_exists(make_path(
            "testdir11", "SUBTEST1.txt")))  # test decrypted file exists
        self.assertTrue(file_exists(make_path(
            "testdir11", "SUBTEST2.txt")))  # test decrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir11", "SUBTEST1.txt"))
        os.remove(make_path("testdir11", "SUBTEST1.txt.crypt"))
        os.remove(make_path("testdir11", "SUBTEST2.txt"))
        os.remove(make_path("testdir11", "SUBTEST2.txt.crypt"))
コード例 #37
0
 def test_decrypt_singlegpgfile_overwrite_shortflag(self):
     command = "decrypto -o testdir6/test2.txt.gpg"
     child = pexpect.spawn(command)
     child.expect("Please enter your passphrase: ")
     child.sendline("test")
     child.expect("Please enter your passphrase again: ")
     child.sendline("test")
     child.expect(
         "'testdir6/test2.txt.gpg' decrypted to 'testdir6/test2.txt'")
     child.close()
     self.assertTrue(file_exists(make_path(
         "testdir6", "test2.txt")))  # confirm decrypted file present
     self.assertFalse(file_exists(make_path(
         "testdir6", "test2.txt.tmp")))  # confirm tmp file erased
コード例 #38
0
 def setUp(self):
     self.template_path = make_path("testfiles", "keep", "inktests",
                                    "test_setup_template.py")
     self.template_path2 = make_path("testfiles", "keep", "inktests",
                                     "test_setup_template2.py")
     self.standard_path = make_path("testfiles", "keep", "inktests",
                                    "test_setup_standard.py")
     self.key_dictionary = {
         'appname': 'test',
         'description': 'A cool app',
         'url': 'http://test.com',
         'license': 'MIT',
         'author': 'Christopher Simpkins',
         'email': '*****@*****.**'
     }
コード例 #39
0
    def test_decrypt_multifile_overwrite_file(self):
        command = "decrypto testdir5/test1.txt.crypt testdir6/test1.txt.crypt"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("test")
        child.expect("Please enter your passphrase again: ")
        child.sendline("test")
        child.expect("The file path 'testdir6/test1.txt' already exists.  This file was not decrypted")
        child.close()
        self.assertTrue(file_exists(make_path("testdir5", "test1.txt")))
        self.assertTrue(file_exists(make_path("testdir6", "test1.txt")))
        self.assertFalse(file_exists(make_path("testdir6", "test1.txt.tmp"))) # confirm that there is no .tmp file

        #cleanup
        os.remove(make_path("testdir5", "test1.txt"))
コード例 #40
0
    def test_decrypt_multifile_overwrite_shortflag(self):
        command = "decrypto -o testdir5/test1.txt.crypt testdir6/test1.txt.crypt"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("test")
        child.expect("Please enter your passphrase again: ")
        child.sendline("test")
        child.interact()
        child.close()
        self.assertTrue(file_exists(make_path("testdir5", "test1.txt")))
        self.assertTrue(file_exists(make_path("testdir6", "test1.txt")))
        self.assertFalse(file_exists(make_path("testdir6", "test1.txt.tmp"))) # confirm that there is no .tmp file

        #cleanup
        os.remove(make_path("testdir5", "test1.txt"))
コード例 #41
0
 def test_decrypt_singlefile_nosuffix(self):
     command = "decrypto testdir5/test5"
     child = pexpect.spawn(command)
     child.expect(
         "Could not confirm that the requested file is encrypted based upon the file type.  Attempting decryption.  Keep your fingers crossed..."
     )
     child.expect("Please enter your passphrase: ")
     child.sendline("test")
     child.expect("Please enter your passphrase again: ")
     child.sendline("test")
     child.interact()
     self.assertTrue(file_exists(make_path("testdir5", "test5.decrypt")))
     child.close()
     # cleanup
     os.remove(make_path("testdir5", "test5.decrypt"))
コード例 #42
0
    def test_escape_passphrase_with_unicode_chars_and_spaces(self):
        command = "crypto testdir11/esc_test.txt"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ")
        child.expect("Please enter your passphrase again: ")
        child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ")
        child.interact()
        self.assertTrue(
            file_exists(make_path(
                "testdir11",
                "esc_test.txt.crypt")))  # test new encrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir11", "esc_test.txt.crypt"))
コード例 #43
0
    def test_escape_passphrase_single_file_encrypt_decrypt(self):
        command = "crypto testdir11/esc_test.txt"
        child = self.submit_same_esc_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir11", "esc_test.txt.crypt")))  # test new encrypted file exists
        child.close()

        os.rename("testdir11/esc_test.txt.crypt", "testdir11/SUBTEST.txt.crypt")

        decrypt_command = "decrypto testdir11/SUBTEST.txt.crypt"
        child = self.submit_same_esc_passphrase(decrypt_command)
        self.assertTrue(file_exists(make_path("testdir11", "SUBTEST.txt")))  # test decrypted file exists
        child.close()

        # cleanup
        os.remove(make_path("testdir11", "SUBTEST.txt"))
        os.remove(make_path("testdir11", "SUBTEST.txt.crypt"))
コード例 #44
0
    def test_decrypt_singledir_multiplefiles(self):
        command = "decrypto testdir5"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("test")
        child.expect("Please enter your passphrase again: ")
        child.sendline("test")
        child.expect(
            "'testdir5/test1.txt.crypt' decrypted to 'testdir5/test1.txt'")
        child.expect(
            "'testdir5/test2.txt.gpg' decrypted to 'testdir5/test2.txt'")
        child.expect(
            "'testdir5/test3.txt.asc' decrypted to 'testdir5/test3.txt'")
        child.expect(
            "The file path 'testdir5/test4.txt' already exists.  This file was not decrypted."
        )
        child.interact()
        self.assertTrue(file_exists(make_path("testdir5", "test1.txt")))
        self.assertTrue(file_exists(make_path("testdir5", "test2.txt")))
        self.assertTrue(file_exists(make_path("testdir5", "test3.txt")))
        self.assertFalse(file_exists(make_path(
            "testdir5", "test5.decrypt")))  # should not decrypt this file
        child.close()

        #cleanup
        os.remove(make_path("testdir5", "test1.txt"))
        os.remove(make_path("testdir5", "test2.txt"))
        os.remove(make_path("testdir5", "test3.txt"))
コード例 #45
0
    def test_crypto_tar_commandline_tararchive(self):
        command = "crypto --tar testdir9/tar_dir"
        child = pexpect.spawn(command)
        child.expect("Please enter your passphrase: ")
        child.sendline("test")
        child.expect("Please enter your passphrase again: ")
        child.sendline("test")
        child.expect(
            "\r\ntestdir9/tar_dir.tar.crypt was generated from testdir9/tar_dir.tar\r\n"
        )
        self.assertTrue(file_exists(make_path('testdir9', 'tar_dir.tar.crypt'))
                        )  # confirm that the encrypted tar file is there
        self.assertFalse(file_exists(
            make_path('testdir9',
                      'tar_dir.tar')))  # confirm that the tar file is removed
        self.assertTrue(dir_exists(make_path(
            'testdir9',
            'tar_dir')))  # confirm that the test directory is not removed
        child.close()

        os.remove('testdir9/tar_dir.tar.crypt')
コード例 #46
0
    def test_decrypt_multifile_same_directory(self):
        command = "decrypto testdir5/test1.txt.crypt testdir5/test2.txt.gpg testdir5/test3.txt.asc"
        child = self.submit_same_passphrase(command)
        self.assertTrue(file_exists(make_path("testdir5", "test1.txt")))
        self.assertTrue(file_exists(make_path("testdir5", "test2.txt")))
        self.assertTrue(file_exists(make_path("testdir5", "test3.txt")))

        child.close()

        #cleanup
        os.remove(make_path("testdir5", "test1.txt"))
        os.remove(make_path("testdir5", "test2.txt"))
        os.remove(make_path("testdir5", "test3.txt"))
コード例 #47
0
ファイル: clean.py プロジェクト: tstyle/doxx
def _remove_doxt():
    # check main directory
    cwd_doxt_list = list_filter_files_cwd(".doxt")
    
    # check for a templates directory
    if dir_exists('templates'):
        templates_dir_doxt_list = list_filter_files(".doxt", "templates")
    else:
        templates_dir_doxt_list = []
    
    # remove template files from the working directory
    if len(cwd_doxt_list) > 0:
        for doxt_file in cwd_doxt_list:
            try:
                remove(doxt_file)
                stdout("[-] doxx: -- " + doxt_file + " ... removed")
            except Exception as e:
                stderr("[!] doxx: Unable to remove the file " + doxt_file + "'. Error: " + str(e), exit=0)
    
    # remove any template files from the templates directory
    if len(templates_dir_doxt_list) > 0:
        for doxt_file in templates_dir_doxt_list:
            new_doxt_path = make_path('templates', doxt_file)
            remove(new_doxt_path)
            stdout("[-] doxx: -- " + new_doxt_path + " ... removed")
            
    # if there are files still remaining in the templates directory, leave it
    # otherwise, remove the templates directory as well
    if dir_exists('templates'):
        remaining_template_file_list = list_all_files('templates')  # get the remaining non-.doxt files in the directory
        if len(remaining_template_file_list) > 0:
            pass  # do nothing, skip the removal of the 'templates' directory from the project because other files are present in it
        else:
            try:
                rmtree('templates')
                stdout("[-] doxx: -- templates (directory) ... removed")
            except Exception as e:
                stderr("[!] doxx: Unable to remove the 'templates' directory.  Error: " + str(e), exit=1)