vgs_api_client 0.0.1.dev202204201806 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +70 -0
- data/README.md +237 -0
- data/docs/AliasFormat.md +15 -0
- data/docs/AliasesApi.md +366 -0
- data/docs/ApiError.md +24 -0
- data/docs/CreateAliasesRequest.md +18 -0
- data/docs/CreateAliasesRequestExisting.md +20 -0
- data/docs/CreateAliasesRequestNew.md +22 -0
- data/docs/InlineResponse200.md +18 -0
- data/docs/InlineResponse2001.md +18 -0
- data/docs/InlineResponse201.md +18 -0
- data/docs/InlineResponseDefault.md +18 -0
- data/docs/ModelAlias.md +20 -0
- data/docs/RevealedData.md +24 -0
- data/docs/UpdateAliasRequest.md +18 -0
- data/docs/UpdateAliasRequestData.md +18 -0
- data/git_push.sh +57 -0
- data/lib/vgs_api_client/api/aliases_api.rb +17 -8
- data/lib/vgs_api_client/api_client.rb +5 -5
- data/lib/vgs_api_client/api_error.rb +3 -3
- data/lib/vgs_api_client/configuration.rb +3 -3
- data/lib/vgs_api_client/models/alias_format.rb +3 -3
- data/lib/vgs_api_client/models/api_error.rb +6 -6
- data/lib/vgs_api_client/models/create_aliases_request.rb +7 -35
- data/lib/vgs_api_client/models/{create_aliases_request_reference.rb → create_aliases_request_existing.rb} +7 -7
- data/lib/vgs_api_client/models/create_aliases_request_new.rb +7 -53
- data/lib/vgs_api_client/models/inline_response200.rb +6 -6
- data/lib/vgs_api_client/models/inline_response2001.rb +6 -30
- data/lib/vgs_api_client/models/inline_response201.rb +6 -6
- data/lib/vgs_api_client/models/inline_response_default.rb +6 -21
- data/lib/vgs_api_client/models/model_alias.rb +6 -6
- data/lib/vgs_api_client/models/revealed_data.rb +7 -53
- data/lib/vgs_api_client/models/update_alias_request.rb +6 -6
- data/lib/vgs_api_client/models/update_alias_request_data.rb +6 -6
- data/lib/vgs_api_client/version.rb +4 -4
- data/lib/vgs_api_client.rb +5 -5
- data/spec/api/aliases_api_spec.rb +137 -0
- data/spec/api_client_spec.rb +31 -31
- data/spec/configuration_spec.rb +5 -5
- data/spec/models/alias_format_spec.rb +28 -0
- data/spec/models/api_error_spec.rb +52 -0
- data/spec/models/create_aliases_request_existing_spec.rb +40 -0
- data/spec/models/create_aliases_request_new_spec.rb +46 -0
- data/spec/models/create_aliases_request_spec.rb +34 -0
- data/spec/models/inline_response2001_spec.rb +34 -0
- data/spec/models/inline_response200_spec.rb +34 -0
- data/spec/models/inline_response201_spec.rb +34 -0
- data/spec/models/inline_response_default_spec.rb +34 -0
- data/spec/models/model_alias_spec.rb +40 -0
- data/spec/models/revealed_data_spec.rb +52 -0
- data/spec/models/update_alias_request_data_spec.rb +34 -0
- data/spec/models/update_alias_request_spec.rb +34 -0
- data/spec/spec_helper.rb +2 -2
- data/vgs_api_client.gemspec +3 -3
- metadata +51 -22
- data/DEVELOPMENT.md +0 -11
- data/LICENSE +0 -11
- data/RELEASE.md +0 -15
- data/docker-compose.yaml +0 -32
- data/lib/vgs.rb +0 -82
- data/scripts/assemble/Dockerfile +0 -8
- data/scripts/assemble/run.sh +0 -9
- data/scripts/publish/Dockerfile +0 -8
- data/scripts/publish/run.sh +0 -14
- data/scripts/publish.sh +0 -12
- data/scripts/run-tests-e2e.sh +0 -10
- data/scripts/run-tests.sh +0 -6
- data/scripts/test/Dockerfile +0 -12
- data/scripts/test/run.sh +0 -37
- data/spec/test_aliases_api_spec.rb +0 -97
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
2
|
#Vault HTTP API
|
3
3
|
|
4
|
-
#
|
4
|
+
#Storing, retrieving, and managing sensitive data within a VGS organization. **NOTE:** _The Vault API is intended only for environments that are already PCI-compliant. If you want to use this API, but are not yet PCI-compliant, you can use [VGS Collect](https://www.verygoodsecurity.com/docs/vgs-collect/what-is-it) or VGS Proxy with [Inbound Routes](https://www.verygoodsecurity.com/docs/getting-started/quick-integration#securing-inbound-connection) to quickly and seamlessly achieve compliance._ Looking for the old version of the API? Find it [here](https://www.verygoodsecurity.com/docs/api/1/vault). # Introduction Each encrypted value stored in a VGS vault has one or multiple _aliases_ associated with it. These aliases are fully opaque and retain no information about the underlying data. The user may safely store aliases without compromising data security. **NOTE:** The API works with persistent storage only. Unlike volatile storage, this means that the data is stored permanently, without any implicit TTL. Aliases are not valuable on their own. However, they can be used to decrypt the associated value and pass it to another service via the [forward proxy](https://www.verygoodsecurity.com/docs/guides/outbound-connection). ## Alias Formats Each alias corresponds to a certain format. There are several alias formats suitable for different kinds of sensitive data. For example, `UUID` produces a random Base58-encoded UUID string with an environment-dependent prefix: ``` tok_sandbox_bhtsCwFUzoJMw9rWUfEV5e ``` This format is generic and suitable for any kind of data. The tables below contain descriptions of all alias formats recognized by the API. ### Generic Formats | Value | Description | |-------------------------|-------------------------------------------------------| | `NUM_LENGTH_PRESERVING` | Length-Preserving, Numeric | | `RAW_UUID` | UUID | | `UUID` | UUID (Prefixed, Base58-Encoded) | | `GENERIC_T_FOUR` | UUID (Prefixed, Base58-Encoded, Last four preserving) | ### Account Number Formats | Value | Description | |-----------------------------------|--------------------------------------| | `FPE_ACC_NUM_T_FOUR` | Length-Preserving, Numeric (A4) | | `FPE_ALPHANUMERIC_ACC_NUM_T_FOUR` | Length-Preserving, Alphanumeric (A4) | ### Payment Card Formats | Value | Description | |------------------|---------------------------------------------| | `FPE_SIX_T_FOUR` | Format-Preserving, Luhn Valid (6T4) | | `FPE_T_FOUR` | Format-Preserving, Luhn Valid (T4) | | `PFPT` | Prefixed, Luhn Valid, 19-Digit Fixed Length | ### SSN Formats | Value | Description | |------------------|------------------------| | `FPE_SSN_T_FOUR` | Format-Preserving (A4) | # Authentication This API uses `Basic` authentication. Credentials to access the API can be generated on the [dashboard](https://dashboard.verygoodsecurity.com) by going to the Settings section of the vault of your choosing. [Docs » Guides » Access credentials](https://www.verygoodsecurity.com/docs/settings/access-credentials) # Rate Limiting The API allows up to 3,000 requests per minute. Requests are associated with the vault, regardless of the access credentials used to authenticate the request. Your current rate limit is included as HTTP headers in every API response: | Header Name | Description | |-------------------------|----------------------------------------------------------| | `x-ratelimit-remaining` | The number of requests remaining in the 1-minute window. | If you exceed the rate limit, the API will reject the request with HTTP [429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). # Errors The API uses standard HTTP status codes to indicate whether the request succeeded or not. In case of failure, the response body will be JSON in a predefined format. For example, trying to create too many aliases at once results in the following response: ```json { \"errors\": [ { \"status\": 400, \"title\": \"Bad request\", \"detail\": \"Too many values (limit: 20)\", \"href\": \"https://api.sandbox.verygoodvault.com/aliases\" } ] } ```
|
5
5
|
|
6
6
|
The version of the OpenAPI document: 1.0.0
|
7
7
|
Contact: support@verygoodsecurity.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 5.
|
9
|
+
OpenAPI Generator version: 5.0.1-SNAPSHOT
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
data/vgs_api_client.gemspec
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
=begin
|
4
4
|
#Vault HTTP API
|
5
5
|
|
6
|
-
#
|
6
|
+
#Storing, retrieving, and managing sensitive data within a VGS organization. **NOTE:** _The Vault API is intended only for environments that are already PCI-compliant. If you want to use this API, but are not yet PCI-compliant, you can use [VGS Collect](https://www.verygoodsecurity.com/docs/vgs-collect/what-is-it) or VGS Proxy with [Inbound Routes](https://www.verygoodsecurity.com/docs/getting-started/quick-integration#securing-inbound-connection) to quickly and seamlessly achieve compliance._ Looking for the old version of the API? Find it [here](https://www.verygoodsecurity.com/docs/api/1/vault). # Introduction Each encrypted value stored in a VGS vault has one or multiple _aliases_ associated with it. These aliases are fully opaque and retain no information about the underlying data. The user may safely store aliases without compromising data security. **NOTE:** The API works with persistent storage only. Unlike volatile storage, this means that the data is stored permanently, without any implicit TTL. Aliases are not valuable on their own. However, they can be used to decrypt the associated value and pass it to another service via the [forward proxy](https://www.verygoodsecurity.com/docs/guides/outbound-connection). ## Alias Formats Each alias corresponds to a certain format. There are several alias formats suitable for different kinds of sensitive data. For example, `UUID` produces a random Base58-encoded UUID string with an environment-dependent prefix: ``` tok_sandbox_bhtsCwFUzoJMw9rWUfEV5e ``` This format is generic and suitable for any kind of data. The tables below contain descriptions of all alias formats recognized by the API. ### Generic Formats | Value | Description | |-------------------------|-------------------------------------------------------| | `NUM_LENGTH_PRESERVING` | Length-Preserving, Numeric | | `RAW_UUID` | UUID | | `UUID` | UUID (Prefixed, Base58-Encoded) | | `GENERIC_T_FOUR` | UUID (Prefixed, Base58-Encoded, Last four preserving) | ### Account Number Formats | Value | Description | |-----------------------------------|--------------------------------------| | `FPE_ACC_NUM_T_FOUR` | Length-Preserving, Numeric (A4) | | `FPE_ALPHANUMERIC_ACC_NUM_T_FOUR` | Length-Preserving, Alphanumeric (A4) | ### Payment Card Formats | Value | Description | |------------------|---------------------------------------------| | `FPE_SIX_T_FOUR` | Format-Preserving, Luhn Valid (6T4) | | `FPE_T_FOUR` | Format-Preserving, Luhn Valid (T4) | | `PFPT` | Prefixed, Luhn Valid, 19-Digit Fixed Length | ### SSN Formats | Value | Description | |------------------|------------------------| | `FPE_SSN_T_FOUR` | Format-Preserving (A4) | # Authentication This API uses `Basic` authentication. Credentials to access the API can be generated on the [dashboard](https://dashboard.verygoodsecurity.com) by going to the Settings section of the vault of your choosing. [Docs » Guides » Access credentials](https://www.verygoodsecurity.com/docs/settings/access-credentials) # Rate Limiting The API allows up to 3,000 requests per minute. Requests are associated with the vault, regardless of the access credentials used to authenticate the request. Your current rate limit is included as HTTP headers in every API response: | Header Name | Description | |-------------------------|----------------------------------------------------------| | `x-ratelimit-remaining` | The number of requests remaining in the 1-minute window. | If you exceed the rate limit, the API will reject the request with HTTP [429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). # Errors The API uses standard HTTP status codes to indicate whether the request succeeded or not. In case of failure, the response body will be JSON in a predefined format. For example, trying to create too many aliases at once results in the following response: ```json { \"errors\": [ { \"status\": 400, \"title\": \"Bad request\", \"detail\": \"Too many values (limit: 20)\", \"href\": \"https://api.sandbox.verygoodvault.com/aliases\" } ] } ```
|
7
7
|
|
8
8
|
The version of the OpenAPI document: 1.0.0
|
9
9
|
Contact: support@verygoodsecurity.com
|
10
10
|
Generated by: https://openapi-generator.tech
|
11
|
-
OpenAPI Generator version: 5.
|
11
|
+
OpenAPI Generator version: 5.0.1-SNAPSHOT
|
12
12
|
|
13
13
|
=end
|
14
14
|
|
@@ -17,7 +17,7 @@ require "vgs_api_client/version"
|
|
17
17
|
|
18
18
|
Gem::Specification.new do |s|
|
19
19
|
s.name = "vgs_api_client"
|
20
|
-
s.version =
|
20
|
+
s.version = VgsapiClient::VERSION
|
21
21
|
s.platform = Gem::Platform::RUBY
|
22
22
|
s.authors = ["Very Good Security"]
|
23
23
|
s.email = ["dev@verygoodsecurity.com"]
|
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
|
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-
|
11
|
+
date: 2022-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -57,13 +57,25 @@ executables: []
|
|
57
57
|
extensions: []
|
58
58
|
extra_rdoc_files: []
|
59
59
|
files:
|
60
|
-
- DEVELOPMENT.md
|
61
60
|
- Gemfile
|
62
|
-
-
|
63
|
-
-
|
61
|
+
- Gemfile.lock
|
62
|
+
- README.md
|
64
63
|
- Rakefile
|
65
|
-
-
|
66
|
-
-
|
64
|
+
- docs/AliasFormat.md
|
65
|
+
- docs/AliasesApi.md
|
66
|
+
- docs/ApiError.md
|
67
|
+
- docs/CreateAliasesRequest.md
|
68
|
+
- docs/CreateAliasesRequestExisting.md
|
69
|
+
- docs/CreateAliasesRequestNew.md
|
70
|
+
- docs/InlineResponse200.md
|
71
|
+
- docs/InlineResponse2001.md
|
72
|
+
- docs/InlineResponse201.md
|
73
|
+
- docs/InlineResponseDefault.md
|
74
|
+
- docs/ModelAlias.md
|
75
|
+
- docs/RevealedData.md
|
76
|
+
- docs/UpdateAliasRequest.md
|
77
|
+
- docs/UpdateAliasRequestData.md
|
78
|
+
- git_push.sh
|
67
79
|
- lib/vgs_api_client.rb
|
68
80
|
- lib/vgs_api_client/api/aliases_api.rb
|
69
81
|
- lib/vgs_api_client/api_client.rb
|
@@ -72,8 +84,8 @@ files:
|
|
72
84
|
- lib/vgs_api_client/models/alias_format.rb
|
73
85
|
- lib/vgs_api_client/models/api_error.rb
|
74
86
|
- lib/vgs_api_client/models/create_aliases_request.rb
|
87
|
+
- lib/vgs_api_client/models/create_aliases_request_existing.rb
|
75
88
|
- lib/vgs_api_client/models/create_aliases_request_new.rb
|
76
|
-
- lib/vgs_api_client/models/create_aliases_request_reference.rb
|
77
89
|
- lib/vgs_api_client/models/inline_response200.rb
|
78
90
|
- lib/vgs_api_client/models/inline_response2001.rb
|
79
91
|
- lib/vgs_api_client/models/inline_response201.rb
|
@@ -83,19 +95,23 @@ files:
|
|
83
95
|
- lib/vgs_api_client/models/update_alias_request.rb
|
84
96
|
- lib/vgs_api_client/models/update_alias_request_data.rb
|
85
97
|
- lib/vgs_api_client/version.rb
|
86
|
-
-
|
87
|
-
- scripts/assemble/run.sh
|
88
|
-
- scripts/publish.sh
|
89
|
-
- scripts/publish/Dockerfile
|
90
|
-
- scripts/publish/run.sh
|
91
|
-
- scripts/run-tests-e2e.sh
|
92
|
-
- scripts/run-tests.sh
|
93
|
-
- scripts/test/Dockerfile
|
94
|
-
- scripts/test/run.sh
|
98
|
+
- spec/api/aliases_api_spec.rb
|
95
99
|
- spec/api_client_spec.rb
|
96
100
|
- spec/configuration_spec.rb
|
101
|
+
- spec/models/alias_format_spec.rb
|
102
|
+
- spec/models/api_error_spec.rb
|
103
|
+
- spec/models/create_aliases_request_existing_spec.rb
|
104
|
+
- spec/models/create_aliases_request_new_spec.rb
|
105
|
+
- spec/models/create_aliases_request_spec.rb
|
106
|
+
- spec/models/inline_response2001_spec.rb
|
107
|
+
- spec/models/inline_response200_spec.rb
|
108
|
+
- spec/models/inline_response201_spec.rb
|
109
|
+
- spec/models/inline_response_default_spec.rb
|
110
|
+
- spec/models/model_alias_spec.rb
|
111
|
+
- spec/models/revealed_data_spec.rb
|
112
|
+
- spec/models/update_alias_request_data_spec.rb
|
113
|
+
- spec/models/update_alias_request_spec.rb
|
97
114
|
- spec/spec_helper.rb
|
98
|
-
- spec/test_aliases_api_spec.rb
|
99
115
|
- vgs_api_client.gemspec
|
100
116
|
homepage: https://openapi-generator.tech
|
101
117
|
licenses:
|
@@ -112,16 +128,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
128
|
version: '2.4'
|
113
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
130
|
requirements:
|
115
|
-
- - "
|
131
|
+
- - ">="
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
133
|
+
version: '0'
|
118
134
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.2.22
|
120
136
|
signing_key:
|
121
137
|
specification_version: 4
|
122
138
|
summary: A ruby wrapper for the VGS Vault API
|
123
139
|
test_files:
|
140
|
+
- spec/api/aliases_api_spec.rb
|
124
141
|
- spec/api_client_spec.rb
|
125
142
|
- spec/configuration_spec.rb
|
143
|
+
- spec/models/revealed_data_spec.rb
|
144
|
+
- spec/models/alias_format_spec.rb
|
145
|
+
- spec/models/create_aliases_request_new_spec.rb
|
146
|
+
- spec/models/api_error_spec.rb
|
147
|
+
- spec/models/inline_response2001_spec.rb
|
148
|
+
- spec/models/update_alias_request_spec.rb
|
149
|
+
- spec/models/create_aliases_request_spec.rb
|
150
|
+
- spec/models/update_alias_request_data_spec.rb
|
151
|
+
- spec/models/inline_response200_spec.rb
|
152
|
+
- spec/models/inline_response201_spec.rb
|
153
|
+
- spec/models/model_alias_spec.rb
|
154
|
+
- spec/models/inline_response_default_spec.rb
|
155
|
+
- spec/models/create_aliases_request_existing_spec.rb
|
126
156
|
- spec/spec_helper.rb
|
127
|
-
- spec/test_aliases_api_spec.rb
|
data/DEVELOPMENT.md
DELETED
data/LICENSE
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Copyright 2022, VERY GOOD SECURITY, Inc.
|
2
|
-
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
4
|
-
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
6
|
-
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
-
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
-
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/RELEASE.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Release
|
2
|
-
|
3
|
-
In order to release version of new library you have to create github release.
|
4
|
-
|
5
|
-
### Versioning
|
6
|
-
|
7
|
-
Libraries that have versions that follow SemVer versioning schema will be released.
|
8
|
-
|
9
|
-
### Release
|
10
|
-
|
11
|
-
After creating tag CI will take care of publishing library to artifact repository.
|
12
|
-
|
13
|
-
### Misc
|
14
|
-
|
15
|
-
In order to release new version of this library you have to have write permissions to this repo.
|
data/docker-compose.yaml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
version: '3.7'
|
2
|
-
|
3
|
-
services:
|
4
|
-
assemble:
|
5
|
-
build:
|
6
|
-
context: .
|
7
|
-
dockerfile: scripts/assemble/Dockerfile
|
8
|
-
environment:
|
9
|
-
LIB_VERSION: ${LIB_VERSION}
|
10
|
-
volumes:
|
11
|
-
- ./:/vgs-api-client/
|
12
|
-
publish:
|
13
|
-
build:
|
14
|
-
context: .
|
15
|
-
dockerfile: scripts/publish/Dockerfile
|
16
|
-
environment:
|
17
|
-
ARTIFACT_REPOSITORY_TOKEN: ${ARTIFACT_REPOSITORY_TOKEN}
|
18
|
-
LIB_VERSION: ${LIB_VERSION}
|
19
|
-
volumes:
|
20
|
-
- ./:/vgs-api-client/
|
21
|
-
test:
|
22
|
-
build:
|
23
|
-
context: .
|
24
|
-
dockerfile: scripts/test/Dockerfile
|
25
|
-
environment:
|
26
|
-
VAULT_API_USERNAME: US7oyrzRGmaKqi3ET8eSsECS
|
27
|
-
VAULT_API_PASSWORD: c06cf6d1-a35e-439d-91d1-8bd04e5fd9e5
|
28
|
-
VAULT_API_BASE_URI: https://api.sandbox.verygoodvault.com
|
29
|
-
VAULT_API_VAULT_ID: tntkxfmsefj
|
30
|
-
LIB_VERSION: ${LIB_VERSION}
|
31
|
-
volumes:
|
32
|
-
- ./:/vgs-api-client/
|
data/lib/vgs.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
module VGS
|
2
|
-
class VgsApiException < StandardError
|
3
|
-
end
|
4
|
-
|
5
|
-
class Aliases
|
6
|
-
def initialize(config)
|
7
|
-
@aliases_api = VgsApiClient::AliasesApi.new(VgsApiClient::ApiClient.new(config))
|
8
|
-
end
|
9
|
-
|
10
|
-
def redact(data)
|
11
|
-
begin
|
12
|
-
requests = data.map do |item|
|
13
|
-
VgsApiClient::CreateAliasesRequestNew.new(attributes = {
|
14
|
-
:format => VgsApiClient::AliasFormat.build_from_hash(item[:format]),
|
15
|
-
:classifiers => item[:classifiers],
|
16
|
-
:value => item[:value],
|
17
|
-
:storage => item[:storage]
|
18
|
-
})
|
19
|
-
end
|
20
|
-
|
21
|
-
create_aliases_request = VgsApiClient::CreateAliasesRequest.new(attributes = {
|
22
|
-
:data => requests
|
23
|
-
})
|
24
|
-
response = @aliases_api.create_aliases(opts = {
|
25
|
-
:create_aliases_request => create_aliases_request.to_hash
|
26
|
-
})
|
27
|
-
|
28
|
-
rescue
|
29
|
-
raise VgsApiException, "Failed to redact data #{ data }"
|
30
|
-
else
|
31
|
-
response.data
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def reveal(aliases)
|
37
|
-
begin
|
38
|
-
query = aliases.kind_of?(Array) ? aliases.join(",") : aliases
|
39
|
-
response = @aliases_api.reveal_multiple_aliases(q = query)
|
40
|
-
rescue
|
41
|
-
raise VgsApiException, "Failed to reveal aliases #{ aliases }"
|
42
|
-
else
|
43
|
-
response.data
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def delete(_alias)
|
48
|
-
begin
|
49
|
-
@aliases_api.delete_alias(_alias = _alias)
|
50
|
-
rescue
|
51
|
-
raise VgsApiException, "Failed to delete alias #{ _alias }"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def update(_alias, data)
|
56
|
-
begin
|
57
|
-
update_alias_request = VgsApiClient::UpdateAliasRequest.new(attributes = {
|
58
|
-
:data => VgsApiClient::UpdateAliasRequestData.new(attributes = {
|
59
|
-
:classifiers => data[:classifiers]
|
60
|
-
})
|
61
|
-
})
|
62
|
-
@aliases_api.update_alias(_alias = _alias, opts = {
|
63
|
-
:update_alias_request => update_alias_request.to_hash
|
64
|
-
})
|
65
|
-
rescue
|
66
|
-
raise VgsApiException, "Failed to update alias #{ _alias }"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.config(username, password, host = 'https://api.sandbox.verygoodvault.com')
|
72
|
-
raise ArgumentError, 'username is nil' if username.nil?
|
73
|
-
raise ArgumentError, 'password is nil' if password.nil?
|
74
|
-
|
75
|
-
config = VgsApiClient::Configuration.default
|
76
|
-
config.username = username
|
77
|
-
config.password = password
|
78
|
-
config.host = host
|
79
|
-
config
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
data/scripts/assemble/Dockerfile
DELETED
data/scripts/assemble/run.sh
DELETED
data/scripts/publish/Dockerfile
DELETED
data/scripts/publish/run.sh
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -e
|
4
|
-
|
5
|
-
usage() { echo "Required env var '$1' is missing"; exit 1; }
|
6
|
-
|
7
|
-
[ -z "${ARTIFACT_REPOSITORY_TOKEN}" ] && usage "ARTIFACT_REPOSITORY_TOKEN" ;
|
8
|
-
[ -z "${LIB_VERSION}" ] && usage "LIB_VERSION" ;
|
9
|
-
|
10
|
-
mkdir ~/.gem
|
11
|
-
echo ":rubygems_api_key: ${ARTIFACT_REPOSITORY_TOKEN}" > ~/.gem/credentials
|
12
|
-
chmod 0600 ~/.gem/credentials
|
13
|
-
|
14
|
-
gem push vgs_api_client-${LIB_VERSION}.gem
|
data/scripts/publish.sh
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -e
|
4
|
-
|
5
|
-
usage() { echo "Required env var '$1' is missing"; exit 1; }
|
6
|
-
|
7
|
-
[ -z "${ARTIFACT_REPOSITORY_TOKEN}" ] && usage "ARTIFACT_REPOSITORY_TOKEN" ;
|
8
|
-
[ -z "${LIB_VERSION}" ] && usage "LIB_VERSION" ;
|
9
|
-
|
10
|
-
docker-compose build && \
|
11
|
-
docker-compose run assemble && \
|
12
|
-
docker-compose run publish
|
data/scripts/run-tests-e2e.sh
DELETED
data/scripts/run-tests.sh
DELETED
data/scripts/test/Dockerfile
DELETED
data/scripts/test/run.sh
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
set -e
|
4
|
-
|
5
|
-
rm vgs_api_client-*.gem || true
|
6
|
-
|
7
|
-
if [[ -n "${LIB_VERSION}" ]]; then
|
8
|
-
echo "Installing lib from rubygems.org ${LIB_VERSION} ..."
|
9
|
-
|
10
|
-
set +e
|
11
|
-
ATTEMPT=1
|
12
|
-
while [ $ATTEMPT -lt 60 ]; do
|
13
|
-
echo "Attempt ${ATTEMPT} ..."
|
14
|
-
|
15
|
-
bundle install --without production --binstubs
|
16
|
-
gem install vgs_api_client -v ${LIB_VERSION}
|
17
|
-
|
18
|
-
if [[ $? == 0 ]]; then
|
19
|
-
echo "Installed ${LIB_VERSION}"
|
20
|
-
break
|
21
|
-
fi
|
22
|
-
|
23
|
-
ATTEMPT=$((ATTEMPT+1))
|
24
|
-
|
25
|
-
sleep 5
|
26
|
-
done
|
27
|
-
set -e
|
28
|
-
else
|
29
|
-
echo "Installing lib from local sources"
|
30
|
-
# fix version
|
31
|
-
VERSION=0.0.1.dev$(date "+%Y%m%d%H%M")
|
32
|
-
grep -rl 0.0.1.dev202204201806 . | xargs sed -i "s/0.0.1.dev202204201806/$VERSION/g"
|
33
|
-
|
34
|
-
bundle install
|
35
|
-
fi
|
36
|
-
|
37
|
-
bundle exec rspec ./spec/*.rb
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'securerandom'
|
3
|
-
require 'vgs'
|
4
|
-
|
5
|
-
describe 'AliasesApiSpec' do
|
6
|
-
before(:all) do
|
7
|
-
config = VGS.config(username = ENV["VAULT_API_USERNAME"], password = ENV["VAULT_API_PASSWORD"])
|
8
|
-
@aliases_api = VGS::Aliases.new(config)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'redact' do
|
12
|
-
it 'should redact values' do
|
13
|
-
data = [
|
14
|
-
{
|
15
|
-
:format => 'UUID',
|
16
|
-
:value => '5201784564572092',
|
17
|
-
:classifiers => %w[credit-card number],
|
18
|
-
:storage => 'PERSISTENT',
|
19
|
-
},
|
20
|
-
{
|
21
|
-
:format => 'UUID',
|
22
|
-
:value => 'Joe Doe',
|
23
|
-
:storage => 'VOLATILE',
|
24
|
-
}
|
25
|
-
]
|
26
|
-
aliases = @aliases_api.redact(data)
|
27
|
-
expect(aliases.length).to eq 2
|
28
|
-
data.each_with_index do |item, index|
|
29
|
-
expect(aliases[index].value).to eq item[:value]
|
30
|
-
expect(aliases[index].storage).to eq item[:storage]
|
31
|
-
expect(aliases[index].aliases[0]._alias).to start_with "tok_"
|
32
|
-
end
|
33
|
-
expect(Set.new(aliases[0].classifiers)).to eq Set.new(%w[credit-card number])
|
34
|
-
expect(Set.new(aliases[1].classifiers)).to eq Set.new
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'reveal' do
|
39
|
-
it 'should reveal aliases' do
|
40
|
-
data = [
|
41
|
-
{
|
42
|
-
:format => 'UUID',
|
43
|
-
:value => '5201784564572092',
|
44
|
-
:classifiers => %w[credit-card number],
|
45
|
-
:storage => 'PERSISTENT',
|
46
|
-
},
|
47
|
-
{
|
48
|
-
:format => 'UUID',
|
49
|
-
:value => 'Joe Doe',
|
50
|
-
:storage => 'VOLATILE',
|
51
|
-
}
|
52
|
-
]
|
53
|
-
aliases = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }
|
54
|
-
|
55
|
-
response = @aliases_api.reveal(aliases)
|
56
|
-
|
57
|
-
expect(response.length).to eq 2
|
58
|
-
original_values = data.map { |i| i[:value] }
|
59
|
-
revealed_values = response.values.map { |i| i.value }
|
60
|
-
expect(Set.new(original_values)).to eq Set.new(revealed_values)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'update' do
|
65
|
-
it 'should update alias' do
|
66
|
-
data = [
|
67
|
-
{
|
68
|
-
:format => 'UUID',
|
69
|
-
:value => SecureRandom.alphanumeric(10),
|
70
|
-
}
|
71
|
-
]
|
72
|
-
_alias = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }[0]
|
73
|
-
|
74
|
-
@aliases_api.update(_alias = _alias, data = { :classifiers => ["secure"] })
|
75
|
-
|
76
|
-
response = @aliases_api.reveal(_alias)
|
77
|
-
expect(response[_alias].classifiers).to eq %w[secure]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'delete' do
|
82
|
-
it 'should delete alias' do
|
83
|
-
data = [
|
84
|
-
{
|
85
|
-
:format => 'UUID',
|
86
|
-
:value => '5201784564572092',
|
87
|
-
}
|
88
|
-
]
|
89
|
-
_alias = @aliases_api.redact(data).map { |item| item.aliases[0]._alias }[0]
|
90
|
-
|
91
|
-
@aliases_api.delete(_alias = _alias)
|
92
|
-
|
93
|
-
expect { @aliases_api.reveal(_alias) }.to raise_error(VGS::VgsApiException)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|