dds_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dds_client/api.rb +12 -7
- data/lib/dds_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8330985ea2387a9974b5fecfcbaa53de36b392b1
|
4
|
+
data.tar.gz: 12e07a680c3d9e083d3fa584b80d0bbe24568689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ff762b133fd5fbe9bf26dd911cd02d1d5a24872ca6439114464d3560b75e07fa6d93519461d6d31a54deab2902b174a0b0a5a6c9b8a04d72f1bcb1b20def2b4
|
7
|
+
data.tar.gz: b0efc4bba78aa21781c17314d679434a1f54cc968c2bac14edfe49cc911f56c2a5a2878ce046d5770e89b303370b27124b3ae0f57c8ee3886dafaa90aa6fabea
|
data/lib/dds_client/api.rb
CHANGED
@@ -6,32 +6,37 @@ require "dds_client/exceptions"
|
|
6
6
|
module DdsClient
|
7
7
|
class Api
|
8
8
|
def self.create_from_env
|
9
|
-
|
10
|
-
|
9
|
+
puts(ENV.fetch("DDS_VERIFY_SSL", "true"))
|
10
|
+
new(
|
11
|
+
ENV.fetch("DDS_URL"),
|
12
|
+
ENV.fetch("DDS_USERNAME"),
|
13
|
+
ENV.fetch("DDS_PASSWORD"),
|
14
|
+
ENV.fetch("DDS_VERIFY_SSL", "true") != "false"
|
15
|
+
)
|
11
16
|
rescue KeyError => e
|
12
17
|
raise DdsClient::ConfigError, "Set environment vars (#{e})"
|
13
18
|
end
|
14
19
|
|
15
|
-
def initialize(url, username, password,
|
20
|
+
def initialize(url, username, password, verify_ssl)
|
16
21
|
url = url.chomp("/")
|
17
|
-
token = authenticate(url, username, password,
|
22
|
+
token = authenticate(url, username, password, verify_ssl)
|
18
23
|
|
19
24
|
params = {
|
20
25
|
headers: {
|
21
26
|
"Content-Type" => "application/json",
|
22
27
|
"Authorization" => "Token #{token}"
|
23
28
|
},
|
24
|
-
|
29
|
+
ssl_verify_peer: verify_ssl
|
25
30
|
}
|
26
31
|
@connection = Excon.new(url, params)
|
27
32
|
end
|
28
33
|
|
29
|
-
def authenticate(url, username, password,
|
34
|
+
def authenticate(url, username, password, verify_ssl)
|
30
35
|
r = Excon.post(
|
31
36
|
"#{url}/auth/get-token",
|
32
37
|
headers: { "Content-Type" => "application/json" },
|
33
38
|
body: { "username" => username, "password" => password }.to_json,
|
34
|
-
|
39
|
+
ssl_verify_peer: verify_ssl
|
35
40
|
)
|
36
41
|
raise DdsClient::AuthError, "Invalid credentials" if r.status != 200
|
37
42
|
JSON.parse(r.body)["token"]
|
data/lib/dds_client/version.rb
CHANGED