2015-10-26 15:50:57 +01:00
|
|
|
# encoding: utf-8
|
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
|
|
|
|
2016-01-28 14:47:46 +01:00
|
|
|
require 'helper'
|
|
|
|
|
2016-01-02 23:58:28 +01:00
|
|
|
describe PasswdParser do
|
|
|
|
let (:parser) { Class.new() { include PasswdParser }.new }
|
2015-10-26 15:50:57 +01:00
|
|
|
|
|
|
|
describe '#parse_passwd' do
|
|
|
|
it 'parses nil content' do
|
|
|
|
parser.parse_passwd(nil).must_equal([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'parses an empty passwd line' do
|
|
|
|
parser.parse_passwd('').must_equal([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'parses a valid passwd line' do
|
|
|
|
info = [{
|
2016-02-18 12:00:34 +01:00
|
|
|
"user"=>"root",
|
2015-10-26 15:50:57 +01:00
|
|
|
"password"=>"x",
|
|
|
|
"uid"=>"0",
|
|
|
|
"gid"=>"0",
|
|
|
|
"desc"=>"root",
|
|
|
|
"home"=>"/root",
|
|
|
|
"shell"=>"/bin/sh"
|
|
|
|
}]
|
|
|
|
parser.parse_passwd('root:x:0:0:root:/root:/bin/sh').must_equal(info)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|