Skip to content

Commit

Permalink
Allow Values::Website#=== to match against Values::EmailAddress.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jul 15, 2024
1 parent d89411a commit bb2e21d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ronin/recon/values/website.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

require 'ronin/recon/value'
require 'ronin/recon/values/url'
require 'ronin/recon/values/email_address'

require 'uri'

Expand Down Expand Up @@ -146,6 +147,8 @@ def ===(other)
@scheme == other.scheme &&
@host == other.host &&
@port == other.port
when EmailAddress
other.address.end_with?("@#{@host}")
else
false
end
Expand Down
32 changes: 32 additions & 0 deletions spec/values/website_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,38 @@
end
end

context "when given a EmailAddress object" do
context "and the other EmailAddress value ends with the same domain as the website" do
let(:other) do
Ronin::Recon::Values::EmailAddress.new("john.smith@#{host}")
end

it "must return true" do
expect(subject === other).to be(true)
end
end

context "but the other EmailAddress value ends with a sub-domain of the website's host name" do
let(:other) do
Ronin::Recon::Values::EmailAddress.new("john.smith@subdomain.#{host}")
end

it "must return false" do
expect(subject === other).to be(false)
end
end

context "but the other EmailAddress value ends with a different domain than the website" do
let(:other) do
Ronin::Recon::Values::EmailAddress.new("[email protected]")
end

it "must return false" do
expect(subject === other).to be(false)
end
end
end

context "when given a non-Value object" do
let(:other) { Object.new }

Expand Down

0 comments on commit bb2e21d

Please sign in to comment.