Commit a09e572b authored by James Lopez's avatar James Lopez

Add user auth spec

parent 323e64ee
...@@ -64,4 +64,25 @@ describe Gitlab::Auth::UserAuthFinders do ...@@ -64,4 +64,25 @@ describe Gitlab::Auth::UserAuthFinders do
it_behaves_like 'find user from job token' it_behaves_like 'find user from job token'
end end
end end
describe '#find_user_from_scim_token' do
let(:token) { create(:personal_access_token, user: user) }
before do
allow(request).to receive(:path).and_return('/api/scim/')
allow(self).to receive(:current_request).and_return(request)
end
it "returns an Unauthorized exception for an invalid token" do
env['HTTP_AUTHORIZATION'] = "Bearer invalid"
expect { find_user_from_scim_token }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
it "return user if token is valid" do
env['HTTP_AUTHORIZATION'] = "Bearer #{token.token}"
expect(find_user_from_scim_token).to eq(user)
end
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