mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add a pseudorandom password generator for VNC.
This commit is contained in:
parent
cfca6798d7
commit
31a5602669
2 changed files with 30 additions and 0 deletions
11
lib/fog/serverlove/util/compute/password_generator.rb
Normal file
11
lib/fog/serverlove/util/compute/password_generator.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
class PasswordGenerator
|
||||
def self.generate
|
||||
('a'...'z').to_a.concat(('A'...'Z').to_a).shuffle[0,8].join
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
tests/serverlove/util/compute/password_generator_tests.rb
Normal file
19
tests/serverlove/util/compute/password_generator_tests.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'fog/serverlove/util/compute/password_generator'
|
||||
|
||||
Shindo.tests('Fog::Compute::Serverlove::PasswordGenerator | generate password', ['serverlove']) do
|
||||
|
||||
@password = Fog::Compute::Serverlove::PasswordGenerator.generate
|
||||
|
||||
tests("@password.length").returns(8) do
|
||||
@password.length
|
||||
end
|
||||
|
||||
tests("@password contains one capital letter").returns(true) do
|
||||
@password.match(/[A-Z]/) && true
|
||||
end
|
||||
|
||||
tests("@password contains one lower case letter").returns(true) do
|
||||
@password.match(/[a-z]/) && true
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue