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 +4 -4
- data/README.md +1 -1
- data/lib/etcdv3/version.rb +1 -1
- data/lib/etcdv3.rb +6 -2
- data/spec/etcdv3_spec.rb +27 -7
- data/spec/helpers/connections.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443472175a4cc4232c56f54afac01f0ca3bd1ae8
|
4
|
+
data.tar.gz: 3e5a3264ddb63003b330133e1e2ed0bc4b51716e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d87445129496ab8919e580b652818a4f136f552e84215812a3a31348ae54f0eabe209bc09ce7a677fa9d8bb590e2c7657c324fb17158a1c84c950c55208bad2
|
7
|
+
data.tar.gz: bb48f8937f5edcaf62231a1ed46c17af1c1a1f5a95735b3db100660d3b93450850bebada9830ea75cc51ba5ca3e1c67220d5d3341ed4d6ce3cc1782d59ae5ea6
|
data/README.md
CHANGED
data/lib/etcdv3/version.rb
CHANGED
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] =
|
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 =
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
data/spec/helpers/connections.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grpc
|