image-inspector-client 1.0.2 → 1.0.3

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: 1f4778a7b8967c1922993122ec7fe7e9403cdb8b
4
- data.tar.gz: a1a68da7ab4c77b68fa53f4e90ac9b5cb9117484
3
+ metadata.gz: a4a6c042421c36dc77cbdf06b8ac27fed24fae08
4
+ data.tar.gz: 4a902b2d59cafde219c5c1e4d8b66a73a37553b7
5
5
  SHA512:
6
- metadata.gz: 0e47c57379ab6a79ea5f1354bf43b9122c1c31762d5909f48c83ea2234edbdbeb6507c3eef40459bdc9fed2bfc65e3443f72db08cb918cd73b7436ed982d1a00
7
- data.tar.gz: 27879e3e27617d90f072b4719afb0a4e67414feb243ea3f1fe2a7bd86fa3853f18f850843d034557eac2e5886c0137d0d7a8987b3a194f3f0ff54c112c819615
6
+ metadata.gz: 12ff422fbadf19288d00bda3be488f967519a43784d649b3c515fc6e8ef38a7208f865f9af958de9d12678c6114c32dc0376906cab49ac27a68603673ce59c75
7
+ data.tar.gz: 337932fe6766926c5ffdee79e1d12c3d60aa5e661ce9ce615b3bf614e0cf6174e2658496bfc228db143ffe8fd334a261e3b200ec55303b9ab80e26d8c0a79fc0
@@ -20,11 +20,13 @@ module ImageInspectorClient
20
20
  username: nil,
21
21
  password: nil,
22
22
  bearer_token: nil
23
- }
23
+ },
24
+ http_proxy_uri: nil
24
25
  )
25
26
  @endpoint = URI.parse("#{uri}/api/#{version}")
26
27
  @auth_options = auth_options
27
28
  @ssl_options = ssl_options
29
+ @http_proxy_uri = http_proxy_uri
28
30
  @headers = {}
29
31
  end
30
32
 
@@ -54,7 +56,7 @@ module ImageInspectorClient
54
56
  rescue JSON::ParserError
55
57
  json_error_msg = {}
56
58
  end
57
- err_message = json_error_msg['message'] || e.to_s
59
+ err_message = json_error_msg['message'] || e.response
58
60
  raise InspectorClientException.new(e.http_code, err_message)
59
61
  end
60
62
 
@@ -66,7 +68,8 @@ module ImageInspectorClient
66
68
  ssl_cert_store: @ssl_options[:cert_store],
67
69
  verify_ssl: @ssl_options[:verify_ssl],
68
70
  user: @auth_options[:username],
69
- password: @auth_options[:password]
71
+ password: @auth_options[:password],
72
+ proxy: @http_proxy_uri
70
73
  }
71
74
  end
72
75
 
@@ -1,4 +1,4 @@
1
1
  # Client for image inspector: https://github.com/simon3z/image-inspector
2
2
  module ImageInspectorClient
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
  end
@@ -0,0 +1,49 @@
1
+ require 'common'
2
+
3
+ # Tests for rest-client return values
4
+ class TestRestClient < MiniTest::Test
5
+ def test_metadata_404_plaintext
6
+ stub_request(:get, %r{/metadata}).to_return(
7
+ body: 'No Metadata Given',
8
+ status: 404
9
+ )
10
+
11
+ e = assert_raises(ImageInspectorClient::InspectorClientException) do
12
+ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
13
+ .fetch_metadata
14
+ end
15
+
16
+ assert_equal(404, e.error_code)
17
+ assert_equal('No Metadata Given', e.message)
18
+ end
19
+
20
+ def test_metadata_404_json
21
+ stub_request(:get, %r{/metadata}).to_return(
22
+ body: '{"message": "No Metadata Given"}',
23
+ status: 404
24
+ )
25
+
26
+ e = assert_raises(ImageInspectorClient::InspectorClientException) do
27
+ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
28
+ .fetch_metadata
29
+ end
30
+
31
+ assert_equal(404, e.error_code)
32
+ assert_equal('No Metadata Given', e.message)
33
+ end
34
+
35
+ def test_metadata_404_empty_body
36
+ stub_request(:get, %r{/metadata}).to_return(
37
+ body: '',
38
+ status: 404
39
+ )
40
+
41
+ e = assert_raises(ImageInspectorClient::InspectorClientException) do
42
+ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
43
+ .fetch_metadata
44
+ end
45
+
46
+ assert_equal(404, e.error_code)
47
+ assert_equal('', e.message)
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image-inspector-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mooli Tayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,6 +144,7 @@ files:
144
144
  - test/test_client.rb
145
145
  - test/test_metadata.rb
146
146
  - test/test_openscap.rb
147
+ - test/test_rest_client.rb
147
148
  - test/xml/openscap.xml
148
149
  homepage: https://github.com/moolitayer/image-inspector-client
149
150
  licenses:
@@ -175,4 +176,5 @@ test_files:
175
176
  - test/test_client.rb
176
177
  - test/test_metadata.rb
177
178
  - test/test_openscap.rb
179
+ - test/test_rest_client.rb
178
180
  - test/xml/openscap.xml