dnsimple-ruby 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c40f147d4747a607ca8ae3cfb8bb1f99830513d9
4
- data.tar.gz: 5d72dcfc3d7332887eec729b7d9122b51cc3fafb
3
+ metadata.gz: 42638c92a4155646824236ba7c5d871d0136cc3a
4
+ data.tar.gz: 9eebdc4564923bb72dcb799dd03742b624755114
5
5
  SHA512:
6
- metadata.gz: 268b16e76b613c51ba2da2f51c5955d54f3ca4437acfef0232a5b4718d69b805420a5dc9851ca4d72fff1e594c3c3c4d91abab15aea138ffbbafdab9c37e34be
7
- data.tar.gz: eb197c1b3b13de5a44075bba53585a2ed2c9cfb884cb63ba916b0cb7f52e14ed41aec1d1022b28a0c8c565ff5ff0178760fbe2102ab71934bbc39315c3e09538
6
+ metadata.gz: b9531a98f22ece8e9be835d779e59a71a461a3f4c13844b5a15096b25b2c8d8a178833cfc3e0b6f91e5ca95cf28cf9ef3ca52b9060636ed2c4168a88360c1a3a
7
+ data.tar.gz: e56b752ffa7824a98ba16b475d8293226475d5851e234c7c5ef3e82a902abccf26816f3d382c147b30fa031f1840e96e10667913718514fc23e2fa4e8682cb30
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ #### Release 1.7.0
4
+
5
+ - NEW: Add support for Domain-based authentication (GH-40, GH-46). Thanks @dwradcliffe and @samsonasu.
6
+
3
7
  #### Release 1.6.0
4
8
 
5
9
  - NEW: Add support for 2FA (GH-44)
@@ -7,6 +7,7 @@ module DNSimple
7
7
  DEFAULT_BASE_URI = "https://api.dnsimple.com/"
8
8
  HEADER_2FA_STRICT = "X-DNSimple-2FA-Strict"
9
9
  HEADER_API_TOKEN = "X-DNSimple-Token"
10
+ HEADER_DOMAIN_API_TOKEN = "X-DNSimple-Domain-Token"
10
11
  HEADER_OTP_TOKEN = "X-DNSimple-OTP"
11
12
  HEADER_EXCHANGE_TOKEN = "X-DNSimple-OTP-Token"
12
13
 
@@ -15,7 +16,7 @@ module DNSimple
15
16
  # Defaults to false.
16
17
  attr_accessor :debug
17
18
 
18
- attr_accessor :username, :password, :exchange_token, :api_token
19
+ attr_accessor :username, :password, :exchange_token, :api_token, :domain_api_token
19
20
  end
20
21
 
21
22
  # Gets the qualified API base uri.
@@ -51,6 +52,7 @@ module DNSimple
51
52
  self.password = credentials['password']
52
53
  self.exchange_token = credentials['exchange_token']
53
54
  self.api_token = credentials['api_token']
55
+ self.domain_api_token = credentials['domain_api_token']
54
56
  self.base_uri = credentials['site'] if credentials['site']
55
57
  self.base_uri = credentials['base_uri'] if credentials['base_uri']
56
58
  @http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] } if credentials['proxy_addr'] || credentials['proxy_port']
@@ -63,7 +65,7 @@ module DNSimple
63
65
  end
64
66
 
65
67
  def self.credentials_loaded?
66
- (@credentials_loaded ||= false) or (username and (password or api_token))
68
+ (@credentials_loaded ||= false) or domain_api_token or (username and (password or api_token))
67
69
  end
68
70
 
69
71
  def self.base_options
@@ -83,6 +85,8 @@ module DNSimple
83
85
  options[:basic_auth] = { :username => exchange_token, :password => "x-2fa-basic" }
84
86
  elsif password
85
87
  options[:basic_auth] = { :username => username, :password => password }
88
+ elsif domain_api_token
89
+ options[:headers][HEADER_DOMAIN_API_TOKEN] = domain_api_token
86
90
  elsif api_token
87
91
  options[:headers][HEADER_API_TOKEN] = "#{username}:#{api_token}"
88
92
  else
@@ -1,3 +1,3 @@
1
1
  module DNSimple
2
- VERSION = '1.6.0'
2
+ VERSION = '1.7.0'
3
3
  end
@@ -30,7 +30,7 @@ describe DNSimple::Client do
30
30
 
31
31
  describe ".request" do
32
32
  before do
33
- [:username, :password, :exchange_token, :api_token].each do |attribute|
33
+ [:username, :password, :exchange_token, :api_token, :domain_api_token].each do |attribute|
34
34
  described_class.send("#{attribute}=", nil)
35
35
  end
36
36
  end
@@ -47,6 +47,17 @@ describe DNSimple::Client do
47
47
  described_class.request(:get, '/domains', {})
48
48
  end
49
49
 
50
+ it "uses header authentication if there's a domain api token provided" do
51
+ described_class.domain_api_token = 'domaintoken'
52
+ described_class.base_uri = 'https://api.example.com/'
53
+
54
+ HTTParty.expects(:get).
55
+ with('https://api.example.com/domains', has_entries(:headers => has_entries({ 'X-DNSimple-Domain-Token' => 'domaintoken' }))).
56
+ returns(response)
57
+
58
+ described_class.request(:get, '/domains', {})
59
+ end
60
+
50
61
  it "uses header authentication if there's an api token provided" do
51
62
  described_class.username = 'user'
52
63
  described_class.api_token = 'token'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Eden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-20 00:00:00.000000000 Z
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty