image-inspector-client 1.0.1 → 1.0.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: da60483c1212458eadf005485118b3a70d1a77e9
4
- data.tar.gz: 753c4a38cf2d86553ead4c5e6ac740672323c690
3
+ metadata.gz: 1f4778a7b8967c1922993122ec7fe7e9403cdb8b
4
+ data.tar.gz: a1a68da7ab4c77b68fa53f4e90ac9b5cb9117484
5
5
  SHA512:
6
- metadata.gz: d420f91f15721963b5b41ba1015135f93e5221e1f4cd53a14aec8792c631dfacb286240628143cdf877582300d7523a3f5004c05cd6b5c09624963a381feee3e
7
- data.tar.gz: 9700a199ad7c28a5afee86713ef5ead0dabcfc3bb0f6fa9d86df2ec852a510004fc2012ff2d7116e587d19874c177f45bc3238042d709d748ffb9fec655b66dc
6
+ metadata.gz: 0e47c57379ab6a79ea5f1354bf43b9122c1c31762d5909f48c83ea2234edbdbeb6507c3eef40459bdc9fed2bfc65e3443f72db08cb918cd73b7436ed982d1a00
7
+ data.tar.gz: 27879e3e27617d90f072b4719afb0a4e67414feb243ea3f1fe2a7bd86fa3853f18f850843d034557eac2e5886c0137d0d7a8987b3a194f3f0ff54c112c819615
data/README.md CHANGED
@@ -11,6 +11,12 @@ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
11
11
  .fetch_metadata
12
12
  .ContainerConfig
13
13
  .Cmd
14
+
15
+
16
+ Get OpenSCAP ARF as raw xml:
17
+ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
18
+ .fetch_oscap_arf
19
+
14
20
  ```
15
21
 
16
22
  ## building from source
@@ -28,6 +28,12 @@ module ImageInspectorClient
28
28
  @headers = {}
29
29
  end
30
30
 
31
+ def fetch_oscap_arf
32
+ exception_handler do
33
+ RestClient::Resource.new(@endpoint, http_options)['openscap'].get(http_headers).body
34
+ end
35
+ end
36
+
31
37
  def fetch_metadata
32
38
  exception_handler do
33
39
  RecursiveOpenStruct.new(
@@ -48,7 +54,7 @@ module ImageInspectorClient
48
54
  rescue JSON::ParserError
49
55
  json_error_msg = {}
50
56
  end
51
- err_message = json_error_msg['message'] || e.message
57
+ err_message = json_error_msg['message'] || e.to_s
52
58
  raise InspectorClientException.new(e.http_code, err_message)
53
59
  end
54
60
 
@@ -1,4 +1,4 @@
1
1
  # Client for image inspector: https://github.com/simon3z/image-inspector
2
2
  module ImageInspectorClient
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
@@ -0,0 +1,61 @@
1
+ require 'common'
2
+
3
+ # Tests for fetch_oscap_arf call
4
+ class TestOpenscap < MiniTest::Test
5
+ def test_openscap_happy_flow
6
+ stub_request(:get, %r{/openscap}).to_return(
7
+ body: open_test_file('openscap.xml'),
8
+ status: 200
9
+ )
10
+
11
+ md = ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
12
+ .fetch_oscap_arf
13
+
14
+ assert_equal(File.read('test/xml/openscap.xml'), md)
15
+
16
+ assert_requested(
17
+ :get,
18
+ 'http://localhost:8080/api/v1/openscap',
19
+ times: 1
20
+ )
21
+ end
22
+
23
+ def test_openscap_empty_body
24
+ stub_request(:get, %r{/openscap}).to_return(
25
+ body: '',
26
+ status: 200
27
+ )
28
+
29
+ md = ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
30
+ .fetch_oscap_arf
31
+
32
+ assert_equal('', md)
33
+
34
+ assert_requested(
35
+ :get,
36
+ 'http://localhost:8080/api/v1/openscap',
37
+ times: 1
38
+ )
39
+ end
40
+
41
+ def test_openscap_404
42
+ stub_request(:get, %r{/openscap}).to_return(
43
+ body: 'Openscap option was not chosen',
44
+ status: 404
45
+ )
46
+
47
+ e = assert_raises(ImageInspectorClient::InspectorClientException) do
48
+ ImageInspectorClient::Client.new('http://localhost:8080', 'v1')
49
+ .fetch_oscap_arf
50
+ end
51
+
52
+ assert_equal(404, e.error_code)
53
+ assert_match(/Openscap option was not chosen/, e.message)
54
+
55
+ assert_requested(
56
+ :get,
57
+ 'http://localhost:8080/api/v1/openscap',
58
+ times: 1
59
+ )
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <arf:asset-report-collection xmlns:arf="http://scap.nist.gov/schema/asset-reporting-format/1.1" xmlns:core="http://scap.nist.gov/schema/reporting-core/1.1" xmlns:ai="http://scap.nist.gov/schema/asset-identification/1.1">
3
+ <core:relationships xmlns:arfvocab="http://scap.nist.gov/specifications/arf/vocabulary/relationships/1.0#" xmlns:arfrel="http://scap.nist.gov/vocabulary/arf/relationships/1.0#">
4
+ <core:relationship type="arfvocab:createdFor" subject="xccdf1">
5
+ <core:ref>collection1</core:ref>
6
+ </core:relationship>
7
+ <core:relationship type="arfrel:isAbout" subject="xccdf1">
8
+ <core:ref>asset0</core:ref>
9
+ </core:relationship>
10
+ </core:relationships>
11
+ <arf:report-requests>
12
+ <arf:report-request id="collection1">
13
+ <arf:content>
14
+ </arf:content>
15
+ </arf:report>
16
+ </arf:reports>
17
+ </arf:asset-report-collection>
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.1
4
+ version: 1.0.2
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-03-27 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,8 @@ files:
143
143
  - test/json/metadata.json
144
144
  - test/test_client.rb
145
145
  - test/test_metadata.rb
146
+ - test/test_openscap.rb
147
+ - test/xml/openscap.xml
146
148
  homepage: https://github.com/moolitayer/image-inspector-client
147
149
  licenses:
148
150
  - MIT
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
165
  version: '0'
164
166
  requirements: []
165
167
  rubyforge_project:
166
- rubygems_version: 2.4.8
168
+ rubygems_version: 2.6.3
167
169
  signing_key:
168
170
  specification_version: 4
169
171
  summary: A client for image_inspector REST API
@@ -172,4 +174,5 @@ test_files:
172
174
  - test/json/metadata.json
173
175
  - test/test_client.rb
174
176
  - test/test_metadata.rb
175
- has_rdoc:
177
+ - test/test_openscap.rb
178
+ - test/xml/openscap.xml