dradis-plugins 4.5.0 → 4.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4339c131aa207ace140362e142a78fdcff456be73ea28613305e1b2d4c95c9c2
4
- data.tar.gz: e9c6f6ca411e7475ed8a36c9bf47946de8518106d9c10d332773c4488f44e11b
3
+ metadata.gz: 5d385ebd646d7e8827ff888c7ac8d72594e5c76b2e7e1d9b819d878a4f7fcbb8
4
+ data.tar.gz: 7295528af5c762c08cf94d05978181fec7ba65de17358932557c75c252d17eca
5
5
  SHA512:
6
- metadata.gz: 6b23de36437861bf0e659a71edf7e747c19aa04736017c71254224747533dd56aa460da39e365020db79879d6287adae8fa02babaf6f1a36069946afd7277c28
7
- data.tar.gz: 960e7ceb874626d3daba375a75fc41c988d5b68984a81d01d328507c1471aee5610621b5ad7d9de847c196e699226f35a038aecc2b7fa65d3e18abfd55571455
6
+ metadata.gz: 48bf16edf79e4bec72dcba64fc57bf5f7fda88f8c656bfafa5d948a8822c67565c663f2b632e2f41d323e292b3fcf0c70c521f63f9025c0fac9dab51e542cbe8
7
+ data.tar.gz: 72617d3db6285dbb639369fbc707c66a9b8af00427da56aada7fd166dbd686059a86fb4dacfca8267c41a60b90702662fbd66ab6c8d18cae50c30161ad81a01e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+
2
+ v4.6.0 (November 2022)
3
+ - Added engine enable/disable functionality
4
+
1
5
  v4.5.0 (August 2022)
2
6
  - No changes
3
7
 
@@ -39,6 +39,20 @@ module Dradis
39
39
  def provides?(feature)
40
40
  @features.include?(feature)
41
41
  end
42
+
43
+ def enabled?
44
+ ActiveRecord::Type::Boolean.new.cast(self.settings.enabled)
45
+ end
46
+
47
+ def enable!
48
+ self.settings.update_settings(enabled: true)
49
+ Dradis::Plugins::clear_enabled_list
50
+ end
51
+
52
+ def disable!
53
+ self.settings.update_settings(enabled: false)
54
+ Dradis::Plugins::clear_enabled_list
55
+ end
42
56
  end
43
57
  end
44
58
  end
@@ -7,8 +7,8 @@ module Dradis
7
7
 
8
8
  module VERSION
9
9
  MAJOR = 4
10
- MINOR = 5
11
- TINY = 0
10
+ MINOR = 6
11
+ TINY = 1
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -5,7 +5,7 @@ module Dradis::Plugins
5
5
  def initialize(namespace)
6
6
  @namespace = namespace
7
7
  @dirty_options ||= {}
8
- @default_options ||= HashWithIndifferentAccess.new
8
+ @default_options ||= { enabled: true }.with_indifferent_access
9
9
  end
10
10
 
11
11
  def respond_to?(name)
@@ -13,7 +13,7 @@ module Dradis::Plugins
13
13
  end
14
14
 
15
15
  def all
16
- @default_options.map do |key, value|
16
+ @default_options.except(:enabled).map do |key, value|
17
17
  {
18
18
  name: key.to_sym,
19
19
  value: value = dirty_or_db_setting_or_default(key.to_sym),
@@ -11,10 +11,19 @@ module Dradis
11
11
  @@extensions
12
12
  end
13
13
 
14
+ # Returns an array of modules representing currently enabled engines
15
+ def enabled_list
16
+ @@enabled_list ||= @@extensions.select(&:enabled?)
17
+ end
18
+
19
+ def clear_enabled_list
20
+ @@enabled_list = nil
21
+ end
22
+
14
23
  # Filters the list of plugins and only returns those that provide the
15
- # requested feature.
24
+ # requested feature and enabled
16
25
  def with_feature(feature)
17
- @@extensions.select do |plugin|
26
+ enabled_list.select do |plugin|
18
27
  # engine = "#{plugin}::Engine".constantize
19
28
  plugin.provides?(feature)
20
29
  end
@@ -0,0 +1,34 @@
1
+ require 'rails_helper'
2
+
3
+ class TestEngine < ::Rails::Engine
4
+ include ::Dradis::Plugins::Base
5
+ addon_settings :test_engine do
6
+ end
7
+ end
8
+
9
+ describe Dradis::Plugins::Base do
10
+ before(:each) do
11
+ TestEngine::settings.reset_defaults!
12
+ end
13
+
14
+ describe '#enabled?' do
15
+ it 'returns default value' do
16
+ expect(TestEngine.enabled?).to eq(false)
17
+ end
18
+ end
19
+ describe '#enable!' do
20
+ it 'sets enabled to true' do
21
+ expect { TestEngine.enable! }.to change {
22
+ TestEngine.enabled?
23
+ }.from(false).to(true)
24
+ end
25
+ end
26
+ describe '#disable!' do
27
+ it 'sets enabled to false' do
28
+ TestEngine.enable!
29
+ expect { TestEngine.disable! }.to change {
30
+ TestEngine.enabled?
31
+ }.from(true).to(false)
32
+ end
33
+ end
34
+ end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # This spec must be ran from Dradis root dir
3
3
  #
4
- require 'spec_helper'
4
+ require 'rails_helper'
5
5
 
6
6
  class TestEngine < ::Rails::Engine
7
7
  include ::Dradis::Plugins::Base
@@ -19,6 +19,7 @@ describe Dradis::Plugins::Settings do
19
19
  end
20
20
 
21
21
  it "sets and return default values" do
22
+ expect(TestEngine::settings.enabled).to eq(false)
22
23
  expect(TestEngine::settings.host).to eq('localhost')
23
24
  expect(TestEngine::settings.port).to eq(80)
24
25
  end
@@ -41,7 +42,6 @@ describe Dradis::Plugins::Settings do
41
42
  it "saves to db and returns persisted values" do
42
43
  expect(TestEngine::settings.host).to eq('localhost')
43
44
  TestEngine::settings.host = '127.0.0.1'
44
- expect_any_instance_of(TestEngine::settings::send(:configuration_class)).to receive(:update_attribute)
45
45
  expect(TestEngine::settings.save).to eq( { host: '127.0.0.1'} )
46
46
  expect(TestEngine::settings.host).to eq('127.0.0.1')
47
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ files:
103
103
  - lib/dradis/plugins/upload/field_processor.rb
104
104
  - lib/dradis/plugins/upload/importer.rb
105
105
  - lib/dradis/plugins/version.rb
106
+ - spec/engine_spec.rb
106
107
  - spec/internal/log/test.log
107
108
  - spec/lib/dradis/plugins/content_service/boards_spec.rb
108
109
  - spec/lib/dradis/plugins/content_service/issues_spec.rb
@@ -112,7 +113,7 @@ homepage: http://dradisframework.org
112
113
  licenses:
113
114
  - GPL-2
114
115
  metadata: {}
115
- post_install_message:
116
+ post_install_message:
116
117
  rdoc_options: []
117
118
  require_paths:
118
119
  - lib
@@ -127,11 +128,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  - !ruby/object:Gem::Version
128
129
  version: '0'
129
130
  requirements: []
130
- rubygems_version: 3.2.28
131
- signing_key:
131
+ rubygems_version: 3.3.7
132
+ signing_key:
132
133
  specification_version: 4
133
134
  summary: Plugin manager for the Dradis Framework project.
134
135
  test_files:
136
+ - spec/engine_spec.rb
135
137
  - spec/internal/log/test.log
136
138
  - spec/lib/dradis/plugins/content_service/boards_spec.rb
137
139
  - spec/lib/dradis/plugins/content_service/issues_spec.rb