dynectastic 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +24 -0
- data/CHANGES.rdoc +9 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +14 -0
- data/LICENSE +20 -0
- data/README.rdoc +120 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/dynectastic.gemspec +85 -0
- data/lib/dynectastic.rb +26 -0
- data/lib/dynectastic/error_translator.rb +22 -0
- data/lib/dynectastic/errors.rb +33 -0
- data/lib/dynectastic/factories/node_factory.rb +15 -0
- data/lib/dynectastic/factories/record_factory.rb +51 -0
- data/lib/dynectastic/factories/zone_factory.rb +58 -0
- data/lib/dynectastic/job.rb +23 -0
- data/lib/dynectastic/record.rb +32 -0
- data/lib/dynectastic/request.rb +114 -0
- data/lib/dynectastic/resource.rb +44 -0
- data/lib/dynectastic/session.rb +37 -0
- data/lib/dynectastic/zone.rb +56 -0
- data/test/helper.rb +14 -0
- data/test/test_node_factory.rb +35 -0
- data/test/test_record.rb +57 -0
- data/test/test_record_factory.rb +68 -0
- data/test/test_request.rb +64 -0
- data/test/test_resource.rb +26 -0
- data/test/test_session.rb +21 -0
- data/test/test_zone.rb +73 -0
- data/test/test_zone_factory.rb +41 -0
- metadata +135 -0
data/test/test_record.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRecord < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Record" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@dynect = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@zone = @dynect.zones.build(
|
10
|
+
:name => "dynectastictests.com",
|
11
|
+
:contact => "ilya@wildbit.com",
|
12
|
+
:ttl => 1800
|
13
|
+
)
|
14
|
+
@zone.save
|
15
|
+
|
16
|
+
@record = @dynect.records.cname.build(
|
17
|
+
:zone => "dynectastictests.com",
|
18
|
+
:node => "new_node.dynectastictests.com",
|
19
|
+
:ttl => 0,
|
20
|
+
:rdata => { :cname => "something.dynectastictests.com" }
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
context "creating" do
|
25
|
+
|
26
|
+
should "save" do
|
27
|
+
assert @record.save
|
28
|
+
end
|
29
|
+
|
30
|
+
teardown do
|
31
|
+
@zone.destroy
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "updating" do
|
37
|
+
|
38
|
+
setup do
|
39
|
+
@record.save
|
40
|
+
@zone.publish
|
41
|
+
end
|
42
|
+
|
43
|
+
teardown do
|
44
|
+
@zone.destroy
|
45
|
+
end
|
46
|
+
|
47
|
+
should "change rdata" do
|
48
|
+
@record.rdata['cname'] = "something_else.dynectastictests.com"
|
49
|
+
assert @record.save
|
50
|
+
assert_equal "something_else.dynectastictests.com.", @record.rdata['cname']
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRecordFactory < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "RecordFactory" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@dynect = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@zone = @dynect.zones.build(
|
10
|
+
:name => "dynectastictests.com",
|
11
|
+
:contact => "ilya@wildbit.com",
|
12
|
+
:ttl => 1800
|
13
|
+
)
|
14
|
+
@zone.save
|
15
|
+
|
16
|
+
@record = @dynect.records.cname.build(
|
17
|
+
:zone => "dynectastictests.com",
|
18
|
+
:node => "ilya.dynectastictests.com",
|
19
|
+
:ttl => 0,
|
20
|
+
:rdata => { :cname => "something.dynectastictests.com" }
|
21
|
+
)
|
22
|
+
@record.save
|
23
|
+
end
|
24
|
+
|
25
|
+
teardown do
|
26
|
+
@zone.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
should "build new record" do
|
30
|
+
record = @dynect.records.cname.build(
|
31
|
+
:zone => "dynectastictests.com",
|
32
|
+
:node => "ilya.dynectastictests.com",
|
33
|
+
:ttl => 0,
|
34
|
+
:rdata => { :cname => "something.dynectastictests.com" }
|
35
|
+
)
|
36
|
+
assert record
|
37
|
+
end
|
38
|
+
|
39
|
+
should "find record by ID" do
|
40
|
+
record = @dynect.records.cname.find_by_id(0, :zone => "dynectastictests.com", :node => "ilya.dynectastictests.com")
|
41
|
+
assert record
|
42
|
+
end
|
43
|
+
|
44
|
+
should "find all existing records" do
|
45
|
+
records = @dynect.records.cname.find_all(:zone => "dynectastictests.com", :node => "ilya.dynectastictests.com")
|
46
|
+
assert records.size == 1
|
47
|
+
end
|
48
|
+
|
49
|
+
should "set record types properly" do
|
50
|
+
assert "AAAA", @dynect.records.aaaa.record_type
|
51
|
+
assert "A", @dynect.records.a.record_type
|
52
|
+
assert "CNAME", @dynect.records.cname.record_type
|
53
|
+
assert "DNSKEY", @dynect.records.dnskey.record_type
|
54
|
+
assert "DS", @dynect.records.ds.record_type
|
55
|
+
assert "KEY", @dynect.records.key.record_type
|
56
|
+
assert "LOC", @dynect.records.loc.record_type
|
57
|
+
assert "MX", @dynect.records.mx.record_type
|
58
|
+
assert "NS", @dynect.records.ns.record_type
|
59
|
+
assert "PTR", @dynect.records.ptr.record_type
|
60
|
+
assert "RP", @dynect.records.rp.record_type
|
61
|
+
assert "SOA", @dynect.records.soa.record_type
|
62
|
+
assert "SRV", @dynect.records.srv.record_type
|
63
|
+
assert "TXT", @dynect.records.txt.record_type
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRequest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Request" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@session = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@zone = @session.zones.build(
|
10
|
+
:name => "dynectastictests.com",
|
11
|
+
:contact => "ilya@wildbit.com",
|
12
|
+
:ttl => 0
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "complete request" do
|
17
|
+
|
18
|
+
should "memorize job_id" do
|
19
|
+
assert @session.last_request.job_id.kind_of?(Numeric)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "memorize response" do
|
23
|
+
assert @session.last_request.response
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "incomplete long-running request" do
|
29
|
+
|
30
|
+
setup do
|
31
|
+
@long_running = resource = Dynectastic::Resource.new(@session)
|
32
|
+
@request_result = @long_running.post('/REST/QPSReport/', :body => {
|
33
|
+
:start_ts => (Time.now - 1296000).to_i,
|
34
|
+
:end_ts => (Time.now + 1296000).to_i
|
35
|
+
})
|
36
|
+
end
|
37
|
+
|
38
|
+
should "return false" do
|
39
|
+
assert_equal false, @request_result
|
40
|
+
end
|
41
|
+
|
42
|
+
should "flag resource with job_incomplete" do
|
43
|
+
assert @long_running.last_request.job.incomplete?
|
44
|
+
end
|
45
|
+
|
46
|
+
should "memorize job_id" do
|
47
|
+
assert @long_running.last_request.job.id.kind_of?(Numeric)
|
48
|
+
end
|
49
|
+
|
50
|
+
should "memorize response" do
|
51
|
+
assert @long_running.last_request.response
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
should "raise DynectError when request failed" do
|
57
|
+
end
|
58
|
+
|
59
|
+
should "retry request X times when session is busy" do
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestResource < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Resource" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@dynect = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@zone = @dynect.zones.build(
|
10
|
+
:name => "dynectastictests.com",
|
11
|
+
:contact => "ilya@wildbit.com",
|
12
|
+
:ttl => 0
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
should "not have any info about last request by default" do
|
17
|
+
assert_nil @zone.last_request
|
18
|
+
end
|
19
|
+
|
20
|
+
should "should memorize last request" do
|
21
|
+
assert @dynect.last_request.kind_of?(Dynectastic::Request)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestSession < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Session" do
|
6
|
+
|
7
|
+
should "create" do
|
8
|
+
session = Dynectastic::Session.new(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
assert session
|
10
|
+
assert session.token.kind_of? String
|
11
|
+
end
|
12
|
+
|
13
|
+
should "raise proper exception when authentication fails" do
|
14
|
+
assert_raises Dynectastic::AuthenticationError do
|
15
|
+
Dynectastic::Session.new("bla", "ble", "blu")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/test_zone.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestZone < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Zone" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@dynect = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@zone = @dynect.zones.build(
|
10
|
+
:name => "dynectastictests.com",
|
11
|
+
:contact => "ilya@wildbit.com",
|
12
|
+
:ttl => 0
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "creating" do
|
17
|
+
|
18
|
+
should "save" do
|
19
|
+
assert @zone.save
|
20
|
+
end
|
21
|
+
|
22
|
+
teardown do
|
23
|
+
@zone.destroy
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "updating" do
|
29
|
+
|
30
|
+
setup do
|
31
|
+
@zone.save
|
32
|
+
end
|
33
|
+
|
34
|
+
teardown do
|
35
|
+
@zone.destroy
|
36
|
+
end
|
37
|
+
|
38
|
+
should "publish" do
|
39
|
+
assert_nil @zone.published?
|
40
|
+
assert @zone.publish
|
41
|
+
assert @zone.published?
|
42
|
+
end
|
43
|
+
|
44
|
+
should "freeze" do
|
45
|
+
assert_nil @zone.frozen?
|
46
|
+
assert @zone.freeze
|
47
|
+
assert @zone.frozen?
|
48
|
+
end
|
49
|
+
|
50
|
+
should "unfreeze" do
|
51
|
+
@zone.freeze
|
52
|
+
assert @zone.frozen?
|
53
|
+
assert @zone.unfreeze
|
54
|
+
assert_equal false, @zone.frozen?
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "deleting" do
|
60
|
+
|
61
|
+
setup do
|
62
|
+
@zone.save
|
63
|
+
end
|
64
|
+
|
65
|
+
should "destroy" do
|
66
|
+
assert @zone.destroy
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestZoneFactory < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "ZoneFactory" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@dynect = Dynectastic.session(DYNECT_CUST_NAME, DYNECT_USER_NAME, DYNECT_USER_PASS)
|
9
|
+
@factory = @dynect.zones
|
10
|
+
@zone = @factory.build(
|
11
|
+
:name => "dynectastictests.com",
|
12
|
+
:contact => "ilya@wildbit.com",
|
13
|
+
:ttl => 1800
|
14
|
+
)
|
15
|
+
@zone.save
|
16
|
+
end
|
17
|
+
|
18
|
+
teardown do
|
19
|
+
@zone.destroy
|
20
|
+
end
|
21
|
+
|
22
|
+
should "build new zone" do
|
23
|
+
zone = @factory.build(:name => "new_zone.name", :contact => "ilya@wildbit.com", :ttl => 1800)
|
24
|
+
assert_equal "ilya@wildbit.com", zone.contact
|
25
|
+
assert_equal 1800, zone.ttl
|
26
|
+
assert_equal "new_zone.name", zone.name
|
27
|
+
end
|
28
|
+
|
29
|
+
should "find zone by name" do
|
30
|
+
zone = @factory.find_by_name("dynectastictests.com")
|
31
|
+
assert_equal "dynectastictests.com", zone.name
|
32
|
+
end
|
33
|
+
|
34
|
+
should "find all existing zones" do
|
35
|
+
zones = @factory.find_all
|
36
|
+
assert zones.find{|z| z.name == 'dynectastictests.com'}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynectastic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ilya Sabanin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-01 00:00:00 +07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: httparty
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 6
|
33
|
+
- 1
|
34
|
+
version: 0.6.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: shoulda
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
description: More or less complete set of tools for managing your Dynect zones, records and nodes via REST API.
|
52
|
+
email: ilya.sabanin@gmail.com
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- LICENSE
|
59
|
+
- README.rdoc
|
60
|
+
files:
|
61
|
+
- .document
|
62
|
+
- .gitignore
|
63
|
+
- CHANGES.rdoc
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- README.rdoc
|
68
|
+
- Rakefile
|
69
|
+
- VERSION
|
70
|
+
- dynectastic.gemspec
|
71
|
+
- lib/dynectastic.rb
|
72
|
+
- lib/dynectastic/error_translator.rb
|
73
|
+
- lib/dynectastic/errors.rb
|
74
|
+
- lib/dynectastic/factories/node_factory.rb
|
75
|
+
- lib/dynectastic/factories/record_factory.rb
|
76
|
+
- lib/dynectastic/factories/zone_factory.rb
|
77
|
+
- lib/dynectastic/job.rb
|
78
|
+
- lib/dynectastic/record.rb
|
79
|
+
- lib/dynectastic/request.rb
|
80
|
+
- lib/dynectastic/resource.rb
|
81
|
+
- lib/dynectastic/session.rb
|
82
|
+
- lib/dynectastic/zone.rb
|
83
|
+
- test/helper.rb
|
84
|
+
- test/test_node_factory.rb
|
85
|
+
- test/test_record.rb
|
86
|
+
- test/test_record_factory.rb
|
87
|
+
- test/test_request.rb
|
88
|
+
- test/test_resource.rb
|
89
|
+
- test/test_session.rb
|
90
|
+
- test/test_zone.rb
|
91
|
+
- test/test_zone_factory.rb
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/iSabanin/dynectastic
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --charset=UTF-8
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Neat wrapper for Dynect REST API.
|
126
|
+
test_files:
|
127
|
+
- test/helper.rb
|
128
|
+
- test/test_node_factory.rb
|
129
|
+
- test/test_record.rb
|
130
|
+
- test/test_record_factory.rb
|
131
|
+
- test/test_request.rb
|
132
|
+
- test/test_resource.rb
|
133
|
+
- test/test_session.rb
|
134
|
+
- test/test_zone.rb
|
135
|
+
- test/test_zone_factory.rb
|