cps-client 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ ---
2
+ domain:
3
+ :regexp: !ruby/regexp /((([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)(com|de|net|org|biz|info|at|co\.at|or\.at|ru|pl|com\.pl|lv|ph|ie|ro|com\.ro|lu|fi|es|com\.es|to|ws|fm|ms|tc|vg|gs|name|([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)name|fr|com\.fr|jp|lt|fo|gr|se|no|hk|com\.hk|cn|hu|hr|cz|nl|dk|be|it|bz\.it|co\.uk|org\.uk|us|ag|com\.ag|net\.ag|org\.ag|cc|tv|bz|com\.bz|net\.bz|ch|li|am|hn|com\.hn|net\.hn|org\.hn|sc|vc|com\.vc|net\.vc|org\.vc|la|com\.cn|net\.cn|org\.cn|md|co\.za|ae|eu|ac|sh|io|mn|tw|mobi|im|aero|gd|mu|cx|travel|asia|com\.lc|net\.lc|org\.lc|co\.lc|lc|tk|me|in|tel))|(([0-9]\.)+((9\.4\.))e164\.arpa))/i
4
+ :min: 4
5
+ :max: 68
6
+ city:
7
+ :regexp: !ruby/regexp /[-A-Za-z0-9\.\, ]+/
8
+ :min: 1
9
+ :max: 50
10
+ contact_type:
11
+ :regexp: !ruby/regexp /(person|organisation)/
12
+ :min: 5
13
+ :max: 15
14
+ email:
15
+ :regexp: !ruby/regexp /[A-Za-z0-9\-\+\_]+(\.[A-Za-z0-9\-\+\_]+)*\@(([a-z0-9]([-a-z0-9]*[a-z0-9])?\.){1,4})([a-z]{2,6})/
16
+ :min: 8
17
+ :max: 100
18
+ fax:
19
+ :regexp: !ruby/regexp /\+[0-9]{1,3}[\. ]{1,1}[0-9]{3,17}/
20
+ :min: 4
21
+ :max: 20
22
+ firstname:
23
+ :regexp: !ruby/regexp /[-A-Za-z0-9\. ]+/
24
+ :min: 1
25
+ :max: 50
26
+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 postal:
43
+ :regexp: !ruby/regexp /[-A-Za-z0-9 ]+/
44
+ :min: 1
45
+ :max: 15
46
+ state:
47
+ :regexp: !ruby/regexp /[-A-Za-z0-9\.\, ]+/
48
+ :min: 1
49
+ :max: 50
50
+ street:
51
+ :regexp: !ruby/regexp /[-A-Za-z0-9\.\,\/ ]+/
52
+ :min: 1
53
+ :max: 100
54
+ reg_type:
55
+ :regexp: !ruby/regexp (transfer|owner_change)
56
+ :min: 8
57
+ :max: 12
58
+ auth_info:
59
+ :regexp: !ruby/regexp //
60
+ :min: 6
61
+ :max: 32
62
+ object:
63
+ :regexp: !ruby/regexp (([A-Z0-9]+)|(\%\%AUTO\%\%))
64
+ :min: 1
65
+ :max: 10
66
+ transfer_lock:
67
+ :regexp: !ruby/regexp (active|disabled)
68
+ :min: 6
69
+ :max: 8
70
+
@@ -1,8 +1,9 @@
1
1
  require 'cps-client/version'
2
- require 'cps-client/errors'
3
2
  require 'cps-client/config'
4
3
  require 'cps-client/erb_helper'
5
4
  require 'cps-client/client'
6
5
  require 'cps-client/contact'
7
6
  require 'cps-client/domain'
8
- require 'core_ext'
7
+ require 'cps-client/core_ext'
8
+ #require 'cps-client/validator'
9
+ #require 'cps-client/errors'
@@ -1,7 +1,7 @@
1
1
  require 'net/https'
2
2
  require 'uri'
3
3
  require 'rexml/document'
4
- require 'always_verify_ssl_certificates'
4
+ # require 'always_verify_ssl_certificates'
5
5
 
6
6
  module CPS
7
7
 
@@ -11,6 +11,9 @@ module CPS
11
11
  # The Integer maximum time to run a cps query, expressed in seconds.
12
12
  DEFAULT_TIMEOUT = 10
13
13
 
14
+ # crt file - deployed by puppet!
15
+ CA_FILE = '/etc/ssl/certs/bundle.crt'
16
+
14
17
  # Initializes a new <tt>Cps::Client</tt> with <tt>options</tt>.
15
18
  #
16
19
  # new(options = {})
@@ -49,6 +52,14 @@ module CPS
49
52
  @data = ""
50
53
  end
51
54
 
55
+ #
56
+ # ==== Returns
57
+ #
58
+ # true: if the call was successful
59
+ # false: if the call failed
60
+ #
61
+ #
62
+ #
52
63
  def query( object )
53
64
  # AlwaysVerifySSLCertificates.ca_file = CA_FILE
54
65
  url = @production == true ? URL_PRD : URL_DEV
@@ -61,7 +72,7 @@ module CPS
61
72
  req = Net::HTTP::Post.new( PATH )
62
73
  @response, @data = http.request(req, @request)
63
74
  self.result_code == '1000' ? true : false
64
- rescue
75
+ rescue # OpenSSL::SSL::SSLError
65
76
  false
66
77
  end
67
78
 
@@ -7,17 +7,17 @@ module CPS
7
7
 
8
8
  def initialize(options = {})
9
9
  @object = options[:object].upcase
10
- @firstname = options[:firstname].to_iso_8859_1
11
- @lastname = options[:lastname].to_iso_8859_1
12
- @orgname = options[:orgname].nil? || options[:orgname] == "" ? "-" : options[:orgname].to_iso_8859_1
13
- @street = options[:street].to_iso_8859_1
14
- @postal = options[:postal].to_iso_8859_1
15
- @city = options[:city].to_iso_8859_1
16
- @state = options[:state].to_iso_8859_1
17
- @iso_country = options[:iso_country].to_iso_8859_1
18
- @phone = options[:phone].to_iso_8859_1
19
- @fax = options[:fax].to_iso_8859_1
20
- @email = options[:email].to_punycode
10
+ @firstname = options[:firstname].to_iso_8859_1 rescue nil
11
+ @lastname = options[:lastname].to_iso_8859_1 rescue nil
12
+ @orgname = options[:orgname].nil? || options[:orgname] == "" ? "-" : options[:orgname].to_iso_8859_1 rescue nil
13
+ @street = options[:street].to_iso_8859_1 rescue nil
14
+ @postal = options[:postal].to_iso_8859_1 rescue nil
15
+ @city = options[:city].to_iso_8859_1 rescue nil
16
+ @state = options[:state].to_iso_8859_1 rescue nil
17
+ @iso_country = options[:iso_country].to_iso_8859_1 rescue nil
18
+ @phone = options[:phone].to_iso_8859_1 rescue nil
19
+ @fax = options[:fax].to_iso_8859_1 rescue nil
20
+ @email = options[:email].to_punycode rescue nil
21
21
  @privacy_rule = options[:privacy_rule] || ""
22
22
  @contact_type = @orgname == '-' ? "person" : "organisation"
23
23
  end
@@ -29,6 +29,10 @@ module CPS
29
29
  def create
30
30
  ErbHelper.build("contact_create", self)
31
31
  end
32
+
33
+ def replace
34
+ ErbHelper.build("contact_replace", self)
35
+ end
32
36
 
33
37
  def delete
34
38
  ErbHelper.build("contact_delete", self)
@@ -3,7 +3,7 @@ require 'punycode'
3
3
  require 'domainatrix'
4
4
 
5
5
  class String
6
-
6
+
7
7
  CONVERTION_TABLE = {
8
8
  'Ç' => 'C',
9
9
  'ç' => 'c',
@@ -41,7 +41,7 @@ class String
41
41
  'ñ' => 'n',
42
42
  'Ñ' => 'N'
43
43
  }
44
-
44
+
45
45
  def i18n_safe
46
46
  s = self
47
47
  return "" unless s
@@ -50,7 +50,7 @@ class String
50
50
  end
51
51
  return s
52
52
  end
53
-
53
+
54
54
  def to_punycode
55
55
  result = self
56
56
  if self.match(/@/)
@@ -63,22 +63,23 @@ class String
63
63
  end
64
64
  return result
65
65
  end
66
-
66
+
67
67
  def to_iso_8859_1
68
+ i = nil
68
69
  begin
69
70
  i = Iconv.new('ISO-8859-1', 'UTF-8') # Iconv.new(to, from)
70
71
  i.iconv(self.i18n_safe)
71
72
  rescue
72
73
  self
73
74
  ensure
74
- i.close
75
+ i.close unless i.nil?
75
76
  end
76
77
  end
77
-
78
+
78
79
  def blank?
79
80
  self.nil? || self == ""
80
81
  end
81
-
82
+
82
83
  def domain_to_punycode
83
84
  p = Punycode.encode(self)
84
85
  unless p.match(/-$/)
@@ -87,5 +88,5 @@ class String
87
88
  p.sub(/-$/, "")
88
89
  end
89
90
  end
90
-
91
+
91
92
  end
@@ -4,13 +4,17 @@ module CPS
4
4
  attr_reader :domain
5
5
 
6
6
  def initialize(options = {})
7
- @domain = options[:domain].downcase.to_punycode
8
- @adminc = options[:adminc]
9
- @techc = options[:techc]
10
- @billc = options[:billc]
11
- @ownerc = options[:ownerc]
12
- @ns1 = options[:ns1]
13
- @ns2 = options[:ns2]
7
+ @domain = options[:domain].downcase.to_punycode
8
+ @adminc = options[:adminc]
9
+ @techc = options[:techc]
10
+ @billc = options[:billc]
11
+ @ownerc = options[:ownerc]
12
+ @ns1 = options[:ns1]
13
+ @ns2 = options[:ns2]
14
+ @reg_type = options[:reg_type] ||= 'transfer'
15
+ @auth_info = options[:auth_info] ||= ''
16
+ @attribute = options[:attribute] ||= 'domain'
17
+ @transfer_lock = options[:transfer_lock] ||= 'active' # active|disabled
14
18
  end
15
19
 
16
20
  def create
@@ -21,6 +25,18 @@ module CPS
21
25
  ErbHelper.build("domain_info", self)
22
26
  end
23
27
 
28
+ def transfer
29
+ ErbHelper.build("domain_transfer", self)
30
+ end
31
+
32
+ def transfer_lock
33
+ ErbHelper.build("domain_transfer_lock", self)
34
+ end
35
+
36
+ def modify
37
+ ErbHelper.build("domain_modify", self)
38
+ end
39
+
24
40
  def delete
25
41
  ErbHelper.build("domain_delete", self)
26
42
  end
@@ -0,0 +1,39 @@
1
+ module CPS
2
+
3
+ # CPS::Validator.load
4
+ # d = CPS::Validator.find(:domain)
5
+ # d.name => :domain
6
+ # d.valid?("qutic.com") => true
7
+
8
+ class Validator < Struct.new(:name, :regexp, :min, :max)
9
+ cattr_accessor :all
10
+
11
+ def self.load
12
+ return @@all if @@all.present?
13
+
14
+ data_file = File.join(File.dirname(__FILE__), '..', '..', 'data', 'validation.yml')
15
+
16
+ @@all = {}
17
+ YAML.load(File.read(data_file)).each_pair do |key, c|
18
+ @@all[key.to_sym] = Validator.new(key.to_sym, c[:regexp], c[:min], c[:max])
19
+ end
20
+ @@all
21
+ end
22
+
23
+ def self.find(key)
24
+ @@all[key]
25
+ end
26
+
27
+ def to_s
28
+ name.to_s
29
+ end
30
+
31
+ def valid?(value)
32
+ !value.nil? &&
33
+ value.length >= self.min &&
34
+ value.length <= self.max &&
35
+ !regexp.match(value).nil?
36
+ end
37
+ end
38
+
39
+ end
@@ -7,7 +7,7 @@ module CPS
7
7
  module Version
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- PATCH = 4
10
+ PATCH = 6
11
11
  BUILD = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
@@ -0,0 +1,6 @@
1
+ <group>contact</group>
2
+ <action>modify</action>
3
+ <attribute>replacement</attribute>
4
+ <object><%= @object %></object>
5
+ <customer_ref></customer_ref>
6
+ <values></values>
@@ -0,0 +1,17 @@
1
+ <group>domain</group>
2
+ <action>modify</action>
3
+ <attribute>domain</attribute>
4
+ <object><%= @domain %></object>
5
+ <values>
6
+ <adminc><%= @adminc %></adminc>
7
+ <techc><%= @techc %></techc>
8
+ <billc><%= @billc %></billc>
9
+ <ownerc><%= @ownerc %></ownerc>
10
+ <dns>
11
+ <hostname><%= @ns1 %></hostname>
12
+ </dns>
13
+ <dns>
14
+ <hostname><%= @ns2 %></hostname>
15
+ </dns>
16
+ <auth_info><%= @auth_info %></auth_info>
17
+ </values>
@@ -0,0 +1,17 @@
1
+ <group>domain</group>
2
+ <action>transfer</action>
3
+ <attribute>domain</attribute>
4
+ <object><%= @domain %></object>
5
+ <values>
6
+ <adminc><%= @adminc %></adminc>
7
+ <techc><%= @techc %></techc>
8
+ <billc><%= @billc %></billc>
9
+ <ownerc><%= @ownerc %></ownerc>
10
+ <dns>
11
+ <hostname><%= @ns1 %></hostname>
12
+ </dns>
13
+ <dns>
14
+ <hostname><%= @ns2 %></hostname>
15
+ </dns>
16
+ <auth_info><%= @auth_info %></auth_info>
17
+ </values>
@@ -0,0 +1,7 @@
1
+ <group>domain</group>
2
+ <action>modify</action>
3
+ <attribute>transfer_lock</attribute>
4
+ <object><%= @domain %></object>
5
+ <values>
6
+ <status><%= @transfer_lock %></status>
7
+ </values>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cps-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - jfqd
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-01 00:00:00 +02:00
18
+ date: 2011-06-29 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,23 +83,30 @@ files:
83
83
  - Rakefile
84
84
  - Readme.textile
85
85
  - cps-client.gemspec
86
- - lib/core_ext.rb
86
+ - data/bundle.crt
87
+ - data/validation.yml
87
88
  - lib/cps-client.rb
88
89
  - lib/cps-client/client.rb
89
90
  - lib/cps-client/config.rb
90
91
  - lib/cps-client/contact.rb
92
+ - lib/cps-client/core_ext.rb
91
93
  - lib/cps-client/domain.rb
92
94
  - lib/cps-client/erb_helper.rb
93
95
  - lib/cps-client/errors.rb
96
+ - lib/cps-client/validator.rb
94
97
  - lib/cps-client/version.rb
95
98
  - lib/erb/base.erb
96
99
  - lib/erb/contact_create.erb
97
100
  - lib/erb/contact_delete.erb
98
101
  - lib/erb/contact_domain.erb
99
102
  - lib/erb/contact_info.erb
103
+ - lib/erb/contact_replace.erb
100
104
  - lib/erb/domain_create.erb
101
105
  - lib/erb/domain_delete.erb
102
106
  - lib/erb/domain_info.erb
107
+ - lib/erb/domain_modify.erb
108
+ - lib/erb/domain_transfer.erb
109
+ - lib/erb/domain_transfer_lock.erb
103
110
  - test.rb
104
111
  has_rdoc: true
105
112
  homepage: https://github.com/jfqd/cps-client