barsoom_utils 0.1.1.20 → 0.1.1.23

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: 8a9d9d936980d3e0cab4dc064368e398d1ea7dadb5a8244a42b2dbdaf49155bf
4
- data.tar.gz: 3931d23a734c47a960942b5ccc5c05ec6e251a46900bfdcbd05bf6f4171a3f3c
3
+ metadata.gz: 8c5296ac79801731d811f20918a97549e16fd0976421af34c152c28fcf287a59
4
+ data.tar.gz: a9f683bb10d8039b24c6d72326f60650d819335731e29282a894b07aa751156d
5
5
  SHA512:
6
- metadata.gz: a4c50cf5b7f5915da3a7a4aabe822c972f4a66618050884fcc2233ff44b3850355ef3f5a6a3de7ecc2394ee8d6a276a96851be10019accc4c1c24e443da313a0
7
- data.tar.gz: 5da6258d39fe440cdc25bf572ddd1648ccbdca1955bb4f85cfbfb210c5ac58e246956821c87aab40bb098dd305c06883ad8fe66d9db16f1da9cccc0a45310511
6
+ metadata.gz: 707dc2525e0a8073c8c7bda645b8362ce26404f4e572b929c8c473297872a4738e68ad39efa56811c235db08a8aa56ba29d4eb28aa116376b8566446784a27f5
7
+ data.tar.gz: 9c87b37e7dca2195357848180d54df9594dea3d4e7319e461bda2397a5d59ab883006e361bf90188c6bcfd1c545737334f974450343998deced22262e569facd
data/.exrc ADDED
@@ -0,0 +1,6 @@
1
+ " To enable per-directory .exrc files, add the following lines to your ~/.vimrc
2
+ "
3
+ " set exrc " enable per-directory .exrc files
4
+ " set secure " disable unsafe commands in local .exrc files
5
+
6
+ let g:turbux_command_rspec = 'script/test'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1.20
1
+ 0.1.1.23
@@ -0,0 +1,17 @@
1
+ require "attr_extras"
2
+
3
+ module BarsoomUtils
4
+ class ParseSpaceSeparatedTokenValues
5
+ method_object :value, [ :minimum_key_size!, :token_name! ]
6
+
7
+ def call
8
+ keys = value.split
9
+
10
+ raise "Missing #{token_name}. Quitting." if keys.empty?
11
+
12
+ raise "Invalid #{token_name}: a too-short element found. Did a key contain a space? Quitting!" if keys.any? { |api_key| api_key.size < minimum_key_size }
13
+
14
+ keys.freeze
15
+ end
16
+ end
17
+ end
data/shared_rubocop.yml CHANGED
@@ -10,6 +10,8 @@ AllCops:
10
10
  - node_modules/**/*
11
11
  - tmp/**/*
12
12
  - deploy/tmp/**/*
13
+ # Will only enable new cops for the subset of cops that are enabled. https://docs.rubocop.org/rubocop/versioning.html#pending-cops
14
+ NewCops: enable
13
15
 
14
16
  # Enable all Security cops
15
17
  Security:
@@ -0,0 +1,39 @@
1
+ require "barsoom_utils/parse_space_separated_token_values"
2
+
3
+ RSpec.describe BarsoomUtils::ParseSpaceSeparatedTokenValues do
4
+ let(:minimum_key_size) { 4 }
5
+ let(:long_enough_api_key) { "xyza" }
6
+ let(:token_name) { "API_TOKENS" }
7
+
8
+ subject(:parsed_value) {
9
+ described_class.call(api_tokens_value, minimum_key_size: minimum_key_size, token_name: token_name)
10
+ }
11
+
12
+ context "with a valid set of tokens" do
13
+ let(:api_tokens_value) { "#{long_enough_api_key} b#{long_enough_api_key}" }
14
+
15
+ it "returns a frozen array" do
16
+ expect(parsed_value).to(
17
+ be_an(Array)
18
+ .and(have_attributes(size: 2))
19
+ .and(be_frozen)
20
+ )
21
+ end
22
+ end
23
+
24
+ context "with one too-short token" do
25
+ let(:api_tokens_value) { "x #{long_enough_api_key}" }
26
+
27
+ it "raises an error" do
28
+ expect { parsed_value }.to raise_error(/Invalid API_TOKENS/)
29
+ end
30
+ end
31
+
32
+ context "with a blank value" do
33
+ let(:api_tokens_value) { " " }
34
+
35
+ it "raises an error" do
36
+ expect { parsed_value }.to raise_error(/Missing API_TOKENS/)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barsoom_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.20
4
+ version: 0.1.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Skogberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-02 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".exrc"
20
21
  - ".github/workflows/ci.yml"
21
22
  - ".gitignore"
22
23
  - ".rspec"
@@ -29,12 +30,14 @@ files:
29
30
  - lib/barsoom_utils.rb
30
31
  - lib/barsoom_utils/exception_notifier.rb
31
32
  - lib/barsoom_utils/feature_toggle.rb
33
+ - lib/barsoom_utils/parse_space_separated_token_values.rb
32
34
  - lib/barsoom_utils/ping_health_check.rb
33
35
  - lib/barsoom_utils/spec/debug_helpers.rb
34
36
  - lib/barsoom_utils/version.rb
35
37
  - script/test
36
38
  - shared_rubocop.yml
37
39
  - shared_rubocop_rails.yml
40
+ - spec/barsoom_utils/parse_space_separated_token_values_spec.rb
38
41
  - spec/exception_notifier_spec.rb
39
42
  - spec/feature_toggle_spec.rb
40
43
  - spec/ping_health_check_spec.rb