ultradns-sdk 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/README.md +44 -0
- data/Rakefile +11 -0
- data/lib/ultradns.rb +11 -0
- data/lib/ultradns/api/account.rb +52 -0
- data/lib/ultradns/api/authentication.rb +107 -0
- data/lib/ultradns/api/client_accessor.rb +23 -0
- data/lib/ultradns/api/rrset.rb +112 -0
- data/lib/ultradns/api/zone.rb +137 -0
- data/lib/ultradns/client.rb +185 -0
- data/lib/ultradns/version.rb +9 -0
- data/test/fixtures/vcr_cassettes/test_account_related_apis.yml +166 -0
- data/test/fixtures/vcr_cassettes/test_auth.yml +166 -0
- data/test/fixtures/vcr_cassettes/test_auth_failure.yml +163 -0
- data/test/fixtures/vcr_cassettes/test_basic_client_apis.yml +124 -0
- data/test/fixtures/vcr_cassettes/test_tasks_list.yml +83 -0
- data/test/fixtures/vcr_cassettes/test_zone_apis.yml +124 -0
- data/test/fixtures/vcr_cassettes/test_zone_rrsets_apis.yml +546 -0
- data/test/test_authentication.rb +39 -0
- data/test/test_client_api.rb +131 -0
- data/test/test_helper.rb +54 -0
- data/ultradns-sdk.gemspec +32 -0
- metadata +191 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright 2000-2014 NeuStar, Inc. All rights reserved.
|
2
|
+
# NeuStar, the Neustar logo and related names and logos are registered
|
3
|
+
# trademarks, service marks or tradenames of NeuStar, Inc. All other
|
4
|
+
# product names, company names, marks, logos and symbols may be trademarks
|
5
|
+
# of their respective owners.
|
6
|
+
|
7
|
+
require_relative 'test_helper'
|
8
|
+
|
9
|
+
class TestAuthentication < Minitest::Unit::TestCase
|
10
|
+
include UltraDNSCredentials
|
11
|
+
|
12
|
+
TEST_ACCOUNT = ENV['ULTRA_ACCOUNT'] || "jdamick"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
setup_credentials
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_auth
|
19
|
+
VCR.use_cassette('test_auth') do
|
20
|
+
client = Ultradns::Client.new(@user, @pw)
|
21
|
+
|
22
|
+
pp client.account(TEST_ACCOUNT).zones
|
23
|
+
|
24
|
+
pp client.accounts
|
25
|
+
|
26
|
+
result = client.status
|
27
|
+
assert result['message'] != nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_auth_failure
|
32
|
+
VCR.use_cassette('test_auth_failure') do
|
33
|
+
client = Ultradns::Client.new(@user, @pw)
|
34
|
+
client.instance_eval { @auth[:access_token] = 'xx' }
|
35
|
+
response = client.status
|
36
|
+
assert response['message'] != nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# Copyright 2000-2014 NeuStar, Inc. All rights reserved.
|
2
|
+
# NeuStar, the Neustar logo and related names and logos are registered
|
3
|
+
# trademarks, service marks or tradenames of NeuStar, Inc. All other
|
4
|
+
# product names, company names, marks, logos and symbols may be trademarks
|
5
|
+
# of their respective owners.
|
6
|
+
|
7
|
+
require_relative 'test_helper'
|
8
|
+
|
9
|
+
class TestClientApi < Minitest::Unit::TestCase
|
10
|
+
include UltraDNSCredentials
|
11
|
+
|
12
|
+
TEST_ZONE = "ultra-rest-test.ultradnstest"
|
13
|
+
TEST_ACCOUNT = ENV['ULTRA_ACCOUNT'] || "jdamick"
|
14
|
+
|
15
|
+
def setup
|
16
|
+
setup_credentials
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_basic_client_apis
|
20
|
+
VCR.use_cassette('test_basic_client_apis') do
|
21
|
+
client = Ultradns::Client.new(@user, @pw)
|
22
|
+
|
23
|
+
result = client.status
|
24
|
+
assert result['message'] != nil
|
25
|
+
|
26
|
+
result = client.version
|
27
|
+
assert result['version'] != nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_tasks_list
|
32
|
+
VCR.use_cassette('test_tasks_list') do
|
33
|
+
client = Ultradns::Client.new(@user, @pw)
|
34
|
+
resp = client.tasks(q: {code: 'PENDING'})
|
35
|
+
assert_equal 70002, resp.first['errorCode']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_account_related_apis
|
40
|
+
VCR.use_cassette('test_account_related_apis') do
|
41
|
+
client = Ultradns::Client.new(@user, @pw)
|
42
|
+
|
43
|
+
resp = client.accounts
|
44
|
+
assert resp['resultInfo'] != nil
|
45
|
+
assert resp['accounts'] != nil
|
46
|
+
|
47
|
+
resp = client.account(TEST_ACCOUNT).zones
|
48
|
+
assert resp['zones'] != nil
|
49
|
+
|
50
|
+
resp = client.account(TEST_ACCOUNT).users
|
51
|
+
assert resp['users'].size > 0
|
52
|
+
assert resp['resultInfo']['totalCount'] != nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_zone_apis
|
57
|
+
VCR.use_cassette('test_zone_apis') do
|
58
|
+
client = Ultradns::Client.new(@user, @pw)
|
59
|
+
|
60
|
+
resp = client.zone('nexgen.neustar.biz').metadata
|
61
|
+
assert resp['properties'] != nil
|
62
|
+
|
63
|
+
resp = client.zone('nexgen.neustarr.biz').metadata
|
64
|
+
assert resp.first['errorCode'] != nil
|
65
|
+
assert_equal 404, resp.code
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_zone_rrsets_apis
|
70
|
+
VCR.use_cassette('test_zone_rrsets_apis') do
|
71
|
+
begin
|
72
|
+
client = Ultradns::Client.new(@user, @pw)
|
73
|
+
|
74
|
+
# create a test zone
|
75
|
+
resp = client.create_primary_zone(TEST_ACCOUNT, TEST_ZONE)
|
76
|
+
assert_equal 201, resp.code
|
77
|
+
|
78
|
+
resp = client.zone(TEST_ZONE).metadata
|
79
|
+
assert resp['properties'] != nil
|
80
|
+
assert resp['registrarInfo'] != nil
|
81
|
+
|
82
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something').create(60, ['192.168.1.1'])
|
83
|
+
assert_equal 201, resp.code
|
84
|
+
|
85
|
+
resp = client.zone(TEST_ZONE).rrsets
|
86
|
+
assert_equal TEST_ZONE, resp["zoneName"]
|
87
|
+
assert_equal 3, resp["resultInfo"]["totalCount"]
|
88
|
+
|
89
|
+
resp = client.zone(TEST_ZONE).rrsets('A')
|
90
|
+
assert_equal TEST_ZONE, resp["zoneName"]
|
91
|
+
assert_equal 1, resp["resultInfo"]["totalCount"]
|
92
|
+
assert_equal "A (1)", resp["rrSets"].first["rrtype"] # why both in 1 field?
|
93
|
+
assert_equal 60, resp["rrSets"].first["ttl"]
|
94
|
+
assert_equal "192.168.1.1", resp["rrSets"].first["rdata"].first
|
95
|
+
|
96
|
+
|
97
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE).list
|
98
|
+
assert_equal TEST_ZONE, resp["zoneName"]
|
99
|
+
assert resp["rrSets"] != nil
|
100
|
+
|
101
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE).update(30)
|
102
|
+
assert 200, resp.code # docs say 201, but it appears to give back 200..
|
103
|
+
|
104
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE).list
|
105
|
+
assert_equal 30, resp["rrSets"].first["ttl"]
|
106
|
+
|
107
|
+
# create a simple Traffic Controller Pool
|
108
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE)
|
109
|
+
.profile({
|
110
|
+
'@context' => 'http://schemas.ultradns.com/RDPool.jsonschema',
|
111
|
+
description: "Pooled Records Test",
|
112
|
+
order: "RANDOM"
|
113
|
+
})
|
114
|
+
|
115
|
+
assert_equal "Successful", resp['message']
|
116
|
+
|
117
|
+
# add another ip
|
118
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE).update(60, ['192.168.3.3'])
|
119
|
+
|
120
|
+
|
121
|
+
resp = client.zone(TEST_ZONE).rrset('A', 'something.' + TEST_ZONE).list
|
122
|
+
assert_equal "RANDOM", resp['rrSets'].first['profile']['order']
|
123
|
+
assert_equal 2, resp['rrSets'].first['rdata'].size
|
124
|
+
|
125
|
+
ensure
|
126
|
+
client.zone(TEST_ZONE).delete
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright 2000-2014 NeuStar, Inc. All rights reserved.
|
2
|
+
# NeuStar, the Neustar logo and related names and logos are registered
|
3
|
+
# trademarks, service marks or tradenames of NeuStar, Inc. All other
|
4
|
+
# product names, company names, marks, logos and symbols may be trademarks
|
5
|
+
# of their respective owners.
|
6
|
+
|
7
|
+
$:.unshift(File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__)))
|
8
|
+
|
9
|
+
require 'pp'
|
10
|
+
|
11
|
+
require 'simplecov'
|
12
|
+
SimpleCov.start do
|
13
|
+
use_merging true
|
14
|
+
command_name "MiniTest #{Time.now}"
|
15
|
+
add_group 'Service', 'service'
|
16
|
+
add_group 'Library', 'lib'
|
17
|
+
add_filter 'vendor' # Don't include vendored stuff
|
18
|
+
add_filter 'test' # Don't include test stuff
|
19
|
+
end
|
20
|
+
|
21
|
+
require "minitest/autorun"
|
22
|
+
require "mocha/mini_test"
|
23
|
+
require 'ultradns'
|
24
|
+
require 'vcr'
|
25
|
+
|
26
|
+
|
27
|
+
VCR.configure do |c|
|
28
|
+
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures', 'vcr_cassettes')
|
29
|
+
#c.hook_into :webmock # or :fakeweb
|
30
|
+
c.hook_into :fakeweb
|
31
|
+
c.filter_sensitive_data('SECRET') do |interaction|
|
32
|
+
#puts "interaction.request.body = #{interaction.request.body}"
|
33
|
+
interaction.request.body.match("password=(.*)&")[1] rescue nil # dont store the password
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
module UltraDNSCredentials
|
40
|
+
def setup_credentials
|
41
|
+
if ENV['RECORD']
|
42
|
+
@user = ENV['ULTRA_USER']
|
43
|
+
@pw = ENV['ULTRA_PW']
|
44
|
+
|
45
|
+
if @user == nil || @user == '' || @pw == nil || @pw == ''
|
46
|
+
puts "\n\n------------------------------------------------------------"
|
47
|
+
puts "ERROR - Please set ULTRA_USER & ULTRA_PW"
|
48
|
+
puts "Example: \nULTRA_USER=me ULTRA_PW=blah bundle exec rake test\n"
|
49
|
+
puts "------------------------------------------------------------\n\n"
|
50
|
+
raise "Invalid UltraDNS account user name or password"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ultradns/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ultradns-sdk"
|
8
|
+
spec.version = Ultradns::VERSION
|
9
|
+
spec.authors = ["ultradns"]
|
10
|
+
spec.email = ["ultrasupport@neustar.biz"]
|
11
|
+
spec.summary = %q{UltraDNS SDK for manipulating zones managed by UltraDNS}
|
12
|
+
spec.description = %q{Manipulate zones or add, update, remove records in UltraDNS}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "Apache 2.0"
|
15
|
+
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "httparty", "~> 0.13.1"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "mocha", "~> 1.1.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.4.0"
|
28
|
+
spec.add_development_dependency "simplecov", "~> 0.9.0"
|
29
|
+
spec.add_development_dependency "vcr", "~> 2.9.2"
|
30
|
+
spec.add_development_dependency "fakeweb", '>= 1.3.0'
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ultradns-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ultradns
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 5.4.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 5.4.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.9.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.9.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fakeweb
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.3.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.3.0
|
125
|
+
description: Manipulate zones or add, update, remove records in UltraDNS
|
126
|
+
email:
|
127
|
+
- ultrasupport@neustar.biz
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- lib/ultradns.rb
|
139
|
+
- lib/ultradns/api/account.rb
|
140
|
+
- lib/ultradns/api/authentication.rb
|
141
|
+
- lib/ultradns/api/client_accessor.rb
|
142
|
+
- lib/ultradns/api/rrset.rb
|
143
|
+
- lib/ultradns/api/zone.rb
|
144
|
+
- lib/ultradns/client.rb
|
145
|
+
- lib/ultradns/version.rb
|
146
|
+
- test/fixtures/vcr_cassettes/test_account_related_apis.yml
|
147
|
+
- test/fixtures/vcr_cassettes/test_auth.yml
|
148
|
+
- test/fixtures/vcr_cassettes/test_auth_failure.yml
|
149
|
+
- test/fixtures/vcr_cassettes/test_basic_client_apis.yml
|
150
|
+
- test/fixtures/vcr_cassettes/test_tasks_list.yml
|
151
|
+
- test/fixtures/vcr_cassettes/test_zone_apis.yml
|
152
|
+
- test/fixtures/vcr_cassettes/test_zone_rrsets_apis.yml
|
153
|
+
- test/test_authentication.rb
|
154
|
+
- test/test_client_api.rb
|
155
|
+
- test/test_helper.rb
|
156
|
+
- ultradns-sdk.gemspec
|
157
|
+
homepage: ''
|
158
|
+
licenses:
|
159
|
+
- Apache 2.0
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.2.2
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: UltraDNS SDK for manipulating zones managed by UltraDNS
|
181
|
+
test_files:
|
182
|
+
- test/fixtures/vcr_cassettes/test_account_related_apis.yml
|
183
|
+
- test/fixtures/vcr_cassettes/test_auth.yml
|
184
|
+
- test/fixtures/vcr_cassettes/test_auth_failure.yml
|
185
|
+
- test/fixtures/vcr_cassettes/test_basic_client_apis.yml
|
186
|
+
- test/fixtures/vcr_cassettes/test_tasks_list.yml
|
187
|
+
- test/fixtures/vcr_cassettes/test_zone_apis.yml
|
188
|
+
- test/fixtures/vcr_cassettes/test_zone_rrsets_apis.yml
|
189
|
+
- test/test_authentication.rb
|
190
|
+
- test/test_client_api.rb
|
191
|
+
- test/test_helper.rb
|