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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98c636be19b19d6798cf56e539898fe720acb2ad
4
- data.tar.gz: d9dae5508a89c099f6026623a8a5067dc862d06a
3
+ metadata.gz: 8330985ea2387a9974b5fecfcbaa53de36b392b1
4
+ data.tar.gz: 12e07a680c3d9e083d3fa584b80d0bbe24568689
5
5
  SHA512:
6
- metadata.gz: 3790981521336d080273eb72c6a2a43f8c7f9ffbc965de92b2d1931442c335b15d4498497946ec43b880515d22f63c0f78c32f1fcf3c46ca17714f251dfc0bea
7
- data.tar.gz: 958c4ff34c98a9028bb7e5a0e107beb5eabfff648bb9f13103bc8c592633af69d9fcf4b3887cd0219447e35bfc73a1ccf66f2f633c44845eaac13fd92164a7be
6
+ metadata.gz: 9ff762b133fd5fbe9bf26dd911cd02d1d5a24872ca6439114464d3560b75e07fa6d93519461d6d31a54deab2902b174a0b0a5a6c9b8a04d72f1bcb1b20def2b4
7
+ data.tar.gz: b0efc4bba78aa21781c17314d679434a1f54cc968c2bac14edfe49cc911f56c2a5a2878ce046d5770e89b303370b27124b3ae0f57c8ee3886dafaa90aa6fabea
@@ -6,32 +6,37 @@ require "dds_client/exceptions"
6
6
  module DdsClient
7
7
  class Api
8
8
  def self.create_from_env
9
- new(ENV.fetch("DDS_URL"), ENV.fetch("DDS_USERNAME"),
10
- ENV.fetch("DDS_PASSWORD"), ENV["DDS_CA_FILE"])
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, ca_file)
20
+ def initialize(url, username, password, verify_ssl)
16
21
  url = url.chomp("/")
17
- token = authenticate(url, username, password, ca_file)
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
- ssl_ca_file: ca_file
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, ca_file)
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
- ssl_ca_file: ca_file
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"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DdsClient
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dds_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadej Borovšak