BigW Consortium Gitlab

Commit 0f8fe93c by Jacob Vosmaer

Whitespace, remove unused method

parent 31bc876b
...@@ -40,7 +40,7 @@ describe 'Git HTTP requests', lib: true do ...@@ -40,7 +40,7 @@ describe 'Git HTTP requests', lib: true do
download("/#{wiki.repository.path_with_namespace}.git") do |response| download("/#{wiki.repository.path_with_namespace}.git") do |response|
json_body = ActiveSupport::JSON.decode(response.body) json_body = ActiveSupport::JSON.decode(response.body)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_body['RepoPath']).to include(wiki.repository.path_with_namespace) expect(json_body['RepoPath']).to include(wiki.repository.path_with_namespace)
end end
...@@ -75,7 +75,7 @@ describe 'Git HTTP requests', lib: true do ...@@ -75,7 +75,7 @@ describe 'Git HTTP requests', lib: true do
context "when username and password are provided" do context "when username and password are provided" do
let(:env) { { user: user.username, password: 'nope' } } let(:env) { { user: user.username, password: 'nope' } }
context "when authentication fails" do context "when authentication fails" do
it "responds with status 401" do it "responds with status 401" do
download(path, env) do |response| download(path, env) do |response|
...@@ -87,9 +87,9 @@ describe 'Git HTTP requests', lib: true do ...@@ -87,9 +87,9 @@ describe 'Git HTTP requests', lib: true do
it "responds with status 401" do it "responds with status 401" do
expect(Rack::Attack::Allow2Ban).to receive(:filter).and_return(true) expect(Rack::Attack::Allow2Ban).to receive(:filter).and_return(true)
allow_any_instance_of(Rack::Request).to receive(:ip).and_return('1.2.3.4') allow_any_instance_of(Rack::Request).to receive(:ip).and_return('1.2.3.4')
clone_get(path, env) clone_get(path, env)
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
end end
...@@ -97,7 +97,7 @@ describe 'Git HTTP requests', lib: true do ...@@ -97,7 +97,7 @@ describe 'Git HTTP requests', lib: true do
context "when authentication succeeds" do context "when authentication succeeds" do
let(:env) { { user: user.username, password: user.password } } let(:env) { { user: user.username, password: user.password } }
context "when the user has access to the project" do context "when the user has access to the project" do
before do before do
project.team << [user, :master] project.team << [user, :master]
...@@ -117,9 +117,9 @@ describe 'Git HTTP requests', lib: true do ...@@ -117,9 +117,9 @@ describe 'Git HTTP requests', lib: true do
context "when the user isn't blocked" do context "when the user isn't blocked" do
it "responds with status 200" do it "responds with status 200" do
expect(Rack::Attack::Allow2Ban).to receive(:reset) expect(Rack::Attack::Allow2Ban).to receive(:reset)
clone_get(path, env) clone_get(path, env)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
end end
...@@ -183,25 +183,21 @@ describe 'Git HTTP requests', lib: true do ...@@ -183,25 +183,21 @@ describe 'Git HTTP requests', lib: true do
def clone_get(project, options={}) def clone_get(project, options={})
get "/#{project}/info/refs", { service: 'git-upload-pack' }, auth_env(*options.values_at(:user, :password)) get "/#{project}/info/refs", { service: 'git-upload-pack' }, auth_env(*options.values_at(:user, :password))
end end
def clone_post(project, options={}) def clone_post(project, options={})
post "/#{project}/git-upload-pack", {}, auth_env(*options.values_at(:user, :password)) post "/#{project}/git-upload-pack", {}, auth_env(*options.values_at(:user, :password))
end end
def clone_path(project)
"/#{project.path_with_namespace}.git/info/refs"
end
def download(project, user: nil, password: nil) def download(project, user: nil, password: nil)
args = [project, {user: user, password: password}] args = [project, {user: user, password: password}]
clone_get *args clone_get *args
yield response yield response
clone_post *args clone_post *args
yield response yield response
end end
def auth_env(user, password) def auth_env(user, password)
if user && password if user && password
{ 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password) } { 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password) }
......
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