metasploit_data_models 0.17.1 → 0.17.2.pre.metasploit.pre.data.pre.models.pre.search
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/app/models/mdm/host.rb +24 -0
- data/app/models/mdm/service.rb +9 -0
- data/app/models/metasploit_data_models/search/visitor/attribute.rb +13 -0
- data/app/models/metasploit_data_models/search/visitor/includes.rb +28 -0
- data/app/models/metasploit_data_models/search/visitor/joins.rb +47 -0
- data/app/models/metasploit_data_models/search/visitor/method.rb +13 -0
- data/app/models/metasploit_data_models/search/visitor/relation.rb +87 -0
- data/app/models/metasploit_data_models/search/visitor/where.rb +65 -0
- data/config/locales/en.yml +7 -0
- data/lib/metasploit_data_models.rb +1 -0
- data/lib/metasploit_data_models/search.rb +6 -0
- data/lib/metasploit_data_models/search/visitor.rb +8 -0
- data/lib/metasploit_data_models/version.rb +1 -1
- data/metasploit_data_models.gemspec +1 -0
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +74 -0
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +124 -0
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +292 -0
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +33 -0
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +253 -0
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +147 -0
- data/spec/dummy/config/initializers/active_record_migrations.rb +4 -0
- data/spec/factories/mdm/services.rb +5 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +38 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +26 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record.rb +37 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record/with_metasploit_model_search_opeator_deprecated_platform.rb +31 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record/with_metasploit_model_search_operator_deprecated_authority.rb +78 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +34 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +50 -0
- metadata +61 -4
| @@ -0,0 +1,124 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MetasploitDataModels::Search::Visitor::Includes do
         | 
| 4 | 
            +
              subject(:visitor) do
         | 
| 5 | 
            +
                described_class.new
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              context '#visit' do
         | 
| 9 | 
            +
                subject(:visit) do
         | 
| 10 | 
            +
                  visitor.visit(node)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                children_classes = [
         | 
| 14 | 
            +
                    Metasploit::Model::Search::Group::Intersection,
         | 
| 15 | 
            +
                    Metasploit::Model::Search::Group::Union,
         | 
| 16 | 
            +
                    Metasploit::Model::Search::Operation::Union
         | 
| 17 | 
            +
                ]
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                children_classes.each do |children_class|
         | 
| 20 | 
            +
                  context "with #{children_class}" do
         | 
| 21 | 
            +
                    it_should_behave_like "MetasploitDataModels::Search::Visitor::Includes#visit with #children" do
         | 
| 22 | 
            +
                      let(:node_class) do
         | 
| 23 | 
            +
                        children_class
         | 
| 24 | 
            +
                      end
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                operation_classes = [
         | 
| 30 | 
            +
                    Metasploit::Model::Search::Operation::Boolean,
         | 
| 31 | 
            +
                    Metasploit::Model::Search::Operation::Date,
         | 
| 32 | 
            +
                    Metasploit::Model::Search::Operation::Integer,
         | 
| 33 | 
            +
                    Metasploit::Model::Search::Operation::Null,
         | 
| 34 | 
            +
                    Metasploit::Model::Search::Operation::Set::Integer,
         | 
| 35 | 
            +
                    Metasploit::Model::Search::Operation::Set::String,
         | 
| 36 | 
            +
                    Metasploit::Model::Search::Operation::String
         | 
| 37 | 
            +
                ]
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                operation_classes.each do |operation_class|
         | 
| 40 | 
            +
                  context "with #{operation_class}" do
         | 
| 41 | 
            +
                    it_should_behave_like 'MetasploitDataModels::Search::Visitor::Includes#visit with Metasploit::Model::Search::Operation::Base' do
         | 
| 42 | 
            +
                      let(:node_class) do
         | 
| 43 | 
            +
                        operation_class
         | 
| 44 | 
            +
                      end
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                context 'with Metasploit::Model::Search::Operation::Union' do
         | 
| 50 | 
            +
                  let(:node) do
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                context 'with Metasploit::Model::Search::Operator::Association' do
         | 
| 56 | 
            +
                  let(:association) do
         | 
| 57 | 
            +
                    FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  let(:node) do
         | 
| 61 | 
            +
                    Metasploit::Model::Search::Operator::Association.new(
         | 
| 62 | 
            +
                        :association => association
         | 
| 63 | 
            +
                    )
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  it 'should include association' do
         | 
| 67 | 
            +
                    visit.should include(association)
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                context 'with Metasploit::Model::Search::Operator::Attribute' do
         | 
| 72 | 
            +
                  let(:node) do
         | 
| 73 | 
            +
                    Metasploit::Model::Search::Operator::Attribute.new
         | 
| 74 | 
            +
                  end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  it { should == [] }
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                context 'with Metasploit::Model::Search::Query#tree' do
         | 
| 80 | 
            +
                  let(:node) do
         | 
| 81 | 
            +
                    query.tree
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                  let(:query) do
         | 
| 85 | 
            +
                    Metasploit::Model::Search::Query.new(
         | 
| 86 | 
            +
                        :formatted => formatted,
         | 
| 87 | 
            +
                        :klass => klass
         | 
| 88 | 
            +
                    )
         | 
| 89 | 
            +
                  end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  context 'Metasploit::Model::Search::Query#klass' do
         | 
| 92 | 
            +
                    context 'with Mdm::Host' do
         | 
| 93 | 
            +
                      let(:klass) {
         | 
| 94 | 
            +
                        Mdm::Host
         | 
| 95 | 
            +
                      }
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                      context 'with name' do
         | 
| 98 | 
            +
                        let(:name) do
         | 
| 99 | 
            +
                          FactoryGirl.generate :mdm_host_name
         | 
| 100 | 
            +
                        end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                        let(:formatted) do
         | 
| 103 | 
            +
                          "name:\"#{name}\""
         | 
| 104 | 
            +
                        end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                        it { should be_empty }
         | 
| 107 | 
            +
                      end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                      context 'with services.name' do
         | 
| 110 | 
            +
                        let(:name) do
         | 
| 111 | 
            +
                          FactoryGirl.generate :mdm_service_name
         | 
| 112 | 
            +
                        end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                        let(:formatted) do
         | 
| 115 | 
            +
                          "services.name:\"#{name}\""
         | 
| 116 | 
            +
                        end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                        it { should include :services }
         | 
| 119 | 
            +
                      end
         | 
| 120 | 
            +
                    end
         | 
| 121 | 
            +
                  end
         | 
| 122 | 
            +
                end
         | 
| 123 | 
            +
              end
         | 
| 124 | 
            +
            end
         | 
| @@ -0,0 +1,292 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MetasploitDataModels::Search::Visitor::Joins do
         | 
| 4 | 
            +
              subject(:visitor) do
         | 
| 5 | 
            +
                described_class.new
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              context '#visit' do
         | 
| 9 | 
            +
                subject(:visit) do
         | 
| 10 | 
            +
                  visitor.visit(node)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                context 'with Metasploit::Model::Search::Group::Intersection' do
         | 
| 14 | 
            +
                  let(:children) do
         | 
| 15 | 
            +
                    2.times.collect { |n|
         | 
| 16 | 
            +
                      double("Child #{n}")
         | 
| 17 | 
            +
                    }
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  let(:node) do
         | 
| 21 | 
            +
                    Metasploit::Model::Search::Group::Intersection.new(
         | 
| 22 | 
            +
                        :children => children
         | 
| 23 | 
            +
                    )
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  it 'should visit each child' do
         | 
| 27 | 
            +
                    # needed for call to visit subject
         | 
| 28 | 
            +
                    visitor.should_receive(:visit).with(node).and_call_original
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    children.each do |child|
         | 
| 31 | 
            +
                      visitor.should_receive(:visit).with(child).and_return([])
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                    visit
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  it 'should return Array of all child visits' do
         | 
| 38 | 
            +
                    child_visits = []
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    visitor.should_receive(:visit).with(node).and_call_original
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    children.each_with_index do |child, i|
         | 
| 43 | 
            +
                      child_visit = ["Visited Child #{i}"]
         | 
| 44 | 
            +
                      visitor.stub(:visit).with(child).and_return(child_visit)
         | 
| 45 | 
            +
                      child_visits.concat(child_visit)
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    visit.should == child_visits
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                union_classes = [
         | 
| 53 | 
            +
                    Metasploit::Model::Search::Group::Union,
         | 
| 54 | 
            +
                    Metasploit::Model::Search::Operation::Union
         | 
| 55 | 
            +
                ]
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                union_classes.each do |union_class|
         | 
| 58 | 
            +
                  context "with #{union_class}" do
         | 
| 59 | 
            +
                    let(:node) do
         | 
| 60 | 
            +
                      union_class.new(
         | 
| 61 | 
            +
                          children: children
         | 
| 62 | 
            +
                      )
         | 
| 63 | 
            +
                    end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    context 'with children' do
         | 
| 66 | 
            +
                      context 'without child joins' do
         | 
| 67 | 
            +
                        let(:children) do
         | 
| 68 | 
            +
                          Array.new(2) {
         | 
| 69 | 
            +
                            Metasploit::Model::Search::Operator::Attribute.new
         | 
| 70 | 
            +
                          }
         | 
| 71 | 
            +
                        end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                        it { should == [] }
         | 
| 74 | 
            +
                      end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                      context 'with association and attribute' do
         | 
| 77 | 
            +
                        let(:association) do
         | 
| 78 | 
            +
                          FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 79 | 
            +
                        end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                        let(:association_operator) do
         | 
| 82 | 
            +
                          Metasploit::Model::Search::Operator::Association.new(
         | 
| 83 | 
            +
                              association: association
         | 
| 84 | 
            +
                          )
         | 
| 85 | 
            +
                        end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                        let(:attribute_operator) do
         | 
| 88 | 
            +
                          Metasploit::Model::Search::Operator::Attribute.new
         | 
| 89 | 
            +
                        end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                        let(:children) do
         | 
| 92 | 
            +
                          [
         | 
| 93 | 
            +
                              association_operator,
         | 
| 94 | 
            +
                              attribute_operator
         | 
| 95 | 
            +
                          ]
         | 
| 96 | 
            +
                        end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                        it { should == [] }
         | 
| 99 | 
            +
                      end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                      context 'with the same child join for all' do
         | 
| 102 | 
            +
                        let(:association) do
         | 
| 103 | 
            +
                          FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 104 | 
            +
                        end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                        let(:association_operator) do
         | 
| 107 | 
            +
                          Metasploit::Model::Search::Operator::Association.new(
         | 
| 108 | 
            +
                              association: association
         | 
| 109 | 
            +
                          )
         | 
| 110 | 
            +
                        end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                        let(:children) do
         | 
| 113 | 
            +
                          Array.new(2) {
         | 
| 114 | 
            +
                            association_operator
         | 
| 115 | 
            +
                          }
         | 
| 116 | 
            +
                        end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                        it 'should include association' do
         | 
| 119 | 
            +
                          visit.should include association
         | 
| 120 | 
            +
                        end
         | 
| 121 | 
            +
                      end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                      context 'with union of intersections' do
         | 
| 124 | 
            +
                        let(:disjoint_associations) do
         | 
| 125 | 
            +
                          Array.new(2) {
         | 
| 126 | 
            +
                            FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 127 | 
            +
                          }
         | 
| 128 | 
            +
                        end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                        let(:first_associations) do
         | 
| 131 | 
            +
                          disjoint_associations[0, 1] + common_associations
         | 
| 132 | 
            +
                        end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                        let(:first_association_operators) do
         | 
| 135 | 
            +
                          first_associations.collect { |association|
         | 
| 136 | 
            +
                            Metasploit::Model::Search::Operator::Association.new(
         | 
| 137 | 
            +
                                association: association
         | 
| 138 | 
            +
                            )
         | 
| 139 | 
            +
                          }
         | 
| 140 | 
            +
                        end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                        let(:second_associations) do
         | 
| 143 | 
            +
                          disjoint_associations[1, 1] + common_associations
         | 
| 144 | 
            +
                        end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                        let(:second_association_operators) do
         | 
| 147 | 
            +
                          second_associations.collect { |association|
         | 
| 148 | 
            +
                            Metasploit::Model::Search::Operator::Association.new(
         | 
| 149 | 
            +
                                association: association
         | 
| 150 | 
            +
                            )
         | 
| 151 | 
            +
                          }
         | 
| 152 | 
            +
                        end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                        let(:children) do
         | 
| 155 | 
            +
                          [first_association_operators, second_association_operators].collect { |grandchildren|
         | 
| 156 | 
            +
                            Metasploit::Model::Search::Group::Intersection.new(
         | 
| 157 | 
            +
                                children: grandchildren
         | 
| 158 | 
            +
                            )
         | 
| 159 | 
            +
                          }
         | 
| 160 | 
            +
                        end
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                        context 'with a common subset of child join' do
         | 
| 163 | 
            +
                          let(:common_associations) do
         | 
| 164 | 
            +
                            Array.new(2) {
         | 
| 165 | 
            +
                              FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 166 | 
            +
                            }
         | 
| 167 | 
            +
                          end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                          it 'should include common associations' do
         | 
| 170 | 
            +
                            common_associations.each do |association|
         | 
| 171 | 
            +
                              visit.should include(association)
         | 
| 172 | 
            +
                            end
         | 
| 173 | 
            +
                          end
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                          it 'should not include disjoint associations' do
         | 
| 176 | 
            +
                            disjoint_associations.each do |association|
         | 
| 177 | 
            +
                              visit.should_not include(association)
         | 
| 178 | 
            +
                            end
         | 
| 179 | 
            +
                          end
         | 
| 180 | 
            +
                        end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                        context 'without a common subset of child joins' do
         | 
| 183 | 
            +
                          let(:common_associations) do
         | 
| 184 | 
            +
                            []
         | 
| 185 | 
            +
                          end
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                          it { should == [] }
         | 
| 188 | 
            +
                        end
         | 
| 189 | 
            +
                      end
         | 
| 190 | 
            +
                    end
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                    context 'without children' do
         | 
| 193 | 
            +
                      let(:children) do
         | 
| 194 | 
            +
                        []
         | 
| 195 | 
            +
                      end
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                      it { should == [] }
         | 
| 198 | 
            +
                    end
         | 
| 199 | 
            +
                  end
         | 
| 200 | 
            +
                end
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                operation_classes = [
         | 
| 203 | 
            +
                    Metasploit::Model::Search::Operation::Boolean,
         | 
| 204 | 
            +
                    Metasploit::Model::Search::Operation::Date,
         | 
| 205 | 
            +
                    Metasploit::Model::Search::Operation::Integer,
         | 
| 206 | 
            +
                    Metasploit::Model::Search::Operation::Null,
         | 
| 207 | 
            +
                    Metasploit::Model::Search::Operation::Set::Integer,
         | 
| 208 | 
            +
                    Metasploit::Model::Search::Operation::Set::String,
         | 
| 209 | 
            +
                    Metasploit::Model::Search::Operation::String
         | 
| 210 | 
            +
                ]
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                operation_classes.each do |operation_class|
         | 
| 213 | 
            +
                  context "with #{operation_class}" do
         | 
| 214 | 
            +
                    it_should_behave_like 'MetasploitDataModels::Search::Visitor::Includes#visit with Metasploit::Model::Search::Operation::Base' do
         | 
| 215 | 
            +
                      let(:node_class) do
         | 
| 216 | 
            +
                        operation_class
         | 
| 217 | 
            +
                      end
         | 
| 218 | 
            +
                    end
         | 
| 219 | 
            +
                  end
         | 
| 220 | 
            +
                end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                context 'with Metasploit::Model::Search::Operator::Association' do
         | 
| 223 | 
            +
                  let(:association) do
         | 
| 224 | 
            +
                    FactoryGirl.generate :metasploit_model_search_operator_association_association
         | 
| 225 | 
            +
                  end
         | 
| 226 | 
            +
             | 
| 227 | 
            +
                  let(:node) do
         | 
| 228 | 
            +
                    Metasploit::Model::Search::Operator::Association.new(
         | 
| 229 | 
            +
                        :association => association
         | 
| 230 | 
            +
                    )
         | 
| 231 | 
            +
                  end
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                  it 'should include association' do
         | 
| 234 | 
            +
                    visit.should include(association)
         | 
| 235 | 
            +
                  end
         | 
| 236 | 
            +
                end
         | 
| 237 | 
            +
             | 
| 238 | 
            +
                context "with Metasploit::Model::Search::Operator::Attribute" do
         | 
| 239 | 
            +
                  let(:node) do
         | 
| 240 | 
            +
                    Metasploit::Model::Search::Operator::Attribute.new
         | 
| 241 | 
            +
                  end
         | 
| 242 | 
            +
             | 
| 243 | 
            +
                  it { should == [] }
         | 
| 244 | 
            +
                end
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                context 'with Metasploit::Model::Search::Query#tree' do
         | 
| 247 | 
            +
                  let(:node) do
         | 
| 248 | 
            +
                    query.tree
         | 
| 249 | 
            +
                  end
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                  let(:query) do
         | 
| 252 | 
            +
                    Metasploit::Model::Search::Query.new(
         | 
| 253 | 
            +
                        :formatted => formatted,
         | 
| 254 | 
            +
                        :klass => klass
         | 
| 255 | 
            +
                    )
         | 
| 256 | 
            +
                  end
         | 
| 257 | 
            +
             | 
| 258 | 
            +
                  context 'Metasploit::Model::Search:Query#klass' do
         | 
| 259 | 
            +
                    context 'with Mdm::Host' do
         | 
| 260 | 
            +
                      let(:klass) {
         | 
| 261 | 
            +
                        Mdm::Host
         | 
| 262 | 
            +
                      }
         | 
| 263 | 
            +
             | 
| 264 | 
            +
             | 
| 265 | 
            +
                      context 'with name' do
         | 
| 266 | 
            +
                        let(:name) do
         | 
| 267 | 
            +
                          FactoryGirl.generate :mdm_host_name
         | 
| 268 | 
            +
                        end
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                        let(:formatted) do
         | 
| 271 | 
            +
                          "name:\"#{name}\""
         | 
| 272 | 
            +
                        end
         | 
| 273 | 
            +
             | 
| 274 | 
            +
                        it { should be_empty }
         | 
| 275 | 
            +
                      end
         | 
| 276 | 
            +
             | 
| 277 | 
            +
                      context 'with services.name' do
         | 
| 278 | 
            +
                        let(:name) do
         | 
| 279 | 
            +
                          FactoryGirl.generate :mdm_service_name
         | 
| 280 | 
            +
                        end
         | 
| 281 | 
            +
             | 
| 282 | 
            +
                        let(:formatted) do
         | 
| 283 | 
            +
                          "services.name:\"#{name}\""
         | 
| 284 | 
            +
                        end
         | 
| 285 | 
            +
             | 
| 286 | 
            +
                        it { should include :services }
         | 
| 287 | 
            +
                      end
         | 
| 288 | 
            +
                    end
         | 
| 289 | 
            +
                  end
         | 
| 290 | 
            +
                end
         | 
| 291 | 
            +
              end
         | 
| 292 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MetasploitDataModels::Search::Visitor::Method do
         | 
| 4 | 
            +
              subject(:visitor) do
         | 
| 5 | 
            +
                described_class.new
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              context '#visit' do
         | 
| 9 | 
            +
                subject(:visit) do
         | 
| 10 | 
            +
                  visitor.visit(node)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                let(:node) do
         | 
| 14 | 
            +
                  node_class.new
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                context 'with Metasploit::Model::Search::Group::Intersection' do
         | 
| 18 | 
            +
                  let(:node_class) do
         | 
| 19 | 
            +
                    Metasploit::Model::Search::Group::Intersection
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  it { should == :and }
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                context 'with Metasploit::Model::Search::Group::Union' do
         | 
| 26 | 
            +
                  let(:node_class) do
         | 
| 27 | 
            +
                    Metasploit::Model::Search::Group::Union
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  it { should == :or }
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         |