def test_encrypt_archive_with_custom_gpg_key(self):
        # Create the YAML configuration file
        self._create_config_yaml_file()
        self.to_delete_files.append(SUBMIT_DEBUG_YAML_FILE)

        # Load the submit debug info yaml file
        st2debug.cmd.submit_debug_info.load_config_yaml_file(
            SUBMIT_DEBUG_YAML_FILE)

        plaintext_archive_path = create_archive(
            include_logs=True,
            include_configs=True,
            include_content=True,
            include_system_info=True,
            include_shell_commands=True,
            config_yaml=SUBMIT_DEBUG_YAML_FILE)

        plaintext_archive_size = os.stat(plaintext_archive_path).st_size

        encrypted_archive_path = encrypt_archive(
            archive_file_path=plaintext_archive_path)
        encrypt_archive_size = os.stat(encrypted_archive_path).st_size

        self.assertTrue(os.path.isfile(encrypted_archive_path))
        self.assertTrue(encrypt_archive_size > plaintext_archive_size)

        self.assertRaises(Exception,
                          archive_path=encrypted_archive_path,
                          extract_path='/tmp')
    def test_encrypt_archive(self):
        plaintext_archive_path = create_archive(include_logs=True, include_configs=True,
                                                include_content=True,
                                                include_system_info=True)
        plaintext_archive_size = os.stat(plaintext_archive_path).st_size

        encrypted_archive_path = encrypt_archive(archive_file_path=plaintext_archive_path)
        encrypt_archive_size = os.stat(encrypted_archive_path).st_size

        self.assertTrue(os.path.isfile(encrypted_archive_path))
        self.assertTrue(encrypt_archive_size > plaintext_archive_size)

        self.assertRaises(Exception, archive_path=encrypted_archive_path,
                          extract_path='/tmp')
    def test_encrypt_archive(self):
        plaintext_archive_path = create_archive(include_logs=True, include_configs=True,
                                                include_content=True,
                                                include_system_info=True)
        plaintext_archive_size = os.stat(plaintext_archive_path).st_size

        encrypted_archive_path = encrypt_archive(archive_file_path=plaintext_archive_path)
        encrypt_archive_size = os.stat(encrypted_archive_path).st_size

        self.assertTrue(os.path.isfile(encrypted_archive_path))
        self.assertTrue(encrypt_archive_size > plaintext_archive_size)

        self.assertRaises(Exception, archive_path=encrypted_archive_path,
                          extract_path='/tmp')
    def test_encrypt_archive_with_custom_gpg_key(self):
        # Create the YAML configuration file
        self._create_config_yaml_file()
        self.to_delete_files.append(SUBMIT_DEBUG_YAML_FILE)

        # Load the submit debug info yaml file
        st2debug.cmd.submit_debug_info.load_config_yaml_file(SUBMIT_DEBUG_YAML_FILE)

        plaintext_archive_path = create_archive(include_logs=True, include_configs=True,
                                                include_content=True,
                                                include_system_info=True,
                                                include_shell_commands=True,
                                                config_yaml=SUBMIT_DEBUG_YAML_FILE)

        plaintext_archive_size = os.stat(plaintext_archive_path).st_size

        encrypted_archive_path = encrypt_archive(archive_file_path=plaintext_archive_path)
        encrypt_archive_size = os.stat(encrypted_archive_path).st_size

        self.assertTrue(os.path.isfile(encrypted_archive_path))
        self.assertTrue(encrypt_archive_size > plaintext_archive_size)

        self.assertRaises(Exception, archive_path=encrypted_archive_path,
                          extract_path='/tmp')