diff --git a/lib/whois/parsers/whois.joker.com.rb b/lib/whois/parsers/whois.joker.com.rb new file mode 100644 index 00000000..d81abd1d --- /dev/null +++ b/lib/whois/parsers/whois.joker.com.rb @@ -0,0 +1,56 @@ +#-- +# Ruby Whois +# +# An intelligent pure Ruby WHOIS client and parser. +# +# Copyright (c) 2009-2018 Simone Carletti +#++ + + +require_relative 'base_icann_compliant' + + +module Whois + class Parsers + + class WhoisJokerCom < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^NOT FOUND\n/ + } + + property_supported :registrant_contacts do + build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT) + end + + property_supported :admin_contacts do + build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE) + end + + property_supported :technical_contacts do + build_contact("Tech", Parser::Contact::TYPE_TECHNICAL) + end + + private + + def build_contact(element, type) + node("#{element} Name") do + Parser::Contact.new( + type: type, + id: node("Registry #{element} ID").presence, + name: value_for_property(element, 'Name'), + organization: value_for_property(element, 'Organization'), + address: value_for_property(element, 'Street'), + city: value_for_property(element, 'City'), + zip: value_for_property(element, 'Postal Code'), + state: value_for_property(element, 'State/Province'), + country_code: value_for_property(element, 'Country'), + phone: value_for_phone_property(element, 'Phone'), + fax: value_for_phone_property(element, 'Fax'), + email: value_for_property(element, 'Email') + ) + end + end + + end + end +end diff --git a/spec/fixtures/responses/whois.joker.com/status_available.expected b/spec/fixtures/responses/whois.joker.com/status_available.expected new file mode 100644 index 00000000..f0e6a67f --- /dev/null +++ b/spec/fixtures/responses/whois.joker.com/status_available.expected @@ -0,0 +1,42 @@ +#domain + %s == nil + +#domain_id + %s == nil + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + +#created_on + %s == nil + +#updated_on + %s == nil + +#expires_on + %s == nil + +#registrar + %s == nil + +#registrant_contacts + %s %CLASS{array} + %s == [] + +#admin_contacts + %s %CLASS{array} + %s == [] + +#technical_contacts + %s %CLASS{array} + %s == [] + +#nameservers + %s %CLASS{array} + %s == [] diff --git a/spec/fixtures/responses/whois.joker.com/status_available.txt b/spec/fixtures/responses/whois.joker.com/status_available.txt new file mode 100644 index 00000000..679aadb9 --- /dev/null +++ b/spec/fixtures/responses/whois.joker.com/status_available.txt @@ -0,0 +1 @@ +NOT FOUND diff --git a/spec/fixtures/responses/whois.joker.com/status_registered.expected b/spec/fixtures/responses/whois.joker.com/status_registered.expected new file mode 100644 index 00000000..bf2894e4 --- /dev/null +++ b/spec/fixtures/responses/whois.joker.com/status_registered.expected @@ -0,0 +1,91 @@ +#domain + %s == "domain.com" + +#domain_id + %s == "523683_DOMAIN_COM-VRSN" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{1994-11-27 00:00:00 UTC} + +#updated_on + %s %CLASS{time} + %s %TIME{2018-02-21 18:51:25 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2027-08-03 15:02:10 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "113" + %s.name == "CSL Computer Service Langenbach GmbH d/b/a joker.com" + %s.organization == "CSL Computer Service Langenbach GmbH d/b/a joker.com" + %s.url == "http://joker.com/" + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "Domain Administrator" + %s[0].organization == "CSL Computer Service Langenbach GmbH" + %s[0].address == "Hansaallee 191-193" + %s[0].city == "Duesseldorf" + %s[0].zip == "40549" + %s[0].state == "" + %s[0].country_code == "DE" + %s[0].phone == "+49.211867670" + %s[0].fax == "+49.2118676710" + %s[0].email == "admin@joker.com" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].name == "n/a" + %s[0].organization == "CSL Computer Service Langenbach GmbH" + %s[0].address == "Hansaallee 191-193" + %s[0].city == "Duesseldorf" + %s[0].zip == "40549" + %s[0].state == "" + %s[0].country_code == "DE" + %s[0].phone == "+49.211867670" + %s[0].fax == "" + %s[0].email == "admin@joker.com" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].name == "Domain Administrator" + %s[0].organization == "CSL Computer Service Langenbach GmbH" + %s[0].address == "Hansaallee 191-193" + %s[0].city == "Duesseldorf" + %s[0].zip == "40549" + %s[0].state == "NRW" + %s[0].country_code == "DE" + %s[0].phone == "+49.211867670" + %s[0].fax == "+49.2118676710" + %s[0].email == "hostmaster@joker.com" + +#nameservers + %s %CLASS{array} + %s %SIZE{3} + %s[0] %CLASS{nameserver} + %s[0].name == "j.ns.joker.com" + %s[1] %CLASS{nameserver} + %s[1].name == "k.ns.joker.com" + %s[2] %CLASS{nameserver} + %s[2].name == "l.ns.joker.com" diff --git a/spec/fixtures/responses/whois.joker.com/status_registered.txt b/spec/fixtures/responses/whois.joker.com/status_registered.txt new file mode 100644 index 00000000..a7e05940 --- /dev/null +++ b/spec/fixtures/responses/whois.joker.com/status_registered.txt @@ -0,0 +1,65 @@ +Domain Name: joker.com +Registry Domain ID: 523683_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.joker.com +Registrar URL: http://joker.com/ +Updated Date: 2018-02-21T18:51:25Z +Creation Date: 1994-11-27T00:00:00Z +Registrar Registration Expiration Date: 2027-08-03T15:02:10Z +Registrar: CSL Computer Service Langenbach GmbH d/b/a joker.com +Registrar IANA ID: 113 +Registrar Abuse Contact Email: abuse@joker.com +Registrar Abuse Contact Phone: +49.21186767447 +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Registry Registrant ID: +Registrant Name: Domain Administrator +Registrant Organization: CSL Computer Service Langenbach GmbH +Registrant Street: Hansaallee 191-193 +Registrant City: Duesseldorf +Registrant Postal Code: 40549 +Registrant Country: DE +Registrant Phone: +49.211867670 +Registrant Fax: +49.2118676710 +Registrant Email: admin@joker.com +Registry Admin ID: +Admin Name: n/a +Admin Organization: CSL Computer Service Langenbach GmbH +Admin Street: Hansaallee 191-193 +Admin City: Duesseldorf +Admin Postal Code: 40549 +Admin Country: DE +Admin Phone: +49.211867670 +Admin Email: admin@joker.com +Registry Tech ID: +Tech Name: Domain Administrator +Tech Organization: CSL Computer Service Langenbach GmbH +Tech Street: Hansaallee 191-193 +Tech City: Duesseldorf +Tech State/Province: NRW +Tech Postal Code: 40549 +Tech Country: DE +Tech Phone: +49.211867670 +Tech Fax: +49.2118676710 +Tech Email: hostmaster@joker.com +Name Server: j.ns.joker.com +Name Server: k.ns.joker.com +Name Server: l.ns.joker.com +DNSSEC: unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +>>> Last update of WHOIS database: 2018-05-03T10:01:07Z <<< + +Query Time: 0.085578 +Query Source: 82.99.18.126 +WHOIS Source: joker.com live whois service + + +For more information on Whois status codes, please visit https://icann.org/epp + +NOTE: By submitting a WHOIS query, you agree to abide by the following +NOTE: terms of use: You agree that you may use this data only for lawful +NOTE: purposes and that under no circumstances will you use this data to: +NOTE: (1) allow, enable, or otherwise support the transmission of mass +NOTE: unsolicited, commercial advertising or solicitations via direct mail, +NOTE: e-mail, telephone, or facsimile; or (2) enable high volume, automated, +NOTE: electronic processes that apply to Joker.com (or its computer systems). +NOTE: The compilation, repackaging, dissemination or other use of this data +NOTE: is expressly prohibited without the prior written consent of Joker.com. diff --git a/spec/whois/parsers/responses/whois.joker.com/status_available_spec.rb b/spec/whois/parsers/responses/whois.joker.com/status_available_spec.rb new file mode 100644 index 00000000..00960c2e --- /dev/null +++ b/spec/whois/parsers/responses/whois.joker.com/status_available_spec.rb @@ -0,0 +1,93 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.joker.com/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.joker.com.rb' + +describe Whois::Parsers::WhoisJokerCom, "status_available.expected" do + + subject do + file = fixture("responses", "whois.joker.com/status_available.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq(nil) + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq(nil) + end + end + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(true) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(false) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to eq(nil) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to eq(nil) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to eq(nil) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to eq(nil) + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts).to eq([]) + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts).to eq([]) + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts).to eq([]) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers).to eq([]) + end + end +end diff --git a/spec/whois/parsers/responses/whois.joker.com/status_registered_spec.rb b/spec/whois/parsers/responses/whois.joker.com/status_registered_spec.rb new file mode 100644 index 00000000..5ad91705 --- /dev/null +++ b/spec/whois/parsers/responses/whois.joker.com/status_registered_spec.rb @@ -0,0 +1,142 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.joker.com/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.joker.com.rb' + +describe Whois::Parsers::WhoisJokerCom, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.joker.com/status_registered.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq("joker.com") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("523683_DOMAIN_COM-VRSN") + end + end + describe "#status" do + it do + expect(subject.status).to eq(:registered) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(false) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(true) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to be_a(Time) + expect(subject.created_on).to eq(Time.parse("1994-11-27 00:00:00 UTC")) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to be_a(Time) + expect(subject.updated_on).to eq(Time.parse("2018-02-21 18:51:25 UTC")) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to be_a(Time) + expect(subject.expires_on).to eq(Time.parse("2027-08-03 15:02:10 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("113") + expect(subject.registrar.name).to eq("CSL Computer Service Langenbach GmbH d/b/a joker.com") + expect(subject.registrar.organization).to eq("CSL Computer Service Langenbach GmbH d/b/a joker.com") + expect(subject.registrar.url).to eq("http://joker.com/") + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts.size).to eq(1) + expect(subject.registrant_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.registrant_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_REGISTRANT) + expect(subject.registrant_contacts[0].name).to eq("Domain Administrator") + expect(subject.registrant_contacts[0].organization).to eq("CSL Computer Service Langenbach GmbH") + expect(subject.registrant_contacts[0].address).to eq("Hansaallee 191-193") + expect(subject.registrant_contacts[0].city).to eq("Duesseldorf") + expect(subject.registrant_contacts[0].zip).to eq("40549") + expect(subject.registrant_contacts[0].state).to eq("") + expect(subject.registrant_contacts[0].country_code).to eq("DE") + expect(subject.registrant_contacts[0].phone).to eq("+49.211867670") + expect(subject.registrant_contacts[0].fax).to eq("+49.2118676710") + expect(subject.registrant_contacts[0].email).to eq("admin@joker.com") + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts.size).to eq(1) + expect(subject.admin_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.admin_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_ADMINISTRATIVE) + expect(subject.admin_contacts[0].name).to eq("n/a") + expect(subject.admin_contacts[0].organization).to eq("CSL Computer Service Langenbach GmbH") + expect(subject.admin_contacts[0].address).to eq("Hansaallee 191-193") + expect(subject.admin_contacts[0].city).to eq("Duesseldorf") + expect(subject.admin_contacts[0].zip).to eq("40549") + expect(subject.admin_contacts[0].state).to eq("") + expect(subject.admin_contacts[0].country_code).to eq("DE") + expect(subject.admin_contacts[0].phone).to eq("+49.211867670") + expect(subject.admin_contacts[0].fax).to eq("") + expect(subject.admin_contacts[0].email).to eq("admin@joker.com") + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts.size).to eq(1) + expect(subject.technical_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.technical_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_TECHNICAL) + expect(subject.technical_contacts[0].name).to eq("Domain Administrator") + expect(subject.technical_contacts[0].organization).to eq("CSL Computer Service Langenbach GmbH") + expect(subject.technical_contacts[0].address).to eq("Hansaallee 191-193") + expect(subject.technical_contacts[0].city).to eq("Duesseldorf") + expect(subject.technical_contacts[0].zip).to eq("40549") + expect(subject.technical_contacts[0].state).to eq("NRW") + expect(subject.technical_contacts[0].country_code).to eq("DE") + expect(subject.technical_contacts[0].phone).to eq("+49.211867670") + expect(subject.technical_contacts[0].fax).to eq("+49.2118676710") + expect(subject.technical_contacts[0].email).to eq("hostmaster@joker.com") + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(3) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("j.ns.joker.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("k.ns.joker.com") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("l.ns.joker.com") + end + end +end