forked from External/greenlight
GRN2-30: Add custom ldap sign in page (#619)
* Add custom ldap signin page * Remove old omniauth-ldap gem * Use new bn gems
This commit is contained in:
committed by
Jesus Federico
parent
09afd9154f
commit
523d9a38f2
@ -336,4 +336,41 @@ describe SessionsController, type: :controller do
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #ldap" do
|
||||
it "should create and login a user with a ldap login" do
|
||||
entry = Net::LDAP::Entry.new("cn=Test User,ou=people,dc=planetexpress,dc=com")
|
||||
entry[:cn] = "Test User"
|
||||
entry[:givenName] = "Test"
|
||||
entry[:sn] = "User"
|
||||
entry[:mail] = "test@example.com"
|
||||
allow_any_instance_of(Net::LDAP).to receive(:bind_as).and_return([entry])
|
||||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
password: 'password',
|
||||
},
|
||||
}
|
||||
|
||||
u = User.last
|
||||
expect(u.provider).to eql("ldap")
|
||||
expect(u.email).to eql("test@example.com")
|
||||
expect(@request.session[:user_id]).to eql(u.id)
|
||||
end
|
||||
|
||||
it "should redirect to signin on invalid credentials" do
|
||||
allow_any_instance_of(Net::LDAP).to receive(:bind_as).and_return(false)
|
||||
|
||||
post :ldap, params: {
|
||||
session: {
|
||||
user: "test",
|
||||
password: 'passwor',
|
||||
},
|
||||
}
|
||||
|
||||
expect(response).to redirect_to(ldap_signin_path)
|
||||
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -387,4 +387,12 @@ describe UsersController, type: :controller do
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'GET #ldap_signin' do
|
||||
it "should render the ldap signin page" do
|
||||
get :ldap_signin
|
||||
|
||||
expect(response).to render_template(:ldap_signin)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user