mirror of
https://github.com/philippdieter/puppet-ldapquery.git
synced 2025-10-13 20:56:55 +00:00
Update tests to match reality
This commit is contained in:
parent
bf64a51a42
commit
fa453d46e2
@ -28,13 +28,13 @@ describe 'PuppetX::LDAPquery' do
|
|||||||
filter = '(uid=zach)'
|
filter = '(uid=zach)'
|
||||||
attributes = ['uid']
|
attributes = ['uid']
|
||||||
|
|
||||||
wanted = [{"dn"=>"uid=zach,ou=users,dc=puppetlabs,dc=com", "uid"=>"zach"}]
|
wanted = [{"dn"=>["uid=zach,ou=users,dc=puppetlabs,dc=com"], "uid"=>["zach"]}]
|
||||||
entries = Marshal.load(File.read("spec/fixtures/entries_single.obj"))
|
entries = Marshal.load(File.read("spec/fixtures/entries_single.obj"))
|
||||||
|
|
||||||
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
||||||
|
|
||||||
expect(l).to receive(:get_entries).and_return(entries)
|
expect(l).to receive(:get_entries).and_return(entries)
|
||||||
expect(l.results).to match(wanted)
|
expect(l.results).to eq(wanted)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "a multivalued attribute is requested" do
|
context "a multivalued attribute is requested" do
|
||||||
@ -42,35 +42,25 @@ describe 'PuppetX::LDAPquery' do
|
|||||||
filter = '(uid=zach)'
|
filter = '(uid=zach)'
|
||||||
attributes = ['objectClass']
|
attributes = ['objectClass']
|
||||||
|
|
||||||
wanted = [{"dn"=>"uid=zach,ou=users,dc=puppetlabs,dc=com",
|
wanted =[{"dn"=>["uid=zach,ou=users,dc=puppetlabs,dc=com"], "objectclass"=>["posixAccount", "shadowAccount", "inetOrgPerson", "puppetPerson", "ldapPublicKey", "top"]}]
|
||||||
"objectclass"=> [
|
|
||||||
"posixAccount",
|
|
||||||
"shadowAccount",
|
|
||||||
"inetOrgPerson",
|
|
||||||
"puppetPerson",
|
|
||||||
"ldapPublicKey",
|
|
||||||
"top"]}]
|
|
||||||
|
|
||||||
entries = Marshal.load(File.read("spec/fixtures/entries_objectClass.obj"))
|
entries = Marshal.load(File.read("spec/fixtures/entries_objectClass.obj"))
|
||||||
|
|
||||||
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
||||||
expect(l).to receive(:get_entries).and_return(entries)
|
expect(l).to receive(:get_entries).and_return(entries)
|
||||||
expect(l.results).to match(wanted)
|
expect(l.results).to eq(wanted)
|
||||||
end
|
end
|
||||||
it 'should return the attributes without new lines' do
|
it 'should return the attributes without new lines' do
|
||||||
filter = '(uid=zach)'
|
filter = '(uid=zach)'
|
||||||
attributes = ['sshPublicKey']
|
attributes = ['sshPublicKey']
|
||||||
|
|
||||||
wanted = [{"dn"=>"uid=zach,ou=users,dc=puppetlabs,dc=com",
|
wanted = [{"dn"=>["uid=zach,ou=users,dc=puppetlabs,dc=com"], "sshpublickey"=>["ssh-rsa AAAAB...1== user@somewhere", "ssh-rsa AAAAB...2== user@somewhereelse"]}]
|
||||||
"sshpublickey"=>
|
|
||||||
["ssh-rsa AAAAB...1== user@somewhere",
|
|
||||||
"ssh-rsa AAAAB...2== user@somewhereelse"]}]
|
|
||||||
|
|
||||||
entries = Marshal.load(File.read("spec/fixtures/entries_multivalue.obj"))
|
entries = Marshal.load(File.read("spec/fixtures/entries_multivalue.obj"))
|
||||||
|
|
||||||
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
l = PuppetX::LDAPquery.new(filter, attributes, base)
|
||||||
expect(l).to receive(:get_entries).and_return(entries)
|
expect(l).to receive(:get_entries).and_return(entries)
|
||||||
expect(l.results).to match(wanted)
|
expect(l.results).to eq(wanted)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user