|
95 | 95 | end
|
96 | 96 | end
|
97 | 97 |
|
| 98 | + describe '.get_sids' do |
| 99 | + it 'returns an array of SIDs given two an array of ADSI children' do |
| 100 | + child1 = double('child1', name: 'Administrator', sid: 'S-1-5-21-3882680660-671291151-3888264257-500') |
| 101 | + child2 = double('child2', name: 'Guest', sid: 'S-1-5-21-3882680660-671291151-3888264257-501') |
| 102 | + allow(Puppet::Util::Windows::SID).to receive(:ads_to_principal).with(child1).and_return('Administrator') |
| 103 | + allow(Puppet::Util::Windows::SID).to receive(:ads_to_principal).with(child2).and_return('Guest') |
| 104 | + sids = Puppet::Util::Windows::ADSI::ADSIObject.get_sids([child1, child2]) |
| 105 | + expect(sids).to eq(['Administrator', 'Guest']) |
| 106 | + end |
| 107 | + |
| 108 | + it 'returns an array of SIDs given an ADSI child and ads_to_principal returning domain failure' do |
| 109 | + child = double('child1', name: 'Administrator', sid: 'S-1-5-21-3882680660-671291151-3888264257-500') |
| 110 | + allow(Puppet::Util::Windows::SID).to receive(:ads_to_principal).with(child).and_raise(Puppet::Util::Windows::Error.new('', Puppet::Util::Windows::SID::ERROR_TRUSTED_DOMAIN_FAILURE)) |
| 111 | + sids = Puppet::Util::Windows::ADSI::ADSIObject.get_sids([child]) |
| 112 | + expect(sids[0]).to eq(Puppet::Util::Windows::SID::Principal.new(child.name, child.sid, child.name, nil, :SidTypeUnknown)) |
| 113 | + end |
| 114 | + |
| 115 | + it 'returns an array of SIDs given an ADSI child and ads_to_principal returning relationship failure' do |
| 116 | + child = double('child1', name: 'Administrator', sid: 'S-1-5-21-3882680660-671291151-3888264257-500') |
| 117 | + allow(Puppet::Util::Windows::SID).to receive(:ads_to_principal).with(child).and_raise(Puppet::Util::Windows::Error.new('', Puppet::Util::Windows::SID::ERROR_TRUSTED_RELATIONSHIP_FAILURE)) |
| 118 | + sids = Puppet::Util::Windows::ADSI::ADSIObject.get_sids([child]) |
| 119 | + expect(sids[0]).to eq(Puppet::Util::Windows::SID::Principal.new(child.name, child.sid, child.name, nil, :SidTypeUnknown)) |
| 120 | + end |
| 121 | + end |
| 122 | + |
98 | 123 | describe Puppet::Util::Windows::ADSI::User do
|
99 | 124 | let(:username) { 'testuser' }
|
100 | 125 | let(:domain) { 'DOMAIN' }
|
|
0 commit comments