From 575a8e3894e115acc19fb7d5a356e6db9745b864 Mon Sep 17 00:00:00 2001 From: Daniel Martin Date: Fri, 4 Jul 2014 14:11:41 +0200 Subject: [PATCH] Remove ProjectManagement plugin from main repo The new gemified plugin is available here: https://github.com/dradis/dradis-projects --- Gemfile | 7 +- vendor/plugins/project_management/Guardfile | 8 - vendor/plugins/project_management/README | 28 ---- vendor/plugins/project_management/Rakefile | 22 --- vendor/plugins/project_management/init.rb | 3 - vendor/plugins/project_management/install.rb | 0 .../lib/project_management.rb | 28 ---- .../lib/project_management/actions.rb | 54 ------- .../export/meta_server_processor.rb | 61 -------- .../project_management/export/processor.rb | 63 -------- .../lib/project_management/meta.rb | 28 ---- .../lib/project_management/upload/package.rb | 54 ------- .../lib/project_management/upload/template.rb | 125 --------------- .../project_management/lib/tasks/thorfile.rb | 140 ----------------- .../spec/fixtures/files/no_positions.xml | 138 ---------------- .../spec/fixtures/files/with_positions.xml | 147 ------------------ .../spec/project_management_spec.rb | 33 ---- .../project_management/spec/spec_helper.rb | 19 --- .../plugins/project_management/uninstall.rb | 0 19 files changed, 3 insertions(+), 955 deletions(-) delete mode 100644 vendor/plugins/project_management/Guardfile delete mode 100644 vendor/plugins/project_management/README delete mode 100644 vendor/plugins/project_management/Rakefile delete mode 100644 vendor/plugins/project_management/init.rb delete mode 100644 vendor/plugins/project_management/install.rb delete mode 100644 vendor/plugins/project_management/lib/project_management.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/actions.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/export/meta_server_processor.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/export/processor.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/meta.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/upload/package.rb delete mode 100644 vendor/plugins/project_management/lib/project_management/upload/template.rb delete mode 100644 vendor/plugins/project_management/lib/tasks/thorfile.rb delete mode 100644 vendor/plugins/project_management/spec/fixtures/files/no_positions.xml delete mode 100644 vendor/plugins/project_management/spec/fixtures/files/with_positions.xml delete mode 100644 vendor/plugins/project_management/spec/project_management_spec.rb delete mode 100644 vendor/plugins/project_management/spec/spec_helper.rb delete mode 100644 vendor/plugins/project_management/uninstall.rb diff --git a/Gemfile b/Gemfile index b350fc49..a259973e 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'coffee-rails', '~> 4.0.0' # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library -gem 'jquery-rails' +#gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder @@ -45,8 +45,8 @@ gemspec path: 'engines/frontend' # Dradis::Plugins manage the list of available / loaded external plugins gem 'dradis-plugins', path: '../dradis-plugins' - - +# Dradis::Plugins::Projects lets you backup and restore the repo state +gem 'dradis-projects', path: '../dradis-projects' # In Production we need to be able to compile assets @@ -54,7 +54,6 @@ gem 'dradis-plugins', path: '../dradis-plugins' # gem 'therubyracer' # ------------------------------------------------------------------ Asset gems -gem 'jquery-fileupload-rails' # ------------------------------------------------------------------ Other gems diff --git a/vendor/plugins/project_management/Guardfile b/vendor/plugins/project_management/Guardfile deleted file mode 100644 index d7a4d715..00000000 --- a/vendor/plugins/project_management/Guardfile +++ /dev/null @@ -1,8 +0,0 @@ -# A sample Guardfile -# More info at https://github.com/guard/guard#readme - -guard 'rspec', :version => 2 do - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { "spec" } -end \ No newline at end of file diff --git a/vendor/plugins/project_management/README b/vendor/plugins/project_management/README deleted file mode 100644 index 93af5b37..00000000 --- a/vendor/plugins/project_management/README +++ /dev/null @@ -1,28 +0,0 @@ -ProjectManagement -================= - -This plugin belongs to the export / upload category. It provides functionality -to export the current contents of the dradis repository into a package that -can be downloaded and stored as a backup. - -It also provides a 'hook' to the import from file functionality in order to -restore the state of dradis from one of these packages. - -This version will preserve category associations of notes, whilst preventing -duplicate categories from being created. - -This plugin will work with any database supported by Rails' ActiveResource data -access layer. - - -License -======= -Released under the terms of the GNU General Public License version 2.0 as -published by the Free Software Foundation and appearing in the file LICENSE -included in the packaging of this file. - - -Acknowledgements -================ -The original implementation of this plugin was contributed by Daniel Bradberry -from MWR Infosecurity in July 2009. diff --git a/vendor/plugins/project_management/Rakefile b/vendor/plugins/project_management/Rakefile deleted file mode 100644 index d9be1dc4..00000000 --- a/vendor/plugins/project_management/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the project_export plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the project_export plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ProjectExport' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/project_management/init.rb b/vendor/plugins/project_management/init.rb deleted file mode 100644 index 8f95c993..00000000 --- a/vendor/plugins/project_management/init.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Include hook code here - -require 'project_management' diff --git a/vendor/plugins/project_management/install.rb b/vendor/plugins/project_management/install.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/plugins/project_management/lib/project_management.rb b/vendor/plugins/project_management/lib/project_management.rb deleted file mode 100644 index cae62fe5..00000000 --- a/vendor/plugins/project_management/lib/project_management.rb +++ /dev/null @@ -1,28 +0,0 @@ -# ProjectManagement - -require 'project_management/export/processor' -require 'project_management/export/meta_server_processor' -require 'project_management/actions' -require 'project_management/upload/template' -require 'project_management/upload/package' -require 'project_management/meta' - -module ProjectManagement - class Configuration < Core::Configurator - configure :namespace => 'project' - setting :ms_host, :default => 'localhost' - setting :ms_port, :default => 3000 - setting :ms_user, :default => 'etd' - setting :ms_password, :default => 'etd001' - end -end - -module Plugins - module Export - include ProjectExport - end - module Upload - include ProjectTemplateUpload - include ProjectPackageUpload - end -end diff --git a/vendor/plugins/project_management/lib/project_management/actions.rb b/vendor/plugins/project_management/lib/project_management/actions.rb deleted file mode 100644 index 5f2a219d..00000000 --- a/vendor/plugins/project_management/lib/project_management/actions.rb +++ /dev/null @@ -1,54 +0,0 @@ -# ProjectExport module of the plugin defines two actions: -# -# = as_template: downloads a copy of the internal database for storage, it -# dumps the contents of the DB into an XML file. -# = full_project: exports the database (see as_template) and attachments for -# each node. These are presented to the user as 'dradis_YYYY-MM-dd.zip'. -# -# This plugin theoretically supports any database backend supported by Active -# Record. It is most efficient when utilising an SQLite database. -module ProjectExport - module Actions - - # This Export menu entry will send a Zip file containing both the contents - # of the repository and any attachments that have been uploaded into the - # current project - def full_project - filename = Rails.root.join('tmp', 'dradis-export.zip') - - project = Processor.full_project( :filename => filename) - send_file( filename ) - - # FIXME: the zip file is left in the tmp/ directory - end - - # This entry will create an XML file containing all the information held in - # the repository: categories, nodes and notes. - # This can be used, for instance, to create 'methodologies' a series of - # notes and nodes that you can re-use every time you have to perform a - # certain task (e.g. 'web application' test) - def as_template - template = Processor.db_only - send_data( template , :filename => 'dradis-template.xml', :type => :xml ) - end - - - # Pack the current project( using Processor.full_project) and send it to - # the Meta-Server either as a new Project or a new Revision of an old - # project depending on how this project was started (see SessionController#setup). - def metaserver_commit - #TODO: Should we consider restricting this to requests from 'localhost'? - # At the end of the day this will use the settings from configuration manager - # to submit the project. The file would contain the credentials of the - # dradis server owner - begin - MetaServerProcessor.commit - flash[:notice] = 'Project successfully sent to the Meta-Server' - rescue Exception => e - flash[:error] = e.message - flash[:error] << ". Verify your connection settings" - end - redirect_to root_path - end - end -end diff --git a/vendor/plugins/project_management/lib/project_management/export/meta_server_processor.rb b/vendor/plugins/project_management/lib/project_management/export/meta_server_processor.rb deleted file mode 100644 index f5ba9121..00000000 --- a/vendor/plugins/project_management/lib/project_management/export/meta_server_processor.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'zip/zip' - -module ProjectExport - # The MetaProcessor class does the heavy-lifting of the export - # functionalities that commit a project to the Meta-Server. - class MetaServerProcessor - private - def self.find_project(title, logger) - project = nil - mode = Configuration.find_by_name('mode') - if (mode.value == 'new') - logger.debug{ 'Creating new project...' } - project = Project.new( :title => title ) - project.save - logger.debug{ 'done.' } - - # As soon as we successfully create a new project we update the local - # configuration to ensure that we keep a reference to that project. - # This is to prevent multiple "NewProject_xx-yy-zz" from being created - # if something fails during the commit process. - mode.update_attribute(:value, 'meta-server') - Configuration.new(:name => 'project', :value => project.attributes['id'] ) - else - logger.debug{ 'This project was checked out from a Meta-Server. Locating... ' } - project = Project.find( Configuration.find_by_name('project').value.to_i ) - logger.debug{ 'done.' } - end - - return project - end - - public - - def self.commit(params={}) - logger = params.fetch(:logger, Rails.logger) - title = params.fetch(:title, "NewProject_#{DateTime.now.strftime('%Y-%m-%d')}") - - # Step 1: Find the right Project to commit a new Revision to - Project.site_from_metaserver(MetaServer.new(:host => ProjectManagement::Configuration.ms_host, - :port => ProjectManagement::Configuration.ms_port, - :user => ProjectManagement::Configuration.ms_user, - :password => ProjectManagement::Configuration.ms_password)) - project = find_project(title, logger) - logger.info{ "Project tile is: #{project.attributes['title']}" } - - # Step 2: create the project package in ./tmp/ and Base64 encode it - logger.debug{ 'Preparing project package...' } - filename = Rails.root.join('tmp', 'dradis-export.zip') - Processor.full_project( :filename => filename) - contents = Base64::encode64( File.read( filename ) ) - File.delete( filename ) - logger.debug{ 'Done' } - - # Step 3: send it over to the Meta-Server - logger.debug{ 'Adding new revision...' } - project.post( :add_revision, {}, {:package => contents}.to_xml(:root => 'revision') ) - logger.debug{ 'Done' } - - end - end # /MetaServerProcessor -end diff --git a/vendor/plugins/project_management/lib/project_management/export/processor.rb b/vendor/plugins/project_management/lib/project_management/export/processor.rb deleted file mode 100644 index 3edfd9af..00000000 --- a/vendor/plugins/project_management/lib/project_management/export/processor.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'rexml/document' -require 'zip/zip' - -module ProjectExport - # The Processor class does the heavy-lifting of the export functionalities - # provided by the ProjectManagement plugin. - # The different Actions defined in this module will in turn call methods in - # the Processor class to implement the requested operations - class Processor - private - public - # This method returns an XML representation of current repository which - # includes Categories, Nodes and Notes - def self.db_only(params={}) - nodes = Node.find(:all).to_xml(:include => :notes) - categories = Category.find(:all).to_xml - - template = REXML::Document.new - template.add( REXML::Element.new('dradis-template') ) - xml_nodes = REXML::Document.new( nodes ) - xml_categories = REXML::Document.new( categories ) - - template.root.add_element( xml_nodes.root ) - template.root.add_element( xml_categories.root ) - - template << REXML::XMLDecl.new( '1.0', 'UTF-8') - template.write(out='') - #template.write( out='', 2 ) - - return out - end - - # Create a new project export bundle. It will include an XML file with the - # contents of the repository (see db_only) and all the attachments that - # have been uploaded into the system. - def self.full_project(params={}) - raise ":filename not provided" unless params.key?(:filename) - - filename = params[:filename] - logger = params.fetch(:logger, Rails.logger) - - File.delete(filename) if File.exists?(filename) - - logger.debug{ "Creating a new Zip file in #{filename}..." } - Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) { |zipfile| - Node.find(:all).each do |node| - node_path = File.join('attachments', "#{node.id}") - - Dir["#{node_path}/**/**"].each do |file| - logger.debug{ "\tAdding attachment for '#{node.label}': #{file}" } - zipfile.add(file.sub('attachments/', ''), file) - end - end - - logger.debug{ "\tAdding XML repository dump" } - zipfile.get_output_stream('dradis-repository.xml') { |out| - out << db_only() - } - } - logger.debug{ 'Done.' } - end - end -end diff --git a/vendor/plugins/project_management/lib/project_management/meta.rb b/vendor/plugins/project_management/lib/project_management/meta.rb deleted file mode 100644 index 2f9f8422..00000000 --- a/vendor/plugins/project_management/lib/project_management/meta.rb +++ /dev/null @@ -1,28 +0,0 @@ -module ProjectPackageUpload - module Meta - NAME = "Project package upload" - EXPECTS = "A Dradis project archive (.zip) generated through Export > Project export > Full project" - # change this to the appropriate version - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 8 - TINY = 0 - - STRING = [MAJOR, MINOR, TINY].join('.') - end - end -end -module ProjectTemplateUpload - module Meta - NAME = "Project template upload" - EXPECTS = "A Dradis template XML file generated through Export > Project export > As template" - # change this to the appropriate version - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 8 - TINY = 0 - - STRING = [MAJOR, MINOR, TINY].join('.') - end - end -end diff --git a/vendor/plugins/project_management/lib/project_management/upload/package.rb b/vendor/plugins/project_management/lib/project_management/upload/package.rb deleted file mode 100644 index 6d41bfce..00000000 --- a/vendor/plugins/project_management/lib/project_management/upload/package.rb +++ /dev/null @@ -1,54 +0,0 @@ -# In this module you will find the implementation details that enable you to -# upload a project archive (generated using ProjectExport::Processor::full_project) -module ProjectPackageUpload - def self.import(params={}) - logger = params.fetch(:logger, Rails.logger) - - package = params[:file] - success = false - - # Unpack the archive in a temporary location - FileUtils.mkdir Rails.root.join('tmp', 'zip') - - begin - logger.info{ 'Uncompressing the file' } - #TODO: this could be improved by only uncompressing the XML, then parsing - # it to get the node_lookup table and then uncompressing each entry to its - # final destination - Zip::ZipFile.foreach(package) { |entry| - path = Rails.root.join('tmp', 'zip', entry.name) - FileUtils.mkdir_p(File.dirname(path)) - entry.extract(path) - logger.info{ "\t#{entry.name}" } - } - logger.info{ 'Done.' } - - logger.info{ 'Loading XML state file' } - node_lookup = ProjectTemplateUpload.import( - :logger => logger, - :file => Rails.root.join('tmp', 'zip', 'dradis-repository.xml') - ) - - logger.info{ 'Moving attachments to their final destinations' } - node_lookup.each do |oldid,newid| - if File.directory?( Rails.root.join('tmp', 'zip', oldid) ) - FileUtils.mkdir_p( Rails.root.join('attachments', newid.to_s) ) - - Dir.glob(Rails.root.join('tmp', 'zip', oldid, '*')).each do |attachment| - FileUtils.mv( attachment, Rails.root.join('attachments', newid.to_s) ) - end - end - end - - success = true - rescue Exception => e - logger.error{ e.message } - success = false - ensure - # clean up the temporary files - FileUtils.rm_rf( Rails.root.join('tmp', 'zip') ) - end - - return success - end -end diff --git a/vendor/plugins/project_management/lib/project_management/upload/template.rb b/vendor/plugins/project_management/lib/project_management/upload/template.rb deleted file mode 100644 index 7fc11785..00000000 --- a/vendor/plugins/project_management/lib/project_management/upload/template.rb +++ /dev/null @@ -1,125 +0,0 @@ -module ProjectTemplateUpload - - # The import method is invoked by the framework to process a template file - # that has just been uploaded using the 'Import from file...' dialog. - # - # This module will take the XMl export file created with the ProjectExport - # module and dump the contents into the current database. - # - # Since we cannot ensure that the original node and category IDs as specified - # in the XML are free in this database, we need to keep a few lookup tables - # to maintain the original structure of Nodes and the Notes pointing to the - # right nodes and categories. - # - # This method also returns the Node lookup table so callers can understand - # what changes to the original IDs have been applied. This is mainly for the - # benefit of the ProjectPackageUpload module that would use the translation - # table to re-associate the attachments in the project archive with the new - # node IDs in the current project. - def self.import(params={}) - logger = params.fetch(:logger, Rails.logger) - - # load the template - logger.info{ "Loading template file from: #{params[:file]}" } - template = REXML::Document.new( File.read( params[:file] ) ) - - # we need this to be able to convert from old category_id to the new - # category_id once the categories are added to the DB (the ID may have - # changed) - category_lookup = {} - # the same applies to Nodes (think parent_id) - node_lookup = {} - # all children nodes, we will need to find the new ID of their parents - orphan_nodes = [] - - # go through the categories, keep a translation table between the old - # category id and the new ones so we know to which category we should - # assign our notes - template.elements.each('dradis-template/categories/category') do |xml_category| - old_id = xml_category.elements['id'].text.strip - name = xml_category.elements['name'].text.strip - category = nil - - # Prevent creating duplicate categories - logger.info{ "Looking for category: #{name}" } - if (category = Category.find_by_name(name)).nil? - category = Category.create :name => name - end - - category_lookup[old_id] = category.id - end - - # Re generate the Node tree structure - template.elements.each('dradis-template/nodes/node') do |xml_node| - element = xml_node.elements['type-id'] - type_id = element.text.nil? ? nil : element.text.strip - - label = xml_node.elements['label'].text.strip - - element = xml_node.elements['parent-id'] - parent_id = element.text.nil? ? nil : element.text.strip - - # Node positions - element = xml_node.elements['position'] - position = (element && !element.text.nil?) ? element.text.strip : nil - created_at = xml_node.elements['created-at'].text.strip - updated_at = xml_node.elements['updated-at'].text.strip - - logger.info{ "New node detected: #{label}, parent_id: #{parent_id}, type_id: #{type_id}" } - - # There is one exception to the rule, the Configuration.uploadsNode node, - # it does not make sense to have more than one of this nodes, in any - # given tree - node = nil - if ( label == Configuration.uploadsNode ) - node = Node.find_or_create_by_label( label, { - :type_id => type_id, - :parent_id => parent_id - }) - - node.update_attribute(:created_at, created_at) if created_at - node.update_attribute(:updated_at, updated_at) if updated_at - else - node = Node.create :type_id => type_id, - :label => label, - :parent_id => parent_id, - :position => position - - node.update_attribute(:created_at, created_at) if created_at - node.update_attribute(:updated_at, updated_at) if updated_at - end - - xml_node.elements.each('notes/note') do |xml_note| - if xml_note.elements['author'] != nil - old_id = xml_note.elements['category-id'].text.strip - new_id = category_lookup[old_id] - - logger.info{ "Note category rewrite, used to be #{old_id}, now is #{new_id}" } - note = Note.create :author => xml_note.elements['author'].text.strip, - :node_id => node.id, - :category_id => new_id, - :text => xml_note.elements['text'].text.strip, - :created_at => xml_note.elements['created-at'].text.strip, - :updated_at => xml_note.elements['updated-at'].text.strip - end - end - - # keep track of reassigned ids - node_lookup[xml_node.elements['id'].text.strip] = node.id - - if node.parent_id != nil - # keep track of orphaned nodes - orphan_nodes << node - end - end - - # look for the parent_id of each orphaned node in the node_lookup table - orphan_nodes.each do |node| - logger.info{ "Finding parent for orphaned node: #{node.label}. Former parent was #{node.parent_id}" } - node.parent_id = node_lookup[node.parent_id.to_s] - node.save - end - - return node_lookup - end -end diff --git a/vendor/plugins/project_management/lib/tasks/thorfile.rb b/vendor/plugins/project_management/lib/tasks/thorfile.rb deleted file mode 100644 index 31305251..00000000 --- a/vendor/plugins/project_management/lib/tasks/thorfile.rb +++ /dev/null @@ -1,140 +0,0 @@ -require 'logger' - -class DradisTasks < Thor - class Export < Thor - class ProjectManagement < Thor - namespace "dradis:export:project" - - desc "template", "export the current repository structure as a dradis template" - method_option :file, :type => :string, :desc => "the template file to create, or directory to create it in" - def template - require 'config/environment' - - logger = Logger.new(STDOUT) - logger.level = Logger::DEBUG - - template_path = options.file || Rails.root.join('backup') - - unless template_path =~ /\.xml\z/ - date = DateTime.now.strftime("%Y-%m-%d") - sequence = Dir.glob(File.join(template_path, "dradis-template_#{date}_*.xml")).collect { |a| a.match(/_([0-9]+)\.xml\z/)[1].to_i }.max || 0 - template_path = File.join(template_path, "dradis-template_#{date}_#{sequence + 1}.xml") - end - - template = ProjectExport::Processor.db_only(:logger => logger) - - f = File.new(template_path, 'w') - f.write template - f.close - - logger.info{ "Template file created at:\n\t#{ File.expand_path( f.path ) }" } - logger.close - end - - -# desc "metaserver", "commit project to the Meta-Server" -# def metaserver -# require 'config/environment' -# -# logger = Logger.new(STDOUT) -# logger.level = Logger::DEBUG -# -# mode = Configuration.find_by_name('mode').value -# title = "NewProject_#{DateTime.now.strftime('%Y-%m-%d')}" -# -# # If this project was never checked out from the Meta-Server, give the -# # user a chance to choose a project title -# if (mode == 'new') -# puts "This project was not checked out from a Meta-Server. Please provide a project name:" -# response = STDIN.gets("\n").chomp -# if !response.empty? -# title = response -# end -# end -# -# begin -# ProjectExport::MetaServerProcessor.commit(:logger => logger, :title => title) -# rescue Exception => e -# logger.error{ 'There was an error sending the project to the Meta-Server:' } -# logger.error{ e.message } -# logger.error{ "The current settings from [#{ProjectManagement::CONF_FILE}]:" } -# logger.error{ ProjectManagement::CONF['meta-server'] } -# end -# -# logger.close -# end - - - desc "package", "creates a copy of your current repository" - long_desc "Creates a copy of the current repository, including all nodes, notes and " + - "attachments as a zipped archive. The backup can be imported into another " + - "dradis instance using the 'Project Package Upload' option." - method_option :file, :type => :string, :desc => "the package file to create, or directory to create it in" - def package - require 'config/environment' - - logger = Logger.new(STDOUT) - logger.level = Logger::DEBUG - - package_path = options.file || Rails.root.join('backup') - - unless package_path =~ /\.xml\z/ - date = DateTime.now.strftime("%Y-%m-%d") - sequence = Dir.glob(File.join(package_path, "dradis-export_#{date}_*.zip")).collect { |a| a.match(/_([0-9]+)\.zip\z/)[1].to_i }.max || 0 - package_path = File.join(package_path, "dradis-export_#{date}_#{sequence + 1}.zip") - end - - ProjectExport::Processor.full_project(:logger => logger, :filename => package_path) - - logger.info{ "Project package created at:\n\t#{ File.expand_path( package_path ) }" } - logger.close - end - - end - end - - class Upload < Thor - class ProjectManagement < Thor - namespace "dradis:upload:project" - - # This task will load into the current database the contents of the template - # file passed as the first argument - desc "template FILE", "create a new repository structure from an XML file" - def template(file_path) - require 'config/environment' - - logger = Logger.new(STDOUT) - logger.level = Logger::DEBUG - - unless File.exists?(file_path) - $stderr.puts "** the file [#{file_path}] does not exist" - exit -1 - end - - ProjectTemplateUpload::import(:logger => logger, :file => file_path ) - logger.close - end - - - # The reverse operation to the dradis:export:project:package task. From a - # zipped project package extract the contents of the archive and populate - # the dradis DB and attachments with them. - desc "package FILE", "import an entire repository package" - def package(file_path) - require 'config/environment' - - logger = Logger.new(STDOUT) - logger.level = Logger::DEBUG - - unless File.exists?(file_path) - $stderr.puts "** the file [#{file_path}] does not exist" - exit -1 - end - - ProjectPackageUpload::import(:logger => logger, :file => file_path ) - logger.close - end - - end - end -end diff --git a/vendor/plugins/project_management/spec/fixtures/files/no_positions.xml b/vendor/plugins/project_management/spec/fixtures/files/no_positions.xml deleted file mode 100644 index 7be13b36..00000000 --- a/vendor/plugins/project_management/spec/fixtures/files/no_positions.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - 2012-02-12T19:09:24Z - 28 - - - - 2012-02-12T19:09:24Z - - - etd - 1 - 2012-03-26T06:33:03Z - 1 - 28 - one - 2012-03-26T06:33:03Z - - - - - 2012-02-12T17:38:26Z - 29 - - - 0 - 2012-02-12T19:02:57Z - - - etd - 1 - 2012-03-26T06:33:09Z - 2 - 29 - two - 2012-03-26T06:33:09Z - - - - - 2012-02-12T17:38:30Z - 30 - - 32 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:38:34Z - 31 - - 29 - 0 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:43:55Z - 32 - - - 0 - 2012-02-12T17:43:55Z - - - etd - 1 - 2012-03-26T06:33:16Z - 3 - 32 - three - 2012-03-26T06:33:16Z - - - - - 2012-02-12T17:50:17Z - 33 - - 32 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:55:54Z - 34 - - 29 - 0 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:56:02Z - 35 - - 32 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:56:06Z - 36 - - 29 - 0 - 2012-02-12T19:09:24Z - - - - - 2012-02-12T17:20:30Z - 1 - default category - 2012-02-12T17:20:30Z - - - 2012-02-12T19:04:03Z - 5 - default category - 2012-02-12T19:04:03Z - - - 2012-02-12T19:04:31Z - 6 - HTMLExport ready - 2012-02-12T19:04:31Z - - - 2012-02-12T19:04:31Z - 7 - WordExport ready - 2012-02-12T19:04:31Z - - \ No newline at end of file diff --git a/vendor/plugins/project_management/spec/fixtures/files/with_positions.xml b/vendor/plugins/project_management/spec/fixtures/files/with_positions.xml deleted file mode 100644 index 09f8ea7b..00000000 --- a/vendor/plugins/project_management/spec/fixtures/files/with_positions.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - 2012-02-12T19:09:24Z - 28 - - - 0 - - 2012-02-12T19:09:24Z - - - etd - 1 - 2012-03-26T06:33:03Z - 1 - 28 - one - 2012-03-26T06:33:03Z - - - - - 2012-02-12T17:38:26Z - 29 - - - 2 - 0 - 2012-02-12T19:02:57Z - - - etd - 1 - 2012-03-26T06:33:09Z - 2 - 29 - two - 2012-03-26T06:33:09Z - - - - - 2012-02-12T17:38:30Z - 30 - - 32 - 3 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:38:34Z - 31 - - 29 - 2 - 0 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:43:55Z - 32 - - - 0 - 0 - 2012-02-12T17:43:55Z - - - etd - 1 - 2012-03-26T06:33:16Z - 3 - 32 - three - 2012-03-26T06:33:16Z - - - - - 2012-02-12T17:50:17Z - 33 - - 32 - 2 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:55:54Z - 34 - - 29 - 3 - 0 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:56:02Z - 35 - - 32 - 1 - 1 - 2012-02-12T19:09:24Z - - - - 2012-02-12T17:56:06Z - 36 - - 29 - 1 - 0 - 2012-02-12T19:09:24Z - - - - - 2012-02-12T17:20:30Z - 1 - default category - 2012-02-12T17:20:30Z - - - 2012-02-12T19:04:03Z - 5 - default category - 2012-02-12T19:04:03Z - - - 2012-02-12T19:04:31Z - 6 - HTMLExport ready - 2012-02-12T19:04:31Z - - - 2012-02-12T19:04:31Z - 7 - WordExport ready - 2012-02-12T19:04:31Z - - \ No newline at end of file diff --git a/vendor/plugins/project_management/spec/project_management_spec.rb b/vendor/plugins/project_management/spec/project_management_spec.rb deleted file mode 100644 index 03564af2..00000000 --- a/vendor/plugins/project_management/spec/project_management_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe 'ProjectManagement plugin' do - describe 'Template upload' do - it "restores the node positions from the template" do - fixture_file = "spec/fixtures/files/with_positions.xml" - Node.count.should eq(0) - Note.count.should eq(0) - lambda{ ProjectTemplateUpload::import( :file => fixture_file ) }.should_not raise_error - Node.count.should eq(9) - Note.count.should eq(3) - node = Node.find_by_label('branch #1') - node.should_not be_nil() - node.notes.count.should eq(1) - node.notes.first.text.should eq('two') - node.position.should eq(2) - end - - it "gracefully handles imports without positions (pre v2.9)" do - fixture_file = "spec/fixtures/files/no_positions.xml" - Node.count.should eq(0) - Note.count.should eq(0) - lambda{ ProjectTemplateUpload::import( :file => fixture_file ) }.should_not raise_error - Node.count.should eq(9) - Note.count.should eq(3) - node = Node.find_by_label('branch #1') - node.should_not be_nil() - node.notes.count.should eq(1) - node.notes.first.text.should eq('two') - node.position.should eq(0) - end - end -end \ No newline at end of file diff --git a/vendor/plugins/project_management/spec/spec_helper.rb b/vendor/plugins/project_management/spec/spec_helper.rb deleted file mode 100644 index 0a1ff079..00000000 --- a/vendor/plugins/project_management/spec/spec_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../../../../config/environment", __FILE__) -require 'rspec/rails' - -RSpec.configure do |config| - config.color_enabled = true - # Use the specified formatter - config.formatter = :documentation - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - config.before(:suite) do - Configuration.create(:name=>'revision', :value=>'0') - Configuration.create(:name=>'uploads_node', :value=>'Uploaded files') - end -end \ No newline at end of file diff --git a/vendor/plugins/project_management/uninstall.rb b/vendor/plugins/project_management/uninstall.rb deleted file mode 100644 index e69de29b..00000000