fog-dnsimple 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Dnsimple
3
- VERSION = "0.0.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ def dns_providers
2
+ {
3
+ :dnsimple => {
4
+ :mocked => false
5
+ },
6
+ }
7
+ end
8
+
9
+ def generate_unique_domain( with_trailing_dot = false)
10
+ #get time (with 1/100th of sec accuracy)
11
+ #want unique domain name and if provider is fast, this can be called more than once per second
12
+ time= (Time.now.to_f * 100).to_i
13
+ domain = 'test-' + time.to_s + '.com'
14
+ if with_trailing_dot
15
+ domain+= '.'
16
+ end
17
+
18
+ domain
19
+ end
@@ -0,0 +1,41 @@
1
+ for provider, config in dns_providers
2
+
3
+ domain_name = uniq_id + '.com'
4
+
5
+ Shindo.tests("Fog::DNS[:#{provider}] | record", [provider.to_s]) do
6
+
7
+ a_record_attributes = {
8
+ :name => 'a.' + domain_name,
9
+ :type => 'A',
10
+ :value => '1.2.3.4'
11
+ }.merge!(config[:record_attributes] || {})
12
+
13
+ aaaa_record_attributes = {
14
+ :name => 'aaaa.' + domain_name,
15
+ :type => 'AAAA',
16
+ :value => '2001:0db8:0000:0000:0000:ff00:0042:8329'
17
+ }.merge!(config[:record_attributes] || {})
18
+
19
+ cname_record_attributes = {
20
+ :name => 'cname.' + domain_name,
21
+ :type => 'CNAME',
22
+ :value => 'real.' + domain_name
23
+ }.merge!(config[:record_attributes] || {})
24
+
25
+ if !Fog.mocking? || config[:mocked]
26
+ zone_attributes = {
27
+ :domain => domain_name
28
+ }.merge(config[:zone_attributes] || {})
29
+
30
+ @zone = Fog::DNS[provider].zones.create(zone_attributes)
31
+
32
+ model_tests(@zone.records, a_record_attributes, config[:mocked])
33
+ model_tests(@zone.records, aaaa_record_attributes, config[:mocked])
34
+ model_tests(@zone.records, cname_record_attributes, config[:mocked])
35
+
36
+ @zone.destroy
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,27 @@
1
+ for provider, config in dns_providers
2
+
3
+ domain_name = uniq_id + '.com'
4
+
5
+ Shindo.tests("Fog::DNS[:#{provider}] | records", [provider.to_s]) do
6
+
7
+ record_attributes = {
8
+ :name => 'www.' + domain_name,
9
+ :type => 'A',
10
+ :value => '1.2.3.4'
11
+ }.merge!(config[:record_attributes] || {})
12
+
13
+ if !Fog.mocking? || config[:mocked]
14
+ zone_attributes = {
15
+ :domain => domain_name
16
+ }.merge(config[:zone_attributes] || {})
17
+
18
+ @zone = Fog::DNS[provider].zones.create(zone_attributes)
19
+
20
+ collection_tests(@zone.records, record_attributes, config[:mocked])
21
+
22
+ @zone.destroy
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,15 @@
1
+ for provider, config in dns_providers
2
+
3
+ domain_name = uniq_id + '.com'
4
+
5
+ Shindo.tests("Fog::DNS[:#{provider}] | zone", [provider.to_s]) do
6
+
7
+ zone_attributes = {
8
+ :domain => domain_name
9
+ }.merge!(config[:zone_attributes] || {})
10
+
11
+ model_tests(Fog::DNS[provider].zones, zone_attributes, config[:mocked])
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ for provider, config in dns_providers
2
+
3
+ domain_name = uniq_id + '.com'
4
+
5
+ Shindo.tests("Fog::DNS[:#{provider}] | zones", [provider.to_s]) do
6
+
7
+ zone_attributes = {
8
+ :domain => domain_name
9
+ }.merge!(config[:zone_attributes] || {})
10
+
11
+ collection_tests(Fog::DNS[provider].zones, zone_attributes, config[:mocked])
12
+
13
+ end
14
+
15
+ end
data/tests/helper.rb ADDED
@@ -0,0 +1,11 @@
1
+ begin
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+ rescue LoadError => e
5
+ $stderr.puts "not recording test coverage: #{e.inspect}"
6
+ end
7
+
8
+ require 'fog/test_helpers'
9
+ require File.expand_path('../../lib/fog/dnsimple', __FILE__)
10
+
11
+ Excon.defaults.merge!(:debug_request => true, :debug_response => true)
@@ -0,0 +1,6 @@
1
+ Fog.mock! if ENV['FOG_MOCK'] == 'true'
2
+
3
+ if Fog.mock?
4
+ Fog.credentials = {
5
+ }.merge(Fog.credentials)
6
+ end
@@ -0,0 +1,122 @@
1
+ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
2
+
3
+ @domain = nil
4
+ @domain_count = 0
5
+
6
+ tests("success") do
7
+
8
+ test("get current domain count") do
9
+ response = Fog::DNS[:dnsimple].list_domains()
10
+ if response.status == 200
11
+ @domain_count = response.body.size
12
+ end
13
+
14
+ response.status == 200
15
+ end
16
+
17
+ test("create domain") do
18
+ domain = generate_unique_domain
19
+ response = Fog::DNS[:dnsimple].create_domain(domain)
20
+ if response.status == 201
21
+ @domain = response.body["domain"]
22
+ end
23
+
24
+ response.status == 201
25
+ end
26
+
27
+ test("get domain by id") do
28
+ response = Fog::DNS[:dnsimple].get_domain(@domain["id"])
29
+ response.status == 200
30
+ end
31
+
32
+ test("create an A resource record") do
33
+ domain = @domain["name"]
34
+ name = "www"
35
+ type = "A"
36
+ content = "1.2.3.4"
37
+ response = Fog::DNS[:dnsimple].create_record(domain, name, type, content)
38
+
39
+ if response.status == 201
40
+ @record = response.body["record"]
41
+ end
42
+
43
+ response.status == 201
44
+
45
+ end
46
+
47
+ test("create a MX record") do
48
+ domain = @domain["name"]
49
+ name = ""
50
+ type = "MX"
51
+ content = "mail.#{domain}"
52
+ options = { "ttl" => 60, "prio" => 10 }
53
+ response = Fog::DNS[:dnsimple].create_record(domain, name, type, content, options)
54
+
55
+ test "MX record creation returns 201" do
56
+ response.status == 201
57
+ end
58
+
59
+ options.each do |key, value|
60
+ test("MX record has option #{key}") { value == response.body["record"][key.to_s] }
61
+ end
62
+
63
+ test "MX record is correct type" do
64
+ response.body["record"]["record_type"] == "MX"
65
+ end
66
+ end
67
+
68
+ test("get a record") do
69
+ domain = @domain["name"]
70
+ record_id = @record["id"]
71
+
72
+ response = Fog::DNS[:dnsimple].get_record(domain, record_id)
73
+
74
+ (response.status == 200) and (@record == response.body["record"])
75
+ end
76
+
77
+ test("update a record") do
78
+ domain = @domain["name"]
79
+ record_id = @record["id"]
80
+ options = { "content" => "2.3.4.5", "ttl" => 600 }
81
+ response = Fog::DNS[:dnsimple].update_record(domain, record_id, options)
82
+ response.status == 200
83
+ end
84
+
85
+ test("list records") do
86
+ response = Fog::DNS[:dnsimple].list_records(@domain["name"])
87
+
88
+ if response.status == 200
89
+ @records = response.body
90
+ end
91
+
92
+ test "list records returns all records for domain" do
93
+ @records.reject { |record| record["record"]["system_record"] }.size == 2
94
+ end
95
+
96
+ response.status == 200
97
+ end
98
+
99
+ test("delete records") do
100
+ domain = @domain["name"]
101
+
102
+ result = true
103
+ @records.each do |record|
104
+ next if record["record"]["system_record"]
105
+ response = Fog::DNS[:dnsimple].delete_record(domain, record["record"]["id"])
106
+ if response.status != 200
107
+ result = false
108
+ break
109
+ end
110
+ end
111
+
112
+ result
113
+ end
114
+
115
+ test("delete domain") do
116
+ response = Fog::DNS[:dnsimple].delete_domain(@domain["name"])
117
+ response.status == 200
118
+ end
119
+
120
+ end
121
+
122
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-dnsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
@@ -9,8 +9,80 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-07-11 00:00:00.000000000 Z
12
- dependencies: []
13
- description: This is currently a stub. The full gem will be released soon.
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: shindo
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fog-core
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.38'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.38'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fog-json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ description: |-
84
+ This library can be used as a module for `fog` or as standalone provider
85
+ to use the DNSimple in applications.
14
86
  email:
15
87
  - weppos@weppos.net
16
88
  executables:
@@ -20,18 +92,41 @@ extensions: []
20
92
  extra_rdoc_files: []
21
93
  files:
22
94
  - ".gitignore"
23
- - ".rspec"
95
+ - ".ruby-gemset"
24
96
  - ".travis.yml"
25
- - CODE_OF_CONDUCT.md
97
+ - CHANGELOG.md
26
98
  - Gemfile
27
- - LICENSE.txt
99
+ - LICENSE.md
28
100
  - README.md
29
101
  - Rakefile
30
102
  - bin/console
31
103
  - bin/setup
32
104
  - fog-dnsimple.gemspec
105
+ - lib/fog/bin/dnsimple.rb
33
106
  - lib/fog/dnsimple.rb
107
+ - lib/fog/dnsimple/dns.rb
108
+ - lib/fog/dnsimple/models/dns/record.rb
109
+ - lib/fog/dnsimple/models/dns/records.rb
110
+ - lib/fog/dnsimple/models/dns/zone.rb
111
+ - lib/fog/dnsimple/models/dns/zones.rb
112
+ - lib/fog/dnsimple/requests/dns/create_domain.rb
113
+ - lib/fog/dnsimple/requests/dns/create_record.rb
114
+ - lib/fog/dnsimple/requests/dns/delete_domain.rb
115
+ - lib/fog/dnsimple/requests/dns/delete_record.rb
116
+ - lib/fog/dnsimple/requests/dns/get_domain.rb
117
+ - lib/fog/dnsimple/requests/dns/get_record.rb
118
+ - lib/fog/dnsimple/requests/dns/list_domains.rb
119
+ - lib/fog/dnsimple/requests/dns/list_records.rb
120
+ - lib/fog/dnsimple/requests/dns/update_record.rb
34
121
  - lib/fog/dnsimple/version.rb
122
+ - tests/dns/helper.rb
123
+ - tests/dns/models/record_tests.rb
124
+ - tests/dns/models/records_tests.rb
125
+ - tests/dns/models/zone_tests.rb
126
+ - tests/dns/models/zones_tests.rb
127
+ - tests/helper.rb
128
+ - tests/helpers/mock_helper.rb
129
+ - tests/requests/dns/dns_tests.rb
35
130
  homepage: https://github.com/fog/fog-dnsimple
36
131
  licenses:
37
132
  - MIT
@@ -57,4 +152,3 @@ signing_key:
57
152
  specification_version: 4
58
153
  summary: Module for the 'fog' gem to support DNSimple.
59
154
  test_files: []
60
- has_rdoc:
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/CODE_OF_CONDUCT.md DELETED
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at weppos@weppos.net. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/