Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDPR preparations for RESTful WHOIS #41

Merged
merged 15 commits into from
May 23, 2018
Merged

GDPR preparations for RESTful WHOIS #41

merged 15 commits into from
May 23, 2018

Conversation

maciej-szlosarczyk
Copy link
Contributor

Fixes #37, #38 and #40.

Also:

  • removes dependency on HAML
  • adds complete test suite, both JSON and HTML
  • Fixes gemset name collision with registry project

* Add missing integration tests
* Use Jbuilder for generating JSON
* Refactor WhoisRecord model
* Remove gemset collision with registry
* Remove Recaptcha api version, as only version 2 is supported
* Add tests that handle 404 requests
* Add tests that handle POST HTTP verb
@maciej-szlosarczyk maciej-szlosarczyk force-pushed the rest-whois-37 branch 2 times, most recently from 5b36ba1 to 8e6a4bb Compare May 8, 2018 12:29
@@ -1 +1 @@
registry
rest-whois
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we use this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to @teadur it has no bearing on production since servers are physically and logically separated.

However, locally it produces an undesired behaviour inside rvm/rbenv: both registry and and rest-whois used the same gemset, which for example contained 2 different versions of rails (4.2.10 and 4.2.7). It also allowed gems to "sneak" from one environment to another:

screen shot 2018-05-19 at 10 38 38

def full_body
@disclosed = (json['disclosed'] || []).dup
return body.to_s if @disclosed.empty?
BLOCKED = 'Blocked'.freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's worth using private_constant to hide them?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary

<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="Full stack top-level domain (TLD) management." name="description"/>
<meta content="Estonian Internet Foundation" name="author"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about removing the entire section? I don't see any point of it.

<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="Full stack top-level domain (TLD) management." name="description"/>
<meta content="Estonian Internet Foundation" name="author"/>

@@ -0,0 +1,8 @@
<% display = (flash[:notice] || flash[:alert] || flash[:warning]) ? 'block' : 'none' %>
Copy link
Contributor

@artur-intech artur-intech May 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to make this view more readable? Currently I find it hard to read.

</pre>
<% if @verified.blank? %>
<div class="full_info_form" style="padding: 20px 0 0 24px">
<%= form_for @whois_record, url: "/v1/#{@whois_record.name}", method: :get do |f| %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see f variable used. Wonder if we really need form_for here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all 3 comments above3: You'd have to ask Herbalizer, I converted it, since it worked, I didn't see any point in dwelling into the details of the rendered ERB.

<%= render partial: "whois", locals: { json: @whois_record.json } %>
</pre>
<% if @verified.blank? %>
<div class="full_info_form" style="padding: 20px 0 0 24px">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is to use dashes instead of underscores for CSS entities.


@private_domain = whois_records(:privately_owned)
@legal_domain = whois_records(:legally_owned)
@discarded_domain = whois_records(:discarded)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why WhoisRecord is assigned to a discarded_domain variable instead of whois_record? One can assume that he or she deals with a domain, whereas it is actually WHOIS-record.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because whois_record_for_discarded_domain feels too long.


def test_partial_name_for_private_person
assert_equal('private_person', @private_domain.partial_name)
assert_equal('private_person', @private_domain.partial_name(true))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using keyword argument here? I need to dig in into that method's definition to find out what does that true mean.

@@ -0,0 +1,57 @@
Domain:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a duplication between legal_person_for_authorized.json.jbuilder and legal_person.json.jbuilder. I see a clear pattern of undisclosed data ("Not Disclosed - Visit www.internet.ee for webbased WHOIS").

Perhaps we could unify those templates?

Copy link
Contributor Author

@maciej-szlosarczyk maciej-szlosarczyk May 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided against it since you end up with an if block, something I find rather unreadable in templates. I'd rather live with the repetition.

if @verified
  json.array!(whois_record.json['tech_contacts']) do |_contact|
    json.name 'Not Disclosed'
    json.email 'Not Disclosed'
    json.changed 'Not Disclosed'
  end
else
  json.array!(whois_record.json['admin_contacts']) do |_contact|
    json.name 'Not Disclosed - Visit www.internet.ee for webbased WHOIS'
    json.email 'Not Disclosed - Visit www.internet.ee for webbased WHOIS'
    json.changed 'Not Disclosed - Visit www.internet.ee for webbased WHOIS'
  end
end

I prefer having multiple templates to one that covers multiple, hence the design where WhoisRecord instance tells the controller which template to render, not the controller/template asking the WhoisRecord about its properties.

@artur-intech
Copy link
Contributor

artur-intech commented May 21, 2018

@vohmar We have discussed above mentioned issues with @maciej-szlosarczyk so you're free to merge it once tested. And the sooner the better, since there are other upcoming changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants