Skip to content

Commit

Permalink
Mdm::Service host.tags association search
Browse files Browse the repository at this point in the history
MSP-10826
  • Loading branch information
limhoff-r7 committed Jul 26, 2014
1 parent f35e2cc commit a25fbcf
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/mdm/service.rb
Expand Up @@ -189,7 +189,7 @@ class Mdm::Service < ActiveRecord::Base
# Search Associations
#

search_association :host
search_associations host: :tags

#
# Search Attributes
Expand Down
Expand Up @@ -180,7 +180,13 @@
os_flavor: non_matching_host_os_flavor,
os_name: non_matching_host_os_name,
os_sp: non_matching_host_os_sp
)
).tap { |host|
FactoryGirl.create(
:mdm_host_tag,
host: host,
tag: non_matching_tag
)
}
}

let(:non_matching_host_address) {
Expand Down Expand Up @@ -219,6 +225,22 @@
'udp'
}

let(:non_matching_tag) {
FactoryGirl.create(
:mdm_tag,
desc: non_matching_tag_desc,
name: non_matching_tag_name
)
}

let(:non_matching_tag_desc) {
'Mdm::Tag#description b'
}

let(:non_matching_tag_name) {
'mdm_tag_name.b'
}

#
# let!s
#
Expand Down Expand Up @@ -333,7 +355,13 @@
os_flavor: matching_host_os_flavor,
os_name: matching_host_os_name,
os_sp: matching_host_os_sp
)
).tap { |host|
FactoryGirl.create(
:mdm_host_tag,
host: host,
tag: matching_tag
)
}
}

let(:matching_host_address) {
Expand Down Expand Up @@ -372,6 +400,22 @@
'tcp'
}

let(:matching_tag) {
FactoryGirl.create(
:mdm_tag,
desc: matching_tag_desc,
name: matching_tag_name
)
}

let(:matching_tag_desc) {
'Mdm::Tag#description a'
}

let(:matching_tag_name) {
'mdm_tag_name.a'
}

#
# let!s
#
Expand Down Expand Up @@ -487,6 +531,18 @@
association: :host,
attribute: :os_sp

it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
association: {
host: :tags
},
attribute: :desc

it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
association: {
host: :tags
},
attribute: :name

it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
attribute: :info

Expand All @@ -507,6 +563,8 @@
host.os_flavor:#{matching_host_os_flavor}
host.os_name:#{matching_host_os_name}
host.os_sp:#{matching_host_os_sp}
host.tags.desc:"#{matching_tag_desc}"
host.tags.name:#{matching_tag_name}
name:#{matching_name}
port:#{matching_port}
proto:#{matching_proto}
Expand Down

0 comments on commit a25fbcf

Please sign in to comment.