etcdv3 0.3.1 → 0.3.2

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: 79843ce217e4f7209283fe46c64022d31e491586
4
- data.tar.gz: 48d9410cc3f1e104b30807476156d65ee09c610b
3
+ metadata.gz: 443472175a4cc4232c56f54afac01f0ca3bd1ae8
4
+ data.tar.gz: 3e5a3264ddb63003b330133e1e2ed0bc4b51716e
5
5
  SHA512:
6
- metadata.gz: 2c3f62df6f498ae227744f16eccd24de9939a6e4604dbcbb800b9befabdb45110ca6ae37777bafeb93e09237d29082a6f38a029f6b74e7b525b14bbc58919195
7
- data.tar.gz: 1098a189e5b130f365090c1eea96869e2f735c77f6129f821c101077036fe95ce4e25d6f627bf5857ca28efad66a0288e62dcf79d812b79d8a8bbd45eb5ff42d
6
+ metadata.gz: 9d87445129496ab8919e580b652818a4f136f552e84215812a3a31348ae54f0eabe209bc09ce7a677fa9d8bb590e2c7657c324fb17158a1c84c950c55208bad2
7
+ data.tar.gz: bb48f8937f5edcaf62231a1ed46c17af1c1a1f5a95735b3db100660d3b93450850bebada9830ea75cc51ba5ca3e1c67220d5d3341ed4d6ce3cc1782d59ae5ea6
data/README.md CHANGED
@@ -47,7 +47,7 @@ conn = Etcdv3.new(url: 'https://hostname:port', user: "gary", password: "secret"
47
47
  conn.del('my')
48
48
 
49
49
  # Delete Key Range
50
- conn.del('my', 'myyy')
50
+ conn.del('my', range_end: 'myyy')
51
51
  ```
52
52
 
53
53
  **User Management**
@@ -1,3 +1,3 @@
1
1
  class Etcdv3
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
data/lib/etcdv3.rb CHANGED
@@ -46,7 +46,7 @@ class Etcdv3
46
46
  @options = options
47
47
  @credentials = resolve_credentials
48
48
  @metadata = {}
49
- @metadata[:token] = auth.generate_token(user, password) unless user.nil?
49
+ @metadata[:token] = generate_token(user, password) unless user.nil?
50
50
  @metacache = set_metacache
51
51
  end
52
52
 
@@ -202,7 +202,7 @@ class Etcdv3
202
202
  # Authenticate using specified user and password.
203
203
  # On successful authentication, an auth token will be assigned to the instance.
204
204
  def authenticate(user, password)
205
- token = request.handle(:auth, 'generate_token', [user, password])
205
+ token = generate_token(user, password)
206
206
  return false unless token
207
207
  @metadata[:token] = token
208
208
  @options[:user] = user
@@ -225,6 +225,10 @@ class Etcdv3
225
225
  Base64.strict_encode64(@metadata.to_s)
226
226
  end
227
227
 
228
+ def generate_token(user, password)
229
+ request.handle(:auth, 'generate_token', [user, password])
230
+ end
231
+
228
232
  def resolve_credentials
229
233
  case scheme
230
234
  when 'http'
data/spec/etcdv3_spec.rb CHANGED
@@ -6,13 +6,33 @@ describe Etcdv3 do
6
6
  let(:conn) { local_connection }
7
7
 
8
8
  describe '#initialize' do
9
- subject { conn }
10
- it { is_expected.to have_attributes(scheme: 'http') }
11
- it { is_expected.to have_attributes(hostname: '127.0.0.1') }
12
- it { is_expected.to have_attributes(credentials: :this_channel_is_insecure) }
13
- it { is_expected.to have_attributes(token: nil) }
14
- it { is_expected.to have_attributes(user: nil) }
15
- it { is_expected.to have_attributes(password: nil) }
9
+ context 'without auth' do
10
+ subject { conn }
11
+ it { is_expected.to have_attributes(scheme: 'http') }
12
+ it { is_expected.to have_attributes(hostname: '127.0.0.1') }
13
+ it { is_expected.to have_attributes(credentials: :this_channel_is_insecure) }
14
+ it { is_expected.to have_attributes(token: nil) }
15
+ it { is_expected.to have_attributes(user: nil) }
16
+ it { is_expected.to have_attributes(password: nil) }
17
+ end
18
+ context 'with auth' do
19
+ let(:auth_conn) { local_connection_with_auth('test', 'pass') }
20
+ before do
21
+ conn.add_user('root', 'pass')
22
+ conn.grant_role_to_user('root', 'root')
23
+ conn.add_user('test', 'pass')
24
+ conn.enable_auth
25
+ end
26
+ after do
27
+ conn.authenticate('root', 'pass')
28
+ conn.disable_auth
29
+ conn.delete_user('root')
30
+ conn.delete_user('test')
31
+ end
32
+ it 'doesnt raise error' do
33
+ expect{ auth_conn }.to_not raise_error
34
+ end
35
+ end
16
36
  end
17
37
 
18
38
  describe '#version' do
@@ -1,6 +1,10 @@
1
1
  module Helpers
2
2
  module Connections
3
3
 
4
+ def local_connection_with_auth(user, password)
5
+ Etcdv3.new(url: "http://#{local_url}", user: user, password: password)
6
+ end
7
+
4
8
  def local_connection
5
9
  Etcdv3.new(url: "http://#{local_url}")
6
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etcdv3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc