manageiq-password 0.2.1 → 0.3.0

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
- SHA1:
3
- metadata.gz: b127f2c405022be724b5b609c6ab4876c4bee785
4
- data.tar.gz: c753a2c52ad8c40eeee847817cd787a20d7b9ea2
2
+ SHA256:
3
+ metadata.gz: 21eeaae385f4eadc2ca2cd9bebd5127e3139a8392a54eeb767e8b2481ada3f11
4
+ data.tar.gz: 92ea5e0fd4d9a2609cc960025cb0f4537049d9efa11c75a7d97120faed516854
5
5
  SHA512:
6
- metadata.gz: 23ae2169c3f0e716c6095979275e21460336e2f1609a7b48f3b0596cdea23e8a2681c1c571ee3efc4ac4f35450162396cb7fcd44bd6a5b3f007789d5cd7e0aff
7
- data.tar.gz: bc72b27b066d950244ca9bdb11468796fd74821edd84661ec2749a99c66c581afd9784ab909c423e1cde2e5bd1effaf2a79d2476467df74ad9eaa6202e5ef780
6
+ metadata.gz: 00ee2ce9764d6420633663fabfb255ce39288c131869472fd5d7b510767156ea90a37cf200f1516b21b66745d934264f2dee3dcaf1eac4f6e4b463561aca18e7
7
+ data.tar.gz: 905c37a40c89f39d99cfdc7503d3b4ac5d6056bb81192ee149dd7157348e74286a211172607071100ed59c22e74aa5664b3cd0f766499500f70bf5793f1d1edc
@@ -1,3 +1,5 @@
1
+ require "manageiq-password"
2
+
1
3
  module ManageIQ
2
4
  class Password
3
5
  module PasswordMixin
@@ -0,0 +1,3 @@
1
+ require "manageiq/password/rspec_matchers/be_decrypted"
2
+ require "manageiq/password/rspec_matchers/be_encrypted"
3
+ require "manageiq/password/rspec_matchers/be_encrypted_version"
@@ -0,0 +1,17 @@
1
+ RSpec::Matchers.define :be_decrypted do |expected|
2
+ match do |actual|
3
+ actual == expected
4
+ end
5
+
6
+ failure_message do |actual|
7
+ "expected: #{actual.inspect} to be decrypted to #{expected.inspect}"
8
+ end
9
+
10
+ failure_message_when_negated do |actual|
11
+ "expected: #{actual.inspect} to not equal #{expected.inspect}"
12
+ end
13
+
14
+ description do
15
+ "expect to be decrypted from a string"
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ require "manageiq-password"
2
+
3
+ RSpec::Matchers.define :be_encrypted do |expected|
4
+ match do |actual|
5
+ ManageIQ::Password.encrypted?(actual) && (
6
+ expected.nil? ||
7
+ ManageIQ::Password.decrypt(actual) == expected
8
+ )
9
+ end
10
+
11
+ # On negation, we don't want to check the expected at all, otherwise it can
12
+ # result in false positives. It doesn't make sense to check a decrypted value
13
+ # anyway, since we are claiming that we don't expect it to be encrypted.
14
+ match_when_negated do |actual|
15
+ raise ArgumentError, "cannot pass `expected` on a negated be_encrypted expectation" if expected
16
+ !ManageIQ::Password.encrypted?(actual)
17
+ end
18
+
19
+ failure_message do |actual|
20
+ "expected: #{actual.inspect} to be encrypted#{" and decrypt to #{expected.inspect}" if expected}"
21
+ end
22
+
23
+ failure_message_when_negated do |actual|
24
+ "expected: #{actual.inspect} not to be encrypted"
25
+ end
26
+
27
+ description do
28
+ "expect to be an encrypted v2 password (with optional encrypted value)"
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ require "manageiq-password"
2
+
3
+ RSpec::Matchers.define :be_encrypted_version do |expected|
4
+ match do |actual|
5
+ ManageIQ::Password.split(actual).first == expected.to_s
6
+ end
7
+
8
+ failure_message do |actual|
9
+ actual_version = ManageIQ::Password.split(actual).first
10
+ actual_version_text = actual_version ? "encrypted with version #{actual_version}" : "not encrypted"
11
+ "expected: #{actual.inspect} to be encrypted with version #{expected} but is #{actual_version_text}"
12
+ end
13
+
14
+ failure_message_when_negated do |actual|
15
+ "expected: #{actual.inspect} not to be encrypted with version #{expected}"
16
+ end
17
+
18
+ description do
19
+ "expect to be encrypted with a particular version of miq password (e.g.: 2)"
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  class Password
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-password
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,10 @@ files:
89
89
  - lib/manageiq-password.rb
90
90
  - lib/manageiq/password.rb
91
91
  - lib/manageiq/password/password_mixin.rb
92
+ - lib/manageiq/password/rspec_matchers.rb
93
+ - lib/manageiq/password/rspec_matchers/be_decrypted.rb
94
+ - lib/manageiq/password/rspec_matchers/be_encrypted.rb
95
+ - lib/manageiq/password/rspec_matchers/be_encrypted_version.rb
92
96
  - lib/manageiq/password/version.rb
93
97
  - manageiq-password.gemspec
94
98
  homepage: https://github.com/ManageIQ/manageiq-password
@@ -111,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
115
  version: '0'
112
116
  requirements: []
113
117
  rubyforge_project:
114
- rubygems_version: 2.6.14.3
118
+ rubygems_version: 2.7.6
115
119
  signing_key:
116
120
  specification_version: 4
117
121
  summary: A simple encryption util for storing passwords in a database.