1
0
Fork 0
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:
Sean Handley 2012-07-17 20:09:07 +02:00
parent cfca6798d7
commit 31a5602669
2 changed files with 30 additions and 0 deletions

View 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

View 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