gen-password 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: tc_password.rb,v 1.3 2004/04/12 08:50:06 ianmacd Exp $
4
+
5
+ $: << File.dirname(__FILE__) + "/.." << File.dirname(__FILE__) + "/../lib"
6
+
7
+ require 'test/unit'
8
+ require 'password'
9
+
10
+
11
+ TIMES = 1000
12
+ LENGTH = 32
13
+
14
+
15
+ class TC_PasswordTest < Test::Unit::TestCase
16
+
17
+ def test_check
18
+ # Check for a weak password.
19
+ pw = Password.new( 'foo' )
20
+ assert_raises( Password::WeakPassword ) { pw.check }
21
+
22
+ # Check for a good password.
23
+ pw = Password.new( 'G@7flAxg' )
24
+ assert_nothing_raised { pw.check }
25
+
26
+ # Check for an exception on bad dictionary path.
27
+ assert_raises( Password::DictionaryError ) { pw.check( '/tmp/nodict' ) }
28
+ end
29
+
30
+ def test_phonemic
31
+ TIMES.times do |t|
32
+ pw = Password.phonemic( LENGTH )
33
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
34
+ end
35
+ end
36
+
37
+ def test_phonemic_one_case
38
+ TIMES.times do |t|
39
+ pw = Password.phonemic( LENGTH, Password::ONE_CASE )
40
+ assert( pw =~ /[A-Z]/, "#{pw} has no upper-case letter" )
41
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
42
+ end
43
+ end
44
+
45
+ def test_phonemic_one_digit
46
+ TIMES.times do |t|
47
+ pw = Password.phonemic( LENGTH, Password::ONE_DIGIT )
48
+ assert( pw =~ /[0-9]/, "#{pw} has no digit" )
49
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
50
+ end
51
+ end
52
+
53
+ def test_phonemic_one_case_one_digit
54
+ TIMES.times do |t|
55
+ pw = Password.phonemic( LENGTH, Password::ONE_CASE |
56
+ Password::ONE_DIGIT )
57
+ assert( pw =~ /[A-Z]/, "#{pw} has no upper-case letter" )
58
+ assert( pw =~ /[0-9]/, "#{pw} has no digit" )
59
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
60
+ end
61
+ end
62
+
63
+ def test_random
64
+ TIMES.times do |t|
65
+ pw = Password.random( LENGTH )
66
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
67
+ end
68
+ end
69
+
70
+ def test_urandom
71
+ TIMES.times do |t|
72
+ pw = Password.urandom( LENGTH )
73
+ assert( pw.length == LENGTH, "bad length: #{pw.length}, not #{LENGTH}" )
74
+ end
75
+ end
76
+
77
+ def test_crypt
78
+ pw = Password.random( LENGTH )
79
+ assert_nothing_raised { pw.crypt( Password::DES ) }
80
+ assert_nothing_raised { pw.crypt( Password::MD5 ) }
81
+ assert_raises( Password::CryptError ) { pw.crypt( Password::DES, '@*' ) }
82
+ end
83
+
84
+ def test_null_stdin
85
+ $stdin.reopen( File.new( '/dev/null' ) )
86
+ assert_nothing_raised { Password.get }
87
+ end
88
+
89
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gen-password
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.16.0
5
+ platform: ruby
6
+ authors:
7
+ - Albert Lash
8
+ - Ian Macdonald
9
+ - Akshay Mankar
10
+ - Vini Gupta
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2014-01-13 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: ruby-termios
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: shoulda
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ description: ! 'Ruby/GenPassword is a suite of password handling methods for Ruby.
45
+ It supports
46
+
47
+ the manual entry of passwords from the keyboard in both buffered and
48
+
49
+ unbuffered modes, random password generation,
50
+
51
+ phonemic password generation (for easy memorisation by human-beings) and the
52
+
53
+ encryption of passwords. It is a fork of Ruby/Password without password checking
54
+ using cracklib'
55
+ email: itsakshaymankar@gmail.com
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files:
59
+ - README
60
+ files:
61
+ - CHANGES
62
+ - COPYING
63
+ - Changelog
64
+ - README
65
+ - Rakefile
66
+ - VERSION
67
+ - example/crypt.rb
68
+ - example/example.rb
69
+ - example/pw.rb
70
+ - example/pwgen
71
+ - gen-password.gemspec
72
+ - lib/password.rb
73
+ - test/tc_password.rb
74
+ homepage: http://www.docunext.com/
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.1.11
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: A password handling library for Ruby
97
+ test_files: []