Commit fea591e5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rename finder to find_in_gitlab_or_ldap

parent 8299fc27
......@@ -12,7 +12,7 @@ Doorkeeper.configure do
end
resource_owner_from_credentials do |routes|
Gitlab::Auth.find_by_master_or_ldap(params[:username], params[:password])
Gitlab::Auth.find_in_gitlab_or_ldap(params[:username], params[:password])
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
......
......@@ -11,7 +11,7 @@ module API
# Example Request:
# POST /session
post "/session" do
user = Gitlab::Auth.find_by_master_or_ldap(params[:email] || params[:login], params[:password])
user = Gitlab::Auth.find_in_gitlab_or_ldap(params[:email] || params[:login], params[:password])
return unauthorized! unless user
present user, with: Entities::UserLogin
......
......@@ -9,7 +9,7 @@ module Gitlab
if valid_ci_request?(login, password, project)
type = :ci
elsif user = find_by_master_or_ldap(login, password)
elsif user = find_in_gitlab_or_ldap(login, password)
type = :master_or_ldap
elsif user = oauth_access_token_check(login, password)
type = :oauth
......@@ -19,7 +19,7 @@ module Gitlab
[user, type]
end
def find_by_master_or_ldap(login, password)
def find_in_gitlab_or_ldap(login, password)
user = User.by_login(login)
# If no user is found, or it's an LDAP server, try LDAP.
......
......@@ -95,7 +95,7 @@ module Grack
end
def authenticate_user(login, password)
user = Gitlab::Auth.new.find_by_master_or_ldap(login, password)
user = Gitlab::Auth.new.find_in_gitlab_or_ldap(login, password)
unless user
user = oauth_access_token_check(login, password)
......
......@@ -41,7 +41,7 @@ describe Gitlab::Auth, lib: true do
end
end
describe 'find_by_master_or_ldap' do
describe 'find_in_gitlab_or_ldap' do
let!(:user) do
create(:user,
username: username,
......@@ -52,25 +52,25 @@ describe Gitlab::Auth, lib: true do
let(:password) { 'my-secret' }
it "should find user by valid login/password" do
expect( gl_auth.find_by_master_or_ldap(username, password) ).to eql user
expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).to eql user
end
it 'should find user by valid email/password with case-insensitive email' do
expect(gl_auth.find_by_master_or_ldap(user.email.upcase, password)).to eql user
expect(gl_auth.find_in_gitlab_or_ldap(user.email.upcase, password)).to eql user
end
it 'should find user by valid username/password with case-insensitive username' do
expect(gl_auth.find_by_master_or_ldap(username.upcase, password)).to eql user
expect(gl_auth.find_in_gitlab_or_ldap(username.upcase, password)).to eql user
end
it "should not find user with invalid password" do
password = 'wrong'
expect( gl_auth.find_by_master_or_ldap(username, password) ).not_to eql user
expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).not_to eql user
end
it "should not find user with invalid login" do
user = 'wrong'
expect( gl_auth.find_by_master_or_ldap(username, password) ).not_to eql user
expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).not_to eql user
end
context "with ldap enabled" do
......@@ -81,13 +81,13 @@ describe Gitlab::Auth, lib: true do
it "tries to autheticate with db before ldap" do
expect(Gitlab::LDAP::Authentication).not_to receive(:login)
gl_auth.find_by_master_or_ldap(username, password)
gl_auth.find_in_gitlab_or_ldap(username, password)
end
it "uses ldap as fallback to for authentication" do
expect(Gitlab::LDAP::Authentication).to receive(:login)
gl_auth.find_by_master_or_ldap('ldap_user', 'password')
gl_auth.find_in_gitlab_or_ldap('ldap_user', 'password')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment