gates_of_heaven 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6fc181d97ae8cad92be668a0168e26880f7273c
4
+ data.tar.gz: 5d931b8e06f957d841232dbd287f0926b6c3c138
5
+ SHA512:
6
+ metadata.gz: 8134925d24daa11c56c704a777f74cb82d81002c8c3d5a137d99357cbb4ab4b6c15286566764aaa53af7e55c6a14b63cec8240ffe8517a689ffc439b4aa0472d
7
+ data.tar.gz: 0106ea7a0dd6235987371c75206d526c4deecde75de5e1107c684c2d10b32f986c9eab153cba4cbfabb1595cd3df3abdad904eb3ffcc07b777671a7ca9d89b29
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swo
19
+ *.swp
20
+ *~
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gates_of_heaven.gemspec
4
+ gemspec
5
+
6
+ version = ENV["RAILS_VERSION"] || "3.2.13"
7
+
8
+ rails = case version
9
+ when "master"
10
+ {github: "rails/rails"}
11
+ else
12
+ "~> #{version}.0"
13
+ end
14
+
15
+ gem "rails", rails
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 bomatson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # GatesOfHeaven
2
+
3
+ Gates Of Heaven allows you to check password strength for any ActiveModel password
4
+ It is most useful when using Ruby On Rails!
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'gates_of_heaven'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install gates_of_heaven
19
+
20
+ ## Usage
21
+
22
+ It's dead simple to use the Gates:
23
+
24
+ User < ActiveRecord::Base
25
+ attr_accessor :password
26
+
27
+ validates :password, gates_of_heaven: true
28
+
29
+ But not so easy to pass through them!
30
+
31
+ ![Gates of Heaven](http://img5.joyreactor.com/pics/post/auto-cat-animals-heaven-346025.jpeg "Gates of Heaven")
32
+
33
+ ## CLI
34
+
35
+ There's also a CLI tool included, allowing you to spot check passwords:
36
+
37
+ $ gates doorman [password]
38
+
39
+ ## Next up
40
+
41
+ Right now, the Gates only check whether the length is less than 6,
42
+ and that the password contains digits.
43
+
44
+ I intend to have the Gates do a match against a library of the most commonly used passwords.
45
+ Suggestions and pull requests are welcome!
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/gates ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gates_of_heaven/cli'
4
+ GatesOfHeaven::CLI.start
@@ -0,0 +1,16 @@
1
+ Feature: Doorman
2
+ In order to enter heaven
3
+ As a CLI
4
+ I want to be as objective as possible
5
+
6
+ Scenario: Password too short
7
+ When I run `gates doorman pass`
8
+ Then the output should contain "Password too short"
9
+
10
+ Scenario: Password does not have numbers
11
+ When I run `gates doorman password`
12
+ Then the output should contain "Password needs numbers"
13
+
14
+ Scenario: Password is legit
15
+ When I run `gates doorman password22`
16
+ Then the output should contain "Nice password, skipper"
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gates_of_heaven/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gates_of_heaven"
8
+ spec.version = GatesOfHeaven::VERSION
9
+ spec.authors = ["Bobby Matson"]
10
+ spec.email = ["bobby.matson@gmail.com"]
11
+ spec.description = %q{This gem will tell you whether your password is garbage or not}
12
+ spec.summary = %q{Check password strength ala ActiveRecord Validators}
13
+ spec.homepage = "http://www.github.com/bomatson/gates-of-heaven"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "cucumber"
25
+ spec.add_development_dependency "aruba"
26
+ spec.add_development_dependency "thor"
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'gates_of_heaven'
2
+
3
+ module ActiveModel
4
+ module Validations
5
+ class GatesOfHeavenValidator < ActiveModel::EachValidator
6
+ def validate_each(record, attribute, value)
7
+ pass = GatesOfHeaven::Doorman.new(record.password)
8
+ if pass.guard.present?
9
+ record.errors.add(:password, pass.guard)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ require "active_model/validations"
2
+ require "gates_of_heaven/version"
3
+ require "gates_of_heaven/doorman"
4
+ require "active_model/validations/gates_of_heaven_validator" if defined? ActiveModel
5
+
6
+ module GatesOfHeaven
7
+ end
8
+ # proposed_password = "something"
9
+ # h = Hash.new
10
+ # h.default_proc = proc do |proposed_password|
11
+ # proposed_password,gsub(/^[a-zA-Z]\w{3,14}$/)
12
+ # PasswordChecker.check(proposed_password)
13
+ # end
14
+
15
+ #h[username] = proposed_password
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+ require 'gates_of_heaven'
3
+
4
+ module GatesOfHeaven
5
+ class CLI < Thor
6
+
7
+ desc "doorman PASSWORD", "Determines if the password is worthy of heaven"
8
+ def doorman(password)
9
+ pass = GatesOfHeaven::Doorman.new(password)
10
+ puts pass.guard
11
+ if pass.guard.nil?
12
+ puts 'Nice password, skipper'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module GatesOfHeaven
2
+ class Doorman
3
+ def initialize(password)
4
+ @password = password.dup
5
+ end
6
+
7
+ def guard
8
+ case
9
+ when @password.length <= 6
10
+ 'Password too short'
11
+ when !@password.match(/\d/)
12
+ 'Password needs numbers'
13
+ else
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module GatesOfHeaven
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'gates_of_heaven'
2
+
3
+ describe GatesOfHeaven::Doorman do
4
+ context '#guard' do
5
+ subject { GatesOfHeaven::Doorman.new(password) }
6
+
7
+ context 'given a password with less than 6 characters' do
8
+ let(:password) { 'pass' }
9
+
10
+ it 'will raise an ArgumentError' do
11
+ expect( subject.guard ).to eq 'Password too short'
12
+ end
13
+ end
14
+
15
+ context 'given a password with no numbers' do
16
+ let(:password) { 'password' }
17
+
18
+ it 'raises an error if there are no numbers' do
19
+ expect( subject.guard ).to eq 'Password needs numbers'
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,49 @@
1
+ require 'gates_of_heaven'
2
+ require 'active_model'
3
+
4
+ class User
5
+ include ActiveModel::Validations
6
+ attr_accessor :password
7
+ end
8
+
9
+ class BasicUser < User
10
+ validates :password, gates_of_heaven: true
11
+ end
12
+
13
+ module ActiveModel
14
+ module Validations
15
+ describe GatesOfHeavenValidator do
16
+ describe 'validations' do
17
+ subject { BasicUser.new }
18
+
19
+ context 'which are not good enough for heaven' do
20
+ let(:too_short) { 'foo' }
21
+ let(:no_number) { 'password' }
22
+
23
+ it 'adds an error to the model record' do
24
+ subject.password = too_short
25
+ subject.valid?
26
+ expect(subject.errors[:password]).to_not be_empty
27
+ end
28
+
29
+ it 'adds an error to the model record' do
30
+ subject.password = no_number
31
+ subject.valid?
32
+ expect(subject.errors[:password]).to_not be_empty
33
+ end
34
+ end
35
+
36
+ context 'which are good enough for heaven' do
37
+ before do
38
+ subject.password = 'password22'
39
+ subject.valid?
40
+ end
41
+
42
+ it 'adds an error to the model record' do
43
+ expect(subject.errors[:password]).to be_empty
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gates_of_heaven
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bobby Matson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This gem will tell you whether your password is garbage or not
98
+ email:
99
+ - bobby.matson@gmail.com
100
+ executables:
101
+ - gates
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/gates
111
+ - features/doorman.feature
112
+ - features/support/setup.rb
113
+ - gates_of_heaven.gemspec
114
+ - lib/active_model/validations/gates_of_heaven_validator.rb
115
+ - lib/gates_of_heaven.rb
116
+ - lib/gates_of_heaven/cli.rb
117
+ - lib/gates_of_heaven/doorman.rb
118
+ - lib/gates_of_heaven/version.rb
119
+ - spec/doorman_spec.rb
120
+ - spec/validation/gates_of_heaven_validator_spec.rb
121
+ homepage: http://www.github.com/bomatson/gates-of-heaven
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.6
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Check password strength ala ActiveRecord Validators
145
+ test_files:
146
+ - features/doorman.feature
147
+ - features/support/setup.rb
148
+ - spec/doorman_spec.rb
149
+ - spec/validation/gates_of_heaven_validator_spec.rb