vgs_api_client 0.0.1.alpha202205061703 → 0.0.1.alpha202205071719
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/openapi_client/api_client.rb +1 -1
- data/lib/openapi_client/version.rb +1 -1
- data/lib/version.rb +1 -1
- data/lib/vgs_api_client.rb +11 -40
- data/scripts/assemble/run.sh +1 -1
- data/scripts/test/run.sh +1 -1
- data/spec/test_aliases_api_spec.rb +12 -46
- data/vgs_api_client.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d332fa1a80e3be4051ca26944d4ee30fa17545249e81ed79c9dc6888ce4849
|
4
|
+
data.tar.gz: ed8790413855fc02a2a5e6d0901b45513447291f8ed950181fb45890de1f180e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df74a87a1c25d69dfe843b2b09ca53516334310f819dd3c65391f20d38912cbdb19a2cc3e2ed00b72ad794ac60fe67f58326ca6591fa6a2ab50a80476838286f
|
7
|
+
data.tar.gz: 7ffa5561d2d9af943316f0bfb37bca6ceb756b10e5adb3c10e6e60b1342d89e7fb506a33cdf116b0d84d44a505c364903706d469d963871fe0881b1dc61c79f7
|
data/README.md
CHANGED
@@ -16,11 +16,11 @@ gem install vgs-api-client
|
|
16
16
|
|
17
17
|
### Development
|
18
18
|
|
19
|
-
Follow [DEVELOPMENT](DEVELOPMENT.md) instruction.
|
19
|
+
Follow [DEVELOPMENT](https://github.com/verygoodsecurity/vgs-api-client-ruby/blob/master/DEVELOPMENT.md) instruction.
|
20
20
|
|
21
21
|
### Release
|
22
22
|
|
23
|
-
Follow [RELEASE](RELEASE.md) instruction.
|
23
|
+
Follow [RELEASE](https://github.com/verygoodsecurity/vgs-api-client-ruby/blob/master/RELEASE.md) instruction.
|
24
24
|
|
25
25
|
### Documentation
|
26
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.1.
|
1
|
+
0.0.1.alpha202205071719
|
@@ -31,7 +31,7 @@ module VgsApiClient
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "vgs-api-client/0.0.1.
|
34
|
+
@user_agent = "vgs-api-client/0.0.1.alpha202205071719/ruby"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
data/lib/version.rb
CHANGED
data/lib/vgs_api_client.rb
CHANGED
@@ -1,48 +1,19 @@
|
|
1
1
|
require 'openapi_client'
|
2
2
|
|
3
3
|
module VGS
|
4
|
-
class
|
5
|
-
end
|
6
|
-
|
7
|
-
class UnauthorizedError < VgsApiError
|
8
|
-
end
|
9
|
-
|
10
|
-
class NotFoundError < VgsApiError
|
11
|
-
end
|
12
|
-
|
13
|
-
class ForbiddenError < VgsApiError
|
4
|
+
class VgsApiException < StandardError
|
14
5
|
end
|
15
6
|
|
16
7
|
class Aliases
|
17
8
|
def initialize(config)
|
18
|
-
raise ArgumentError, 'config is nil' if config.nil?
|
19
9
|
@aliases_api = VgsApiClient::AliasesApi.new(VgsApiClient::ApiClient.new(config))
|
20
10
|
end
|
21
11
|
|
22
|
-
private def map_exception(message, error)
|
23
|
-
error_message = message
|
24
|
-
if error.is_a? VgsApiClient::ApiError
|
25
|
-
error_message += ". Details: #{error.message}"
|
26
|
-
case error.code
|
27
|
-
when 401
|
28
|
-
UnauthorizedError.new error_message
|
29
|
-
when 403
|
30
|
-
ForbiddenError.new error_message
|
31
|
-
when 404
|
32
|
-
NotFoundError.new error_message
|
33
|
-
else
|
34
|
-
VgsApiError.new error_message
|
35
|
-
end
|
36
|
-
else
|
37
|
-
VgsApiError.new error_message
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
12
|
def redact(data)
|
42
13
|
begin
|
43
14
|
requests = data.map do |item|
|
44
15
|
VgsApiClient::CreateAliasesRequestNew.new(attributes = {
|
45
|
-
:format => VgsApiClient::AliasFormat.build_from_hash(item[:format]),
|
16
|
+
:format => VgsApiClient::AliasFormat.build_from_hash(item[:format] || "UUID"),
|
46
17
|
:classifiers => item[:classifiers],
|
47
18
|
:value => item[:value],
|
48
19
|
:storage => item[:storage]
|
@@ -55,8 +26,9 @@ module VGS
|
|
55
26
|
response = @aliases_api.create_aliases(opts = {
|
56
27
|
:create_aliases_request => create_aliases_request.to_hash
|
57
28
|
})
|
58
|
-
|
59
|
-
|
29
|
+
|
30
|
+
rescue
|
31
|
+
raise VgsApiException, "Failed to redact data #{ data }"
|
60
32
|
else
|
61
33
|
response.data
|
62
34
|
end
|
@@ -66,8 +38,8 @@ module VGS
|
|
66
38
|
begin
|
67
39
|
query = aliases.kind_of?(Array) ? aliases.join(",") : aliases
|
68
40
|
response = @aliases_api.reveal_multiple_aliases(q = query)
|
69
|
-
rescue
|
70
|
-
raise
|
41
|
+
rescue
|
42
|
+
raise VgsApiException, "Failed to reveal aliases #{ aliases }"
|
71
43
|
else
|
72
44
|
response.data
|
73
45
|
end
|
@@ -76,8 +48,8 @@ module VGS
|
|
76
48
|
def delete(_alias)
|
77
49
|
begin
|
78
50
|
@aliases_api.delete_alias(_alias = _alias)
|
79
|
-
rescue
|
80
|
-
raise
|
51
|
+
rescue
|
52
|
+
raise VgsApiException, "Failed to delete alias #{ _alias }"
|
81
53
|
end
|
82
54
|
end
|
83
55
|
|
@@ -91,8 +63,8 @@ module VGS
|
|
91
63
|
@aliases_api.update_alias(_alias = _alias, opts = {
|
92
64
|
:update_alias_request => update_alias_request.to_hash
|
93
65
|
})
|
94
|
-
rescue
|
95
|
-
raise
|
66
|
+
rescue
|
67
|
+
raise VgsApiException, "Failed to update alias #{ _alias }"
|
96
68
|
end
|
97
69
|
end
|
98
70
|
end
|
@@ -105,7 +77,6 @@ module VGS
|
|
105
77
|
config.username = username
|
106
78
|
config.password = password
|
107
79
|
config.host = host
|
108
|
-
config.server_index = nil
|
109
80
|
config
|
110
81
|
end
|
111
82
|
end
|
data/scripts/assemble/run.sh
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
LIB_VERSION=${LIB_VERSION:-0.0.1.alpha$(date "+%Y%m%d%H%M")}
|
4
4
|
|
5
5
|
# fix version
|
6
|
-
grep -rl 0.0.1.
|
6
|
+
grep -rl 0.0.1.alpha202205071719 . | xargs sed -i "s/0.0.1.alpha202205071719/${LIB_VERSION}/g"
|
7
7
|
|
8
8
|
# build
|
9
9
|
gem build vgs_api_client.gemspec
|
data/scripts/test/run.sh
CHANGED
@@ -5,7 +5,7 @@ set -e
|
|
5
5
|
echo "Installing lib from local sources"
|
6
6
|
# fix version
|
7
7
|
VERSION=0.0.1.alpha$(date "+%Y%m%d%H%M")
|
8
|
-
grep -rl 0.0.1.
|
8
|
+
grep -rl 0.0.1.alpha202205071719 . | xargs sed -i "s/0.0.1.alpha202205071719/$VERSION/g"
|
9
9
|
|
10
10
|
bundle install
|
11
11
|
|
@@ -3,43 +3,9 @@ require 'securerandom'
|
|
3
3
|
require 'vgs_api_client'
|
4
4
|
|
5
5
|
describe 'AliasesApiSpec' do
|
6
|
-
before(:
|
6
|
+
before(:all) do
|
7
7
|
config = VGS.config(username = ENV['VAULT_API_USERNAME'], password = ENV['VAULT_API_PASSWORD'])
|
8
|
-
@
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'invalid auth' do
|
12
|
-
it 'should fail if invalid auth provided' do
|
13
|
-
invalid_config = VGS.config(username = 'Invalid', password = 'Invalid')
|
14
|
-
api = VGS::Aliases.new invalid_config
|
15
|
-
data = [{
|
16
|
-
format: 'UUID',
|
17
|
-
value: 'Joe Doe'
|
18
|
-
}]
|
19
|
-
|
20
|
-
expect { api.redact data }.to raise_error(VGS::UnauthorizedError)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'invalid config' do
|
25
|
-
it 'should fail if invalid config provided' do
|
26
|
-
expect { VGS::Aliases.new nil }.to raise_error(ArgumentError)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'invalid host' do
|
31
|
-
it 'should fail if invalid host provided' do
|
32
|
-
config = VGS.config(
|
33
|
-
username = ENV['VAULT_API_USERNAME'],
|
34
|
-
password = ENV['VAULT_API_PASSWORD'],
|
35
|
-
host = 'https://echo.apps.verygood.systems')
|
36
|
-
api = VGS::Aliases.new config
|
37
|
-
data = [{
|
38
|
-
format: 'UUID',
|
39
|
-
value: 'Joe Doe'
|
40
|
-
}]
|
41
|
-
expect { api.redact data }.to raise_error(VGS::NotFoundError)
|
42
|
-
end
|
8
|
+
@aliases_api = VGS::Aliases.new config
|
43
9
|
end
|
44
10
|
|
45
11
|
describe 'redact' do
|
@@ -55,7 +21,7 @@ describe 'AliasesApiSpec' do
|
|
55
21
|
value: 'Joe Doe',
|
56
22
|
storage: 'VOLATILE'
|
57
23
|
}]
|
58
|
-
aliases = @
|
24
|
+
aliases = @aliases_api.redact data
|
59
25
|
expect(aliases.length).to eq 2
|
60
26
|
data.each_with_index do |item, index|
|
61
27
|
expect(aliases[index].value).to eq item[:value]
|
@@ -80,14 +46,14 @@ describe 'AliasesApiSpec' do
|
|
80
46
|
value: 'Joe Doe',
|
81
47
|
storage: 'VOLATILE'
|
82
48
|
}]
|
83
|
-
aliases = @
|
49
|
+
aliases = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }
|
84
50
|
|
85
|
-
response = @
|
51
|
+
response = @aliases_api.reveal aliases
|
86
52
|
|
87
53
|
expect(response.length).to eq 2
|
88
54
|
original_values = data.map { |i| i[:value] }
|
89
55
|
revealed_values = response.values.map { |i| i.value }
|
90
|
-
expect(Set.new
|
56
|
+
expect(Set.new(original_values)).to eq Set.new(revealed_values)
|
91
57
|
end
|
92
58
|
end
|
93
59
|
|
@@ -97,11 +63,11 @@ describe 'AliasesApiSpec' do
|
|
97
63
|
format: 'UUID',
|
98
64
|
value: SecureRandom.alphanumeric(10)
|
99
65
|
}]
|
100
|
-
_alias = @
|
66
|
+
_alias = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }[0]
|
101
67
|
|
102
|
-
@
|
68
|
+
@aliases_api.update _alias, classifiers: %w[secure]
|
103
69
|
|
104
|
-
response = @
|
70
|
+
response = @aliases_api.reveal(_alias)
|
105
71
|
expect(response[_alias].classifiers).to eq %w[secure]
|
106
72
|
end
|
107
73
|
end
|
@@ -112,11 +78,11 @@ describe 'AliasesApiSpec' do
|
|
112
78
|
format: 'UUID',
|
113
79
|
value: '5201784564572092'
|
114
80
|
}]
|
115
|
-
_alias = @
|
81
|
+
_alias = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }[0]
|
116
82
|
|
117
|
-
@
|
83
|
+
@aliases_api.delete _alias
|
118
84
|
|
119
|
-
expect { @
|
85
|
+
expect { @aliases_api.reveal(_alias) }.to raise_error(VGS::VgsApiException)
|
120
86
|
end
|
121
87
|
end
|
122
88
|
|
data/vgs_api_client.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Very Good Security"]
|
10
10
|
s.email = ["support@verygoodsecurity.com"]
|
11
11
|
s.homepage = "https://github.com/verygoodsecurity/vgs-api-client-ruby"
|
12
|
-
s.summary = "
|
13
|
-
s.description = "
|
12
|
+
s.summary = "Very Good Security API Client"
|
13
|
+
s.description = "Very Good Security API Client library. More details on https://www.verygoodsecurity.com/"
|
14
14
|
s.license = "BSD-3-Clause"
|
15
15
|
s.required_ruby_version = ">= 2.6"
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vgs_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.alpha202205071719
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Very Good Security
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 3.6.0
|
53
|
-
description:
|
53
|
+
description: Very Good Security API Client library. More details on https://www.verygoodsecurity.com/
|
54
54
|
email:
|
55
55
|
- support@verygoodsecurity.com
|
56
56
|
executables: []
|
@@ -132,7 +132,7 @@ requirements: []
|
|
132
132
|
rubygems_version: 3.3.7
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
|
-
summary:
|
135
|
+
summary: Very Good Security API Client
|
136
136
|
test_files:
|
137
137
|
- spec/api_client_spec.rb
|
138
138
|
- spec/configuration_spec.rb
|