ibm_cloud_sdk_core 1.1.1 → 1.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
  SHA256:
3
- metadata.gz: 3aa7649a46616ff68df78f31bb96e4e3f446dbbb860de733539ae0fe33198be2
4
- data.tar.gz: e277e383682e0e00ab70626e08a02484ebcac0e0fdddb75a4328203308b2dbc7
3
+ metadata.gz: 9ea5a5f7575d1adaba82982ad3467bb4a80c39bcc686d291dbb95e450b72e1c1
4
+ data.tar.gz: 870be154704bc0e75a215ba910be6f72aa110855f65961f73ee937ba650e1103
5
5
  SHA512:
6
- metadata.gz: 1c88b1408600c23b95e93d9b236b2b7f1befefebce6c3af01c406a6d9cf8ee5ed319011ca7ee50ec7be3fd06a9d5e867ab41d3074181fa1a00b0b1f8ad115e12
7
- data.tar.gz: 102d3450e5019d17efe1217e3d6c21a74dd4883690aba3bc8784995beb5609b61661bf177f6b0a978f92ae5f20560a45bac35996018b61f43c6b6663963819b6
6
+ metadata.gz: '081184cf6a07b9a48bdfcb7c20a97ff27871fb3f35e56defd88dc5e3baba9b71dc4e954ae9d1ec8c78b9929281a2133cd144967e3028463eb2a8287a9aff2560'
7
+ data.tar.gz: 1ec8854f91cabc79e2bd5e9dadd09278fc72fab8934daf1d9a30e903dd85bdc1ae8aa877beea3cc72ddb5f81b435740c2a5c1fdc93175d721869b198e5606d3c
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.com/IBM/ruby-sdk-core.svg?branch=master)](https://travis-ci.com/IBM/ruby-sdk-core)
2
- [![codecov](https://codecov.io/gh/IBM/ruby-sdk-core/branch/master/graph/badge.svg)](https://codecov.io/gh/IBM/ruby-sdk-core)
1
+ [![Build Status](https://travis-ci.com/IBM/ruby-sdk-core.svg?branch=main)](https://travis-ci.com/IBM/ruby-sdk-core)
2
+ [![codecov](https://codecov.io/gh/IBM/ruby-sdk-core/branch/main/graph/badge.svg)](https://codecov.io/gh/IBM/ruby-sdk-core)
3
3
  [![Gem Version](https://badge.fury.io/rb/ibm_cloud_sdk_core.svg)](https://rubygems.org/gems/ibm_cloud_sdk_core)
4
4
 
5
5
  # ruby-sdk-core
@@ -44,7 +44,7 @@ def load_from_credential_file(service_name, separator = "=")
44
44
  file_contents = File.open(credential_file_path, "r")
45
45
  config = {}
46
46
  file_contents.each_line do |line|
47
- key_val = line.strip.split(separator)
47
+ key_val = line.strip.split(separator, 2)
48
48
  if key_val.length == 2 && !line.start_with?("#")
49
49
  key = parse_key(key_val[0].downcase, service_name) unless key_val[0].nil?
50
50
  config.store(key.to_sym, key_val[1]) unless key.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMCloudSdkCore
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
@@ -23,4 +23,94 @@ class UtilsTest < Minitest::Test
23
23
  assert_equal(explicitly_true(false), false)
24
24
  assert_equal(explicitly_true(nil), false)
25
25
  end
26
+
27
+ def test_get_configuration_credential_file
28
+ file_path = File.join(File.dirname(__FILE__), "../../resources/ibm-credentials.env")
29
+ ENV["IBM_CREDENTIALS_FILE"] = file_path
30
+ # get properties
31
+ config = get_service_properties("service_1")
32
+ auth_type = config[:auth_type] unless config.nil?
33
+ apikey = config[:apikey] unless config.nil?
34
+ auth_url = config[:auth_url] unless config.nil?
35
+ client_id = config[:client_id] unless config.nil?
36
+ client_secret = config[:client_secret] unless config.nil?
37
+ service_url = config[:url] unless config.nil?
38
+
39
+ assert !auth_type.nil?
40
+ assert !apikey.nil?
41
+ assert !auth_url.nil?
42
+ assert !client_id.nil?
43
+ assert !client_secret.nil?
44
+ assert !service_url.nil?
45
+
46
+ assert_equal("iam", auth_type)
47
+ assert_equal("V4HXmoUtMjohnsnow=KotN", apikey)
48
+ assert_equal("https://iamhost/iam/api=", auth_url)
49
+ assert_equal("somefake========id", client_id)
50
+ assert_equal("==my-client-secret==", client_secret)
51
+ assert_equal("service1.com/api", service_url)
52
+ ENV.delete("IBM_CREDENTIALS_FILE")
53
+ end
54
+
55
+ def test_get_configuration_from_env
56
+ # Service1 auth properties configured with IAM and a token containing '='
57
+ ENV["SERVICE_1_AUTH_TYPE"] = "iam"
58
+ ENV["SERVICE_1_APIKEY"] = "V4HXmoUtMjohnsnow=KotN"
59
+ ENV["SERVICE_1_CLIENT_ID"] = "somefake========id"
60
+ ENV["SERVICE_1_CLIENT_SECRET"] = "==my-client-secret=="
61
+ ENV["SERVICE_1_AUTH_URL"] = "https://iamhost/iam/api="
62
+ # Service1 service properties
63
+ ENV["SERVICE_1_URL"] = "service1.com/api"
64
+ # get properties
65
+ config = get_service_properties("service_1")
66
+ auth_type = config[:auth_type] unless config.nil?
67
+ apikey = config[:apikey] unless config.nil?
68
+ auth_url = config[:auth_url] unless config.nil?
69
+ client_id = config[:client_id] unless config.nil?
70
+ client_secret = config[:client_secret] unless config.nil?
71
+ service_url = config[:url] unless config.nil?
72
+
73
+ assert !auth_type.nil?
74
+ assert !apikey.nil?
75
+ assert !auth_url.nil?
76
+ assert !client_id.nil?
77
+ assert !client_secret.nil?
78
+ assert !service_url.nil?
79
+
80
+ assert_equal("iam", auth_type)
81
+ assert_equal("V4HXmoUtMjohnsnow=KotN", apikey)
82
+ assert_equal("https://iamhost/iam/api=", auth_url)
83
+ assert_equal("somefake========id", client_id)
84
+ assert_equal("==my-client-secret==", client_secret)
85
+ assert_equal("service1.com/api", service_url)
86
+
87
+ ENV.delete("SERVICE_1_AUTH_TYPE")
88
+ ENV.delete("SERVICE_1_APIKEY")
89
+ ENV.delete("SERVICE_1_CLIENT_ID")
90
+ ENV.delete("SERVICE_1_CLIENT_SECRET")
91
+ ENV.delete("SERVICE_1_AUTH_URL")
92
+ ENV.delete("SERVICE_1_URL")
93
+ end
94
+
95
+ def test_get_configuration_from_vcap
96
+ ENV["VCAP_SERVICES"] = JSON.parse(File.read(Dir.getwd + "/resources/vcap-testing.json")).to_json
97
+ # get properties
98
+ config = get_service_properties("equals-sign-test")
99
+ auth_type = config[:auth_type] unless config.nil?
100
+ apikey = config[:apikey] unless config.nil?
101
+ iam_url = config[:iam_url] unless config.nil?
102
+ service_url = config[:url] unless config.nil?
103
+
104
+ assert !auth_type.nil?
105
+ assert !apikey.nil?
106
+ assert !iam_url.nil?
107
+ assert !service_url.nil?
108
+
109
+ assert_equal("iam", auth_type)
110
+ assert_equal("V4HXmoUtMjohnsnow=KotN", apikey)
111
+ assert_equal("https://iamhost/iam/api=", iam_url)
112
+ assert_equal("https://gateway.watsonplatform.net/testService", service_url)
113
+
114
+ ENV.delete("VCAP_SERVICES")
115
+ end
26
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_cloud_sdk_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mamoon Raja
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -276,8 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  - !ruby/object:Gem::Version
277
277
  version: '0'
278
278
  requirements: []
279
- rubyforge_project:
280
- rubygems_version: 2.7.7
279
+ rubygems_version: 3.0.8
281
280
  signing_key:
282
281
  specification_version: 4
283
282
  summary: Official IBM Cloud SDK core library