diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-07 14:58:28 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-07 14:58:28 -0500 |
| commit | c751e4eef508ab3cf9466dcb45479fced5d3e4be (patch) | |
| tree | 153c767f8d54931e0224cbaa10105a1fbac1005c /spec/unit/provider/group | |
| parent | 81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8 (diff) | |
| download | puppet-c751e4eef508ab3cf9466dcb45479fced5d3e4be.tar.gz puppet-c751e4eef508ab3cf9466dcb45479fced5d3e4be.tar.xz puppet-c751e4eef508ab3cf9466dcb45479fced5d3e4be.zip | |
Fixed #1272 - ldap group names will be converted to GIDs.
Note that this only looks up ldap groups, at this point; if you want to set an
ldap user's primary group to a local group, you have to specify the GID.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/provider/group')
| -rwxr-xr-x | spec/unit/provider/group/ldap.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/unit/provider/group/ldap.rb b/spec/unit/provider/group/ldap.rb index 53d9e8bfc..ab2bd72aa 100755 --- a/spec/unit/provider/group/ldap.rb +++ b/spec/unit/provider/group/ldap.rb @@ -77,4 +77,29 @@ describe provider_class do end end end + + it "should have a method for converting group names to GIDs" do + provider_class.should respond_to(:name2id) + end + + describe "when converting from a group name to GID" do + it "should use the ldap manager to look up the GID" do + provider_class.manager.expects(:search).with("cn=foo") + provider_class.name2id("foo") + end + + it "should return nil if no group is found" do + provider_class.manager.expects(:search).with("cn=foo").returns nil + provider_class.name2id("foo").should be_nil + provider_class.manager.expects(:search).with("cn=bar").returns [] + provider_class.name2id("bar").should be_nil + end + + # We shouldn't ever actually have more than one gid, but it doesn't hurt + # to test for the possibility. + it "should return the first gid from the first returned group" do + provider_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}] + provider_class.name2id("foo").should == 10 + end + end end |
