xchange-passgen 1.0.1.a

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,150 @@
1
+ require "./lib/passgen"
2
+
3
+ describe "Using passgen" do
4
+
5
+ before do
6
+ srand(2)
7
+ end
8
+
9
+ it "should return password with default settings." do
10
+ Passgen::generate.should eql("OpTiwRslOh")
11
+ end
12
+
13
+ it "should return password with uppercase chars only" do
14
+ Passgen::generate(:uppercase => :only).should eql("IPNIWLSLIH")
15
+ end
16
+
17
+ it "should return password with lowercase chars only" do
18
+ Passgen::generate(:lowercase => :only).should eql("ipniwlslih")
19
+ end
20
+
21
+ it "should return password with digits only" do
22
+ Passgen::generate(:digits => :only).should eql("8862872154")
23
+ end
24
+
25
+ it "should return password with symbols only" do
26
+ Passgen::generate(:symbols => :only).should eql("))/*#*)(\#@")
27
+ end
28
+
29
+ it "should return password with lowercase and uppercase chars only" do
30
+ Passgen::generate(:digits => false).should eql("OpTiwRslOh")
31
+ end
32
+
33
+ it "should return password with lowercase and digit chars only" do
34
+ Passgen::generate(:uppercase => false).should eql("piwslh85lv")
35
+ end
36
+
37
+ it "should return password with lowercase and symbol chars only" do
38
+ Passgen::generate(:uppercase => false, :digits => false, :symbols => true).should eql("piwslh)&lv")
39
+ end
40
+
41
+ it "should return password with uppercase and digit chars only" do
42
+ Passgen::generate(:lowercase => false).should eql("PIWSLH85LV")
43
+ end
44
+
45
+ it "should return password with uppercase and symbol chars only" do
46
+ Passgen::generate(:lowercase => false, :digits => false, :symbols => true).should eql("PIWSLH)&LV")
47
+ end
48
+
49
+ it "should return password with digit and symbol chars only" do
50
+ Passgen::generate(:lowercase => false, :uppercase => false, :symbols => true).should eql("8&$8@)@872")
51
+ end
52
+
53
+ it "should return password with lowercase, uppercase and digit chars only" do
54
+ Passgen::generate.should eql("OpTiwRslOh")
55
+ end
56
+
57
+ it "should return password with lowercase, uppercase and symbol chars only" do
58
+ srand(3)
59
+ Passgen::generate(:digits => false, :symbols => true).should eql("Qy&d%iav+t")
60
+ end
61
+
62
+ it "should return password with lowercase, digit and symbol chars only" do
63
+ srand(4)
64
+ Passgen::generate(:uppercase => false, :symbols => true).should eql("?fb%xij$+4")
65
+ end
66
+
67
+ it "should return password with uppercase, digit and symbol chars only" do
68
+ srand(4)
69
+ Passgen::generate(:lowercase => false, :symbols => true).should eql("?FB%XIJ$+4")
70
+ end
71
+
72
+ it "should return given number of passwords in an Array" do
73
+ Passgen::generate(:number => 3).should eql(["OpTiwRslOh", "IXFlvVFAu8", "0LNdMeQRZN"])
74
+ end
75
+
76
+ it "should return a password with given length" do
77
+ Passgen::generate(:length => 8).should eql("OpTiwRsl")
78
+ end
79
+
80
+ it "should return several passwords of variable length" do
81
+ Passgen::generate(:length => 3..12, :number => 2).should eql(["pTiwRslOhIX", "VFAu80LN"])
82
+ end
83
+
84
+ it "should use given seed" do
85
+ pass1 = Passgen::generate(:seed => 5)
86
+ pass2 = Passgen::generate(:seed => 5)
87
+ pass1.should eql(pass2)
88
+ end
89
+
90
+ it "should set seed to Time.now + Process.id" do
91
+ pass1 = Passgen::generate(:seed => :default)
92
+ pass2 = Passgen::generate(:seed => :default)
93
+ pass1.should_not eql(pass2)
94
+ end
95
+
96
+ describe "handling tokens" do
97
+
98
+ it "should return a-z" do
99
+ Passgen::LOWERCASE_TOKENS.should eql(("a".."z").to_a)
100
+ end
101
+
102
+ it "should return A-Z" do
103
+ Passgen::UPPERCASE_TOKENS.should eql(("A".."Z").to_a)
104
+ end
105
+
106
+ it "should return 0-9" do
107
+ Passgen::DIGIT_TOKENS.should eql(("0".."9").to_a)
108
+ end
109
+
110
+ it "should return default symbols" do
111
+ Passgen::symbol_tokens.should eql(%w{! @ # $ % & / ( ) + ? *})
112
+ end
113
+
114
+ end
115
+
116
+ describe "pronounceable" do
117
+ it "should return a pronounceable lower case password" do
118
+ Passgen::generate(:pronounceable => true, :lowercase => :only).should == "ishanghter"
119
+ end
120
+
121
+ it "should return a pronounceable upper case password" do
122
+ Passgen::generate(:pronounceable => true, :uppercase => :only).should == "ISHANGHTER"
123
+ end
124
+
125
+ it "should return a pronounceable mixed case password" do
126
+ Passgen::generate(:pronounceable => true).should == "iShfIeRBAt"
127
+ end
128
+
129
+ it "should return a pronounceable mixed case password of length 7" do
130
+ Passgen::generate(:pronounceable => true, :length => 7).should == "IShfIeR"
131
+ end
132
+
133
+ it "should return a pronounceable password with 3 digits in front" do
134
+ Passgen::generate(:pronounceable => true, :digits_before => 3).should == "886uRApLIN"
135
+ end
136
+
137
+ it "should return a pronounceable password with default 2 digits in front" do
138
+ Passgen::generate(:pronounceable => true, :digits_before => true).should == "88mpICePED"
139
+ end
140
+
141
+ it "should return a pronounceable password with 3 digits at the end" do
142
+ Passgen::generate(:pronounceable => true, :digits_after => 3).should == "uRAPLIN886"
143
+ end
144
+
145
+ it "should return a pronounceable password with default 2 digits at the end" do
146
+ Passgen::generate(:pronounceable => true, :digits_after => true).should == "mPICEPED88"
147
+ end
148
+
149
+ end
150
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xchange-passgen
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1.a
5
+ platform: ruby
6
+ authors:
7
+ - Erik Lindblad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-12-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A password generation gem for Ruby and Rails applications.
14
+ email: erik@l2c.se
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files:
18
+ - CHANGELOG
19
+ - README.rdoc
20
+ - lib/passgen.rb
21
+ - lib/passgen/probabilities.rb
22
+ - lib/passgen/strength_analyzer.rb
23
+ files:
24
+ - CHANGELOG
25
+ - Manifest
26
+ - README.rdoc
27
+ - Rakefile
28
+ - init.rb
29
+ - lib/passgen.rb
30
+ - lib/passgen/probabilities.rb
31
+ - lib/passgen/strength_analyzer.rb
32
+ - passgen.gemspec
33
+ - spec/passgen/strength_analyzer_spec.rb
34
+ - spec/passgen_spec.rb
35
+ homepage: http://github.com/cryptice/passgen
36
+ licenses: []
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options:
40
+ - "--line-numbers"
41
+ - "--inline-source"
42
+ - "--title"
43
+ - Passgen
44
+ - "--main"
45
+ - README.rdoc
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '1.2'
58
+ requirements: []
59
+ rubygems_version: 3.0.1
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: A password generation gem for Ruby and Rails applications.
63
+ test_files: []