pco-url 1.9.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +70 -0
- data/.rubocop.yml +5 -2
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +42 -1
- data/lib/pco/url.rb +3 -3
- data/lib/pco/url/encryption.rb +122 -0
- data/lib/pco/url/version.rb +1 -1
- data/pco-url.gemspec +1 -1
- data/spec/.rubocop.yml +4 -0
- data/spec/pco/url/encryption_spec.rb +121 -0
- data/spec/pco_url_spec.rb +7 -3
- data/spec/spec_helper.rb +5 -0
- metadata +24 -18
- data/circle.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad5229c15a12077f471c25fca3288c285b2c687
|
4
|
+
data.tar.gz: aadeaab05a5ea105f5ad32d30fabbfd32c00cb6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27e08f5cdc63de25d4cfcedfde96a4c8b06612adee3553c5d7ed43b5b37734ec70c609b9aaf1a3578f5b5d13769aa282460d4d8cb02af5ca49d16cf6c8b03053
|
7
|
+
data.tar.gz: 6a055c9dbb973275dceb0e909e3abea22dc7513b8d633e8f97b1ee2cd3bc485040d973e64525f9d4e1f76087ffdaac372c2e40d219152cdda8c75ad51719aa28
|
@@ -0,0 +1,70 @@
|
|
1
|
+
version: 2 # use CircleCI 2.0
|
2
|
+
jobs: # a collection of steps
|
3
|
+
"ruby-2.3": # runs not using Workflows must have a `build` job as entry point
|
4
|
+
docker: # run the steps with Docker
|
5
|
+
- image: circleci/ruby:2.3
|
6
|
+
environment: # environment variables for primary container
|
7
|
+
BUNDLE_JOBS: 3
|
8
|
+
BUNDLE_RETRY: 3
|
9
|
+
BUNDLE_PATH: vendor/bundle
|
10
|
+
steps: # a collection of executable commands
|
11
|
+
- checkout # special step to check out source code to working directory
|
12
|
+
|
13
|
+
# Restore bundle cache
|
14
|
+
- restore_cache:
|
15
|
+
keys:
|
16
|
+
- pco-url-bundle-v2-ruby23-{{ checksum "pco-url.gemspec" }}
|
17
|
+
- pco-url-bundle-v2-ruby23-
|
18
|
+
|
19
|
+
- run:
|
20
|
+
name: Bundle Install
|
21
|
+
command: bundle check || bundle install
|
22
|
+
|
23
|
+
# Store bundle cache
|
24
|
+
- save_cache:
|
25
|
+
key: pco-url-bundle-v2-ruby23-{{ checksum "pco-url.gemspec" }}
|
26
|
+
paths:
|
27
|
+
- vendor/bundle
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: Run rspec
|
31
|
+
command: |
|
32
|
+
bundle exec rspec --format progress
|
33
|
+
|
34
|
+
"ruby-2.4": # runs not using Workflows must have a `build` job as entry point
|
35
|
+
docker: # run the steps with Docker
|
36
|
+
- image: circleci/ruby:2.4
|
37
|
+
environment: # environment variables for primary container
|
38
|
+
BUNDLE_JOBS: 3
|
39
|
+
BUNDLE_RETRY: 3
|
40
|
+
BUNDLE_PATH: vendor/bundle
|
41
|
+
steps: # a collection of executable commands
|
42
|
+
- checkout # special step to check out source code to working directory
|
43
|
+
|
44
|
+
# Restore bundle cache
|
45
|
+
- restore_cache:
|
46
|
+
keys:
|
47
|
+
- pco-url-bundle-v2-ruby24-{{ checksum "pco-url.gemspec" }}
|
48
|
+
- pco-url-bundle-v2-ruby24-
|
49
|
+
|
50
|
+
- run:
|
51
|
+
name: Bundle Install
|
52
|
+
command: bundle check || bundle install
|
53
|
+
|
54
|
+
# Store bundle cache
|
55
|
+
- save_cache:
|
56
|
+
key: pco-url-bundle-v2-ruby24-{{ checksum "pco-url.gemspec" }}
|
57
|
+
paths:
|
58
|
+
- vendor/bundle
|
59
|
+
|
60
|
+
- run:
|
61
|
+
name: Run rspec
|
62
|
+
command: |
|
63
|
+
bundle exec rspec --format progress
|
64
|
+
|
65
|
+
workflows:
|
66
|
+
version: 2
|
67
|
+
build:
|
68
|
+
jobs:
|
69
|
+
- "ruby-2.3"
|
70
|
+
- "ruby-2.4"
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
|
1
4
|
Style/StringLiterals:
|
2
5
|
Enabled: true
|
3
6
|
EnforcedStyle: double_quotes
|
@@ -8,5 +11,5 @@ Metrics/LineLength:
|
|
8
11
|
Style/Documentation:
|
9
12
|
Enabled: false
|
10
13
|
|
11
|
-
|
12
|
-
Enabled: false
|
14
|
+
Layout/SpaceBeforeFirstArg:
|
15
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -46,4 +46,45 @@ PCO::URL.accounts("test")
|
|
46
46
|
|
47
47
|
PCO::URL.accounts("test", "working")
|
48
48
|
# => "https://accounts-test1.planningcenteronline.com/test/working"
|
49
|
-
```
|
49
|
+
```
|
50
|
+
|
51
|
+
### Encryption
|
52
|
+
|
53
|
+
`pco-url` includes URL-safe encryption utilites in the `PCO::URL::Encryption` module.
|
54
|
+
|
55
|
+
It uses `aes-256-cbc` for encryption, and the code is ported from [URLcrypt](https://github.com/cheerful/URLcrypt).
|
56
|
+
|
57
|
+
The encryption/decryption key **should** be 32 bytes. In Ruby <= 2.3, a longer key will be automatically truncated by the `OpenSSL` library, but starting with Ruby >= 2.4, the encryption will fail if the key is not exactly 32 bytes. If you currently are using a key that isn't 32 bytes, you will have to change the key to upgrade to Ruby 2.4.
|
58
|
+
|
59
|
+
#### Setup
|
60
|
+
|
61
|
+
`PCO::URL::Encryption` can be used with a global default encryption key, or a specific key for each encrypt/decrypt step.
|
62
|
+
|
63
|
+
To set a default key:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# for example, in an initializer
|
67
|
+
|
68
|
+
PCO::URL::Encryption.default_key = "32 bytes of randomness"
|
69
|
+
```
|
70
|
+
|
71
|
+
**note:** if you set a default key, `pco-url` will raise an error on any attempt to modify the default key. If you need to use multiple keys in your app, use the keyword argument syntax to set it for each encryption/decryption.
|
72
|
+
|
73
|
+
#### Usage
|
74
|
+
|
75
|
+
To encrypt with the global default key
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
# encrypt with the global default key
|
79
|
+
PCO::URL::Encryption.encrypt("sekret") # => qmj1w631bs6hd3cyf8h5kv37n3Zxxvgyr4j5jvsll0x65f7vcm9sm
|
80
|
+
|
81
|
+
# decrypt with the global default key
|
82
|
+
PCO::URL::Encryption.decrypt("qmj1w631bs6hd3cyf8h5kv37n3Zxxvgyr4j5jvsll0x65f7vcm9sm") # => sekret
|
83
|
+
|
84
|
+
# encrypt with a specific key
|
85
|
+
thirty_two_byte_string = "192c0ba7369e27f4b04fa304030712c8"
|
86
|
+
|
87
|
+
PCO::URL::Encryption.encrypt("sekret", key: thirty_two_byte_string) # => rxnfnstyt6fvs618A8Abwtg1c1Zyqhgf0lhtqtmypc4t0zlhxyr02
|
88
|
+
|
89
|
+
PCO::URL::Encryption.decrypt("rxnfnstyt6fvs618A8Abwtg1c1Zyqhgf0lhtqtmypc4t0zlhxyr02", key: thirty_two_byte_string) # => sekret
|
90
|
+
```
|
data/lib/pco/url.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require_relative "url/version"
|
2
2
|
require_relative "url/church_center"
|
3
3
|
require_relative "url/get"
|
4
|
+
require_relative "url/encryption"
|
4
5
|
require "uri"
|
5
|
-
require "URLcrypt"
|
6
6
|
|
7
7
|
module PCO
|
8
8
|
class URL
|
9
9
|
class << self
|
10
10
|
def decrypt_query_params(string)
|
11
|
-
|
11
|
+
Encryption.decrypt(string)
|
12
12
|
end
|
13
13
|
|
14
14
|
def parse(string)
|
@@ -62,7 +62,7 @@ module PCO
|
|
62
62
|
@path = @path[1..-1] if @path && @path[0] == "/"
|
63
63
|
|
64
64
|
if query
|
65
|
-
@query = encrypt_query_params ? "_e=#{
|
65
|
+
@query = encrypt_query_params ? "_e=#{Encryption.encrypt(query)}" : query
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# Sourced from https://github.com/cheerful/URLcrypt/blob/v0.1.1/lib/URLcrypt.rb
|
2
|
+
#
|
3
|
+
# Copyright (c) 2013-2015 Thomas Fuchs
|
4
|
+
# Copyright (c) 2007-2011 Samuel Tesla
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
|
24
|
+
require "openssl"
|
25
|
+
|
26
|
+
module PCO
|
27
|
+
class URL
|
28
|
+
module Encryption
|
29
|
+
class DecryptError < ::ArgumentError; end
|
30
|
+
class MissingKeyError < ::ArgumentError; end
|
31
|
+
|
32
|
+
# avoid vowels to not generate four-letter words, etc.
|
33
|
+
# this is important because those words can trigger spam
|
34
|
+
# filters when URLs are used in emails
|
35
|
+
TABLE = "1bcd2fgh3jklmn4pqrstAvwxyz567890".freeze
|
36
|
+
|
37
|
+
class Chunk
|
38
|
+
def initialize(bytes)
|
39
|
+
@bytes = bytes
|
40
|
+
end
|
41
|
+
|
42
|
+
def decode # rubocop:disable Metrics/AbcSize
|
43
|
+
bytes = @bytes.take_while { |c| c != 61 } # strip padding
|
44
|
+
bytes = bytes.find_all { |b| !TABLE.index(b.chr).nil? } # remove invalid characters
|
45
|
+
n = (bytes.length * 5.0 / 8.0).floor
|
46
|
+
p = bytes.length < 8 ? 5 - (n * 8) % 5 : 0
|
47
|
+
c = bytes.inject(0) { |m, o| (m << 5) + TABLE.index(o.chr) } >> p
|
48
|
+
(0..(n - 1)).to_a.reverse.collect { |i| ((c >> i * 8) & 0xff).chr }
|
49
|
+
end
|
50
|
+
|
51
|
+
def encode # rubocop:disable Metrics/AbcSize
|
52
|
+
n = (@bytes.length * 8.0 / 5.0).ceil
|
53
|
+
p = n < 8 ? 5 - (@bytes.length * 8) % 5 : 0
|
54
|
+
c = @bytes.inject(0) { |m, o| (m << 8) + o } << p
|
55
|
+
[
|
56
|
+
(0..(n - 1)).to_a.reverse.collect { |i| TABLE[(c >> i * 5) & 0x1f].chr },
|
57
|
+
("=" * (8 - n))
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class << self
|
63
|
+
def default_key=(key)
|
64
|
+
raise(<<~ERR) if defined?(@default_key) && @default_key != key
|
65
|
+
Don't change the default_key during the life of a process.
|
66
|
+
This configuration variable is meant to be set once on boot and not
|
67
|
+
touched again.
|
68
|
+
|
69
|
+
If your app needs to use multiple keys, pass them in explicitly to `encrypt`
|
70
|
+
and `decrypt`
|
71
|
+
ERR
|
72
|
+
|
73
|
+
@default_key = key
|
74
|
+
end
|
75
|
+
|
76
|
+
def decrypt(data, key: @default_key)
|
77
|
+
raise MissingKeyError, "default key or key: argument must be set" if key.nil?
|
78
|
+
iv, encrypted = data.split("Z").map { |part| decode(part) }
|
79
|
+
raise DecryptError, "not a valid string to decrypt" unless iv && encrypted
|
80
|
+
decrypter = cipher(:decrypt, key: key)
|
81
|
+
decrypter.iv = iv
|
82
|
+
decrypter.update(encrypted) + decrypter.final
|
83
|
+
end
|
84
|
+
|
85
|
+
def encrypt(data, key: @default_key)
|
86
|
+
raise MissingKeyError, "default key or key: argument must be set" if key.nil?
|
87
|
+
crypter = cipher(:encrypt, key: key)
|
88
|
+
crypter.iv = iv = crypter.random_iv
|
89
|
+
"#{encode(iv)}Z#{encode(crypter.update(data) + crypter.final)}"
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def chunks(str, size)
|
95
|
+
result = []
|
96
|
+
bytes = str.bytes
|
97
|
+
while bytes.any?
|
98
|
+
result << Chunk.new(bytes.take(size))
|
99
|
+
bytes = bytes.drop(size)
|
100
|
+
end
|
101
|
+
result
|
102
|
+
end
|
103
|
+
|
104
|
+
# strip "=" padding, because we don"t need it
|
105
|
+
def encode(data)
|
106
|
+
chunks(data, 5).collect(&:encode).flatten.join.tr("=", "")
|
107
|
+
end
|
108
|
+
|
109
|
+
def decode(data)
|
110
|
+
chunks(data, 8).collect(&:decode).flatten.join
|
111
|
+
end
|
112
|
+
|
113
|
+
def cipher(mode, key:)
|
114
|
+
cipher = OpenSSL::Cipher.new("aes-256-cbc")
|
115
|
+
cipher.public_send(mode)
|
116
|
+
cipher.key = key
|
117
|
+
cipher
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/pco/url/version.rb
CHANGED
data/pco-url.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "urlcrypt", ">= 0.1.1"
|
21
20
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
22
|
spec.add_development_dependency "rspec", ">= 3.0.0", "< 4"
|
23
|
+
spec.add_development_dependency "rubocop", "0.54.0"
|
24
24
|
end
|
data/spec/.rubocop.yml
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PCO::URL::Encryption do
|
4
|
+
# rubocop:disable Metrics/LineLength
|
5
|
+
TEST_DEFAULT_KEY = "b01b94f55e543afee167392ea43f8245".freeze
|
6
|
+
TEST_SPECIFIC_KEY = "97f44346e1cfa9f5fc19463fd182c495".freeze
|
7
|
+
# rubocop:enable Metrics/LineLength
|
8
|
+
|
9
|
+
after { reset_encryption_default_key }
|
10
|
+
|
11
|
+
it "gets mad if you try to change the default key" do
|
12
|
+
described_class.default_key = "key!"
|
13
|
+
|
14
|
+
expect { described_class.default_key = "new key!" }.to raise_error(/change the default_key/i)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "without a specific key" do
|
18
|
+
context "when a default key is set" do
|
19
|
+
it "encrypts and decrypts correctly" do
|
20
|
+
described_class.default_key = TEST_DEFAULT_KEY
|
21
|
+
encrypted = described_class.encrypt("BoJack")
|
22
|
+
decrypted = described_class.decrypt(encrypted)
|
23
|
+
|
24
|
+
expect(decrypted).to eq("BoJack")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "decrypts correctly" do
|
28
|
+
described_class.default_key = TEST_DEFAULT_KEY
|
29
|
+
encrypted = "gktp1A49k6kmbz7ktfwrzwlmc2Zn8t95d4lq9bc62mr252d0542k1"
|
30
|
+
|
31
|
+
expect(described_class.decrypt(encrypted)).to eq("Horseman")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when no default key is set" do
|
36
|
+
it "fails loudly because no key is set" do
|
37
|
+
expect { described_class.encrypt("value") }.to raise_error(described_class::MissingKeyError)
|
38
|
+
expect { described_class.decrypt("value") }.to raise_error(described_class::MissingKeyError)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "using a specified key" do
|
44
|
+
it "encrypts and decrypts correctly" do
|
45
|
+
encrypted = described_class.encrypt("You are Secretariat", key: TEST_SPECIFIC_KEY)
|
46
|
+
decrypted = described_class.decrypt(encrypted, key: TEST_SPECIFIC_KEY)
|
47
|
+
|
48
|
+
expect(decrypted).to eq("You are Secretariat")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "decrypts correctly" do
|
52
|
+
encrypted = "lbklbyhw9pkgs3mqtc5p000xz1Zqrdrkf1f3phmhvzfksgg2Aqdg78kngpv3r5zz1fll6z5cvn96j11"
|
53
|
+
|
54
|
+
expect(described_class.decrypt(encrypted, key: TEST_SPECIFIC_KEY)).to eq("Do the funky Spiderman")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "the original URLcrypt tests" do
|
59
|
+
def private_encode(plain)
|
60
|
+
described_class.send(:encode, plain)
|
61
|
+
end
|
62
|
+
|
63
|
+
def private_decode(encded)
|
64
|
+
described_class.send(:decode, encded)
|
65
|
+
end
|
66
|
+
|
67
|
+
def expect_bytes_equal(string1, string2)
|
68
|
+
bytes1 = string1.bytes.to_a.join(":")
|
69
|
+
bytes2 = string2.bytes.to_a.join(":")
|
70
|
+
expect(bytes1).to eq(bytes2)
|
71
|
+
end
|
72
|
+
|
73
|
+
def expect_decoding(encoded, plain)
|
74
|
+
expect_bytes_equal(plain, private_decode(encoded))
|
75
|
+
end
|
76
|
+
|
77
|
+
def expect_encoding(encoded, plain)
|
78
|
+
expect_bytes_equal(encoded, private_encode(plain))
|
79
|
+
end
|
80
|
+
|
81
|
+
it "test empty string" do
|
82
|
+
expect_encoding("", "")
|
83
|
+
expect_decoding("", "")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "encodes and decodes properly" do
|
87
|
+
encoded = "111gc86f4nxw5zj1b3qmhpb14n5h25l4m7111"
|
88
|
+
plain = "\0\0awesome \n ü string\0\0"
|
89
|
+
|
90
|
+
expect_encoding(encoded, plain)
|
91
|
+
expect_decoding(encoded, plain)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "test invalid decoding" do
|
95
|
+
expect_decoding("ZZZZZ", "")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "test arbitrary byte strings" do
|
99
|
+
0.step(1500, 17) do |n|
|
100
|
+
original = (0..n).map { rand(256).chr }.join
|
101
|
+
encoded = private_encode(original)
|
102
|
+
expect_decoding(encoded, original)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "test encryption" do
|
107
|
+
described_class.default_key = "3c3ff314c12b786da43a50b571c0aedc"
|
108
|
+
|
109
|
+
original = "hello world!"
|
110
|
+
encrypted = described_class.encrypt(original)
|
111
|
+
expect(described_class.decrypt(encrypted)).to eq(original)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "test decrypt error" do
|
115
|
+
described_class.default_key = "some key"
|
116
|
+
expect { described_class.decrypt("just some plaintext") }
|
117
|
+
.to raise_error(described_class::DecryptError)
|
118
|
+
.with_message("not a valid string to decrypt")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/spec/pco_url_spec.rb
CHANGED
@@ -14,8 +14,12 @@ APPLICATIONS = [
|
|
14
14
|
|
15
15
|
describe PCO::URL do
|
16
16
|
before :all do
|
17
|
-
|
18
|
-
|
17
|
+
PCO::URL::Encryption.default_key =
|
18
|
+
"\xF7\xFE\x99I\x1EkO\xD4\xD3\v\x96\x8A\b\x17\xD8m\x01jr\x8F\xA0L.\xB3\xF3\x12\xD7c\x16\xA8\xD0."
|
19
|
+
end
|
20
|
+
|
21
|
+
after :all do
|
22
|
+
reset_encryption_default_key
|
19
23
|
end
|
20
24
|
|
21
25
|
describe "defaults" do
|
@@ -177,7 +181,7 @@ describe PCO::URL do
|
|
177
181
|
end
|
178
182
|
|
179
183
|
it "encrypts and decrypts URL parameters" do
|
180
|
-
expect(
|
184
|
+
expect(PCO::URL::Encryption.decrypt(subject.query.gsub("_e=", ""))).to eq("foo=bar")
|
181
185
|
end
|
182
186
|
|
183
187
|
it "decrypts using #decrypt_query_params" do
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,11 @@ RSpec.configure do |config|
|
|
5
5
|
config.color = true
|
6
6
|
config.filter_run focus: true
|
7
7
|
config.run_all_when_everything_filtered = true
|
8
|
+
|
9
|
+
def reset_encryption_default_key
|
10
|
+
return unless PCO::URL::Encryption.instance_variable_defined?(:@default_key)
|
11
|
+
PCO::URL::Encryption.remove_instance_variable(:@default_key)
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
class Rails
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pco-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: urlcrypt
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.1
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +58,20 @@ dependencies:
|
|
72
58
|
- - "<"
|
73
59
|
- !ruby/object:Gem::Version
|
74
60
|
version: '4'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.54.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.54.0
|
75
75
|
description:
|
76
76
|
email:
|
77
77
|
- bensie@gmail.com
|
@@ -79,21 +79,25 @@ executables: []
|
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
|
+
- ".circleci/config.yml"
|
82
83
|
- ".editorconfig"
|
83
84
|
- ".gitignore"
|
84
85
|
- ".rubocop.yml"
|
86
|
+
- ".ruby-version"
|
85
87
|
- CHANGELOG.md
|
86
88
|
- Gemfile
|
87
89
|
- LICENSE.txt
|
88
90
|
- README.md
|
89
91
|
- Rakefile
|
90
|
-
- circle.yml
|
91
92
|
- lib/pco/url.rb
|
92
93
|
- lib/pco/url/church_center.rb
|
94
|
+
- lib/pco/url/encryption.rb
|
93
95
|
- lib/pco/url/get.rb
|
94
96
|
- lib/pco/url/version.rb
|
95
97
|
- pco-url.gemspec
|
98
|
+
- spec/.rubocop.yml
|
96
99
|
- spec/pco/url/church_center_spec.rb
|
100
|
+
- spec/pco/url/encryption_spec.rb
|
97
101
|
- spec/pco_url_spec.rb
|
98
102
|
- spec/spec_helper.rb
|
99
103
|
homepage: https://github.com/ministrycentered/pco-url
|
@@ -116,11 +120,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
120
|
version: '0'
|
117
121
|
requirements: []
|
118
122
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.5.2
|
123
|
+
rubygems_version: 2.5.2.3
|
120
124
|
signing_key:
|
121
125
|
specification_version: 4
|
122
126
|
summary: Generate URLs for PCO apps in all environments
|
123
127
|
test_files:
|
128
|
+
- spec/.rubocop.yml
|
124
129
|
- spec/pco/url/church_center_spec.rb
|
130
|
+
- spec/pco/url/encryption_spec.rb
|
125
131
|
- spec/pco_url_spec.rb
|
126
132
|
- spec/spec_helper.rb
|
data/circle.yml
DELETED