passing test
This commit is contained in:
Родитель
671fca2b54
Коммит
a671164925
|
@ -1,14 +1,12 @@
|
|||
module KcpasswordHelpers
|
||||
class Kcpassword << self
|
||||
def magic_bits
|
||||
[125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]
|
||||
end
|
||||
module Kcpassword
|
||||
@magic_bits = [125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]
|
||||
|
||||
def obfuscate(password)
|
||||
obfuscated = []
|
||||
padded(password).each do |char|
|
||||
obfuscated.push(@magic_bits[0] ^ char)
|
||||
@magic_bits.rotate
|
||||
@magic_bits.rotate!
|
||||
end
|
||||
obfuscated.pack('C*')
|
||||
end
|
||||
|
@ -28,5 +26,5 @@ module KcpasswordHelpers
|
|||
end
|
||||
end unless defined?(KcpasswordHelpers)
|
||||
|
||||
Chef::Recipe.include(KcpasswordHelpers)
|
||||
Chef::Resource.include(KcpasswordHelpers)
|
||||
Chef::Recipe.include(KcpasswordHelpers::Kcpassword)
|
||||
Chef::Resource.include(KcpasswordHelpers::Kcpassword)
|
||||
|
|
|
@ -3,3 +3,4 @@ require 'chefspec/berkshelf'
|
|||
|
||||
require_relative '../libraries/plistbuddy'
|
||||
require_relative '../libraries/xcode'
|
||||
require_relative '../libraries/kcpassword'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
include KcpasswordHelpers::Kcpassword
|
||||
|
||||
describe KcpasswordHelpers::Kcpassword, '#obfuscate' do
|
||||
context 'When calling the obfuscate method' do
|
||||
it 'the password is obfuscated correctly' do
|
||||
expect(KcpasswordHelpers::Kcpassword.obfuscate('password')).to eq "\r\xE8!P\xA5\xD3\xAF\x8E\xA3\xB9\x1F".force_encoding('ASCII-8BIT')
|
||||
end
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче