spec/adauth_spec.rb in adauth-1.0.1 vs spec/adauth_spec.rb in adauth-1.1.0
- old
+ new
@@ -2,13 +2,21 @@
require 'yaml'
describe Adauth, "#configure" do
it "should accept a block" do
Adauth.configure do |c|
- c.domain = "example.com"
+ c.domain = "test.example.com"
end
end
+
+ it "should correctly calculate the base" do
+ Adauth.config.base.should eq("dc=test, dc=example, dc=com")
+ end
+
+ it "should set the server to the domain if not specified" do
+ Adauth.config.server.should eq("test.example.com")
+ end
end
describe Adauth, "#config" do
before :each do
Adauth.configure do |c|
@@ -64,14 +72,34 @@
it "should dis-allow users who are in a denied group" do
Adauth.config.denied_groups = @yaml["domain"]["pass_allowed_groups"]
Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_nil
end
- it "should dis-allow users who are in a denied group" do
+ it "should allow users who are in a denied group" do
Adauth.config.denied_groups = @yaml["domain"]["fail_allowed_groups"]
Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_a Adauth::User
end
+
+ it "should allow users who are in an allowed ou" do
+ Adauth.config.allowed_ous = @yaml["domain"]["pass_allowed_ous"]
+ Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_a Adauth::User
+ end
+
+ it "should dis-allow users who are not in an allowed ou" do
+ Adauth.config.allowed_ous = @yaml["domain"]["fail_allowed_ous"]
+ Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_nil
+ end
+
+ it "should dis-allow users who are in a denied ou" do
+ Adauth.config.denied_ous = @yaml["domain"]["pass_allowed_ous"]
+ Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_nil
+ end
+
+ it "should allow users who are not in a denied ou" do
+ Adauth.config.denied_ous = @yaml["domain"]["fail_allowed_ous"]
+ Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"]).should be_a Adauth::User
+ end
end
describe Adauth::User do
before :each do
@yaml = YAML::load(File.open('spec/test_data.yml'))
@@ -96,7 +124,31 @@
@user.member_of?(@yaml["user"]["password"]).should == false
end
it "should have the correct user" do
@user.login.should == @yaml["user"]["login"]
+ end
+end
+
+describe "Adauth::User custom returns" do
+ before :each do
+ @yaml = YAML::load(File.open('spec/test_data.yml'))
+ Adauth.configure do |c|
+ c.domain = @yaml["domain"]["domain"]
+ c.server = @yaml["domain"]["server"]
+ c.port = @yaml["domain"]["port"]
+ c.base = @yaml["domain"]["base"]
+ c.ad_sv_attrs = { :phone => :telephonenumber }
+ c.ad_mv_attrs = { :ous => [ :memberof,
+ Proc.new {|g| g.sub(/.*?OU=(.*?),.*/, '\1')} ] }
+ end
+ @user = Adauth.authenticate(@yaml["user"]["login"], @yaml["user"]["password"])
+ end
+
+ it "should pickup the custom single value from AD" do
+ @user.phone.should be_a String
+ end
+
+ it "should pickup the custom multi value from AD" do
+ @user.ous.should be_a Array
end
end
\ No newline at end of file