Skip to content

Commit

Permalink
Merge pull request #405 from internetee/404-fix-whitelisted-info
Browse files Browse the repository at this point in the history
Disclosed contact info for whitelisted users
  • Loading branch information
vohmar authored Mar 27, 2024
2 parents 9d69755 + 86e14e5 commit d3d8e2b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 31 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04]
ruby: ['2.7', '3.0.3']
ruby: ['3.0.3']
runs-on: ${{ matrix.os }}
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
steps:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '2.7', '3.0.3' ]
ruby: [ '3.0.3' ]
runs-on: ubuntu-22.04

env:
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ gem 'bootsnap', '~> 1.18.0', require: false
gem 'figaro', '~> 1.2.0'
gem 'jbuilder'
gem 'mimemagic', '~> 0.4.3'
gem 'passenger', '>= 5.3.2', require: 'phusion_passenger/rack_handler'
gem 'pg', '~> 1.5.0'
gem 'rails', '>= 6.0.3.1'
gem 'recaptcha', '~> 5.8', require: 'recaptcha/rails'
gem 'sassc', '~> 2.4'
gem 'sassc-rails'
gem 'simpleidn', '0.2.1' # For Punycode
gem 'uglifier'
gem 'passenger', '>= 5.3.2', require: 'phusion_passenger/rack_handler'

group :development do
gem 'listen', '>= 3.0.5', '< 3.9'
Expand All @@ -21,10 +21,10 @@ end
group :development, :test do
gem 'apparition', github: 'twalpole/apparition', ref: 'ca86be4d54af835d531dbcd2b86e7b2c77f85f34'
gem 'capybara'
gem 'pry'
gem 'unicorn'
gem 'mina', '~> 1.2.4'
gem 'pry'
gem 'puma'
gem 'unicorn'
gem 'webmock'
end

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.3.11
2.5.7
2 changes: 1 addition & 1 deletion app/presenters/contact_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def last_update
private

def disclose_attr_for_org_registrant(attr)
if contact_publishable? || captcha_solved?
if whitelisted_user? || contact_publishable? || captcha_solved?
contact.send(attr.to_sym)
else
disclosable_mask
Expand Down
22 changes: 6 additions & 16 deletions app/presenters/registrant_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
class RegistrantPresenter < ContactPresenter
def name
if registrant_is_org?
contact.name
else
disclose_data_priv_registrant('name')
end
registrant_is_org? ? contact.name : disclose_data_priv_registrant('name')
end

def email
# publishable_attribute('email')
disclose_registrant_data('email')
registrant_is_org? ? disclose_attr('email') : disclose_data_priv_registrant('email')
end

def phone
Expand All @@ -18,29 +14,23 @@ def phone
end

def last_update
if captcha_solved?
contact.last_update
else
disclosable_mask
end
captcha_solved? ? contact.last_update : disclosable_mask
end

private

def disclose_registrant_data(attr)
registrant_is_org? ? disclose_attr(attr) : disclose_data_priv_registrant(attr)
end

def disclose_attr(attr)
if registrant_publishable? || captcha_solved?
if whitelisted_user? || registrant_publishable? || captcha_solved?
contact.send(attr.to_sym)
else
disclosable_mask
end
end

def disclose_data_priv_registrant(attr)
return contact.send(attr.to_sym) if whitelisted_user?
return undisclosable_mask unless contact.attribute_disclosed?(attr)

disclose_attr(attr)
end
end
10 changes: 5 additions & 5 deletions test/integration/whois_records/json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def test_show_sensitive_data_of_private_entity_when_ip_is_in_whitelist
get '/v1/privatedomain.test', params: { format: :json }
response_json = JSON.parse(response.body, symbolize_names: true)

assert_equal 'Not Disclosed', response_json[:registrant]
assert_equal 'Not Disclosed', response_json[:email]
assert_equal 'Not Disclosed', response_json[:phone]
assert_equal 'test', response_json[:registrant]
assert_equal '[email protected]', response_json[:email]
assert_equal '+555.555', response_json[:phone]
assert_equal '2018-04-25T14:10:39+00:00', response_json[:registrant_changed]

expected_admin_contacts = [
Expand All @@ -178,8 +178,8 @@ def test_show_sensitive_data_of_legal_entity_when_ip_is_in_whitelist
response_json = JSON.parse(response.body, symbolize_names: true)

assert_equal 'test', response_json[:registrant]
assert_equal 'Not Disclosed - Visit www.internet.ee for web-based WHOIS', response_json[:email]
assert_equal 'Not Disclosed', response_json[:phone]
assert_equal '[email protected]', response_json[:email]
assert_equal '+555.555', response_json[:phone]
assert_equal '2018-04-25T14:10:39+00:00', response_json[:registrant_changed]

expected_admin_contacts = [
Expand Down
6 changes: 3 additions & 3 deletions test/system/whois_records/details/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def test_registrant_details
visit whois_record_url(name: @whois_record.name)

within '.registrant' do
assert_text 'Name Not Disclosed'
assert_text 'Email Not Disclosed'
assert_text 'Phone Not Disclosed'
assert_text 'Name John'
assert_text 'Email [email protected]'
assert_text '+555.555'
assert_text 'Last update Not Disclosed - Visit www.internet.ee for web-based WHOIS'
end
end
Expand Down

0 comments on commit d3d8e2b

Please sign in to comment.