summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-11-20 11:06:27 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-11-20 11:06:27 +0100
commitf8453da5868dd7a23d0f2f3da7a45e33c441d1db (patch)
tree4287dcaab5a9b0e8be14e82104a109ca9349b81a /spec
parent11311a95545f967a5736cd16ab5fc37f7e658519 (diff)
downloadgitlab-shell-f8453da5868dd7a23d0f2f3da7a45e33c441d1db.tar.gz
Revert "Merge branch 'git_hook_messages'"
At least the following things were broken: - missing require for 'gitlab_access_status' in lib/gitlab_net.rb - gitlabhq master internal API returns 'true' or 'false', gitlab-shell expects JSON This reverts commit 11311a95545f967a5736cd16ab5fc37f7e658519, reversing changes made to 45444597aef3e434571de2491934ae92357ad231.
Diffstat (limited to 'spec')
-rw-r--r--spec/gitlab_net_spec.rb27
-rw-r--r--spec/gitlab_shell_spec.rb11
-rw-r--r--spec/vcr_cassettes/allowed-pull.yml2
-rw-r--r--spec/vcr_cassettes/allowed-push.yml2
-rw-r--r--spec/vcr_cassettes/denied-pull.yml2
-rw-r--r--spec/vcr_cassettes/denied-push-with-user.yml2
-rw-r--r--spec/vcr_cassettes/denied-push.yml2
7 files changed, 23 insertions, 25 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index d431ac7..9ccabe0 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -1,6 +1,5 @@
require_relative 'spec_helper'
require_relative '../lib/gitlab_net'
-require_relative '../lib/gitlab_access_status'
describe GitlabNet, vcr: true do
@@ -44,26 +43,26 @@ describe GitlabNet, vcr: true do
end
end
- describe :check_access do
+ describe :allowed? do
context 'ssh key with access to project' do
it 'should allow pull access for dev.gitlab.org' do
VCR.use_cassette("allowed-pull") do
- access = gitlab_net.check_access('git-receive-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
- access.allowed?.should be_true
+ access = gitlab_net.allowed?('git-receive-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
+ access.should be_true
end
end
- it 'adds the secret_token to the request' do
+ it 'adds the secret_token theo request' do
VCR.use_cassette("allowed-pull") do
Net::HTTP::Post.any_instance.should_receive(:set_form_data).with(hash_including(secret_token: 'a123'))
- gitlab_net.check_access('git-receive-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
+ gitlab_net.allowed?('git-receive-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
end
end
it 'should allow push access for dev.gitlab.org' do
VCR.use_cassette("allowed-push") do
- access = gitlab_net.check_access('git-upload-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
- access.allowed?.should be_true
+ access = gitlab_net.allowed?('git-upload-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
+ access.should be_true
end
end
end
@@ -71,22 +70,22 @@ describe GitlabNet, vcr: true do
context 'ssh key without access to project' do
it 'should deny pull access for dev.gitlab.org' do
VCR.use_cassette("denied-pull") do
- access = gitlab_net.check_access('git-receive-pack', 'gitlab/gitlabhq.git', 'key-2', changes)
- access.allowed?.should be_false
+ access = gitlab_net.allowed?('git-receive-pack', 'gitlab/gitlabhq.git', 'key-2', changes)
+ access.should be_false
end
end
it 'should deny push access for dev.gitlab.org' do
VCR.use_cassette("denied-push") do
- access = gitlab_net.check_access('git-upload-pack', 'gitlab/gitlabhq.git', 'key-2', changes)
- access.allowed?.should be_false
+ access = gitlab_net.allowed?('git-upload-pack', 'gitlab/gitlabhq.git', 'key-2', changes)
+ access.should be_false
end
end
it 'should deny push access for dev.gitlab.org (with user)' do
VCR.use_cassette("denied-push-with-user") do
- access = gitlab_net.check_access('git-upload-pack', 'gitlab/gitlabhq.git', 'user-1', changes)
- access.allowed?.should be_false
+ access = gitlab_net.allowed?('git-upload-pack', 'gitlab/gitlabhq.git', 'user-1', changes)
+ access.should be_false
end
end
end
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index 5df2391..4741303 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -1,6 +1,5 @@
require_relative 'spec_helper'
require_relative '../lib/gitlab_shell'
-require_relative '../lib/gitlab_access_status'
describe GitlabShell do
subject do
@@ -13,7 +12,7 @@ describe GitlabShell do
let(:api) do
double(GitlabNet).tap do |api|
api.stub(discover: { 'name' => 'John Doe' })
- api.stub(check_access: GitAccessStatus.new(true))
+ api.stub(allowed?: true)
end
end
let(:key_id) { "key-#{rand(100) + 100}" }
@@ -141,13 +140,13 @@ describe GitlabShell do
before { ssh_cmd 'git-upload-pack gitlab-ci.git' }
after { subject.exec }
- it "should call api.check_access" do
- api.should_receive(:check_access).
+ it "should call api.allowed?" do
+ api.should_receive(:allowed?).
with('git-upload-pack', 'gitlab-ci.git', key_id, '_any')
end
- it "should disallow access and log the attempt if check_access returns false status" do
- api.stub(check_access: GitAccessStatus.new(false))
+ it "should disallow access and log the attempt if allowed? returns false" do
+ api.stub(allowed?: false)
message = "gitlab-shell: Access denied for git command <git-upload-pack gitlab-ci.git> "
message << "by user with key #{key_id}."
$logger.should_receive(:warn).with(message)
diff --git a/spec/vcr_cassettes/allowed-pull.yml b/spec/vcr_cassettes/allowed-pull.yml
index 5a10ec9..337b00f 100644
--- a/spec/vcr_cassettes/allowed-pull.yml
+++ b/spec/vcr_cassettes/allowed-pull.yml
@@ -42,7 +42,7 @@ http_interactions:
- '0.089741'
body:
encoding: UTF-8
- string: '{"status": "true"}'
+ string: 'true'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:36 GMT
recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push.yml b/spec/vcr_cassettes/allowed-push.yml
index a75c2db..cb757bf 100644
--- a/spec/vcr_cassettes/allowed-push.yml
+++ b/spec/vcr_cassettes/allowed-push.yml
@@ -42,7 +42,7 @@ http_interactions:
- '0.833195'
body:
encoding: UTF-8
- string: '{"status": "true"}'
+ string: 'true'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:37 GMT
recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/denied-pull.yml b/spec/vcr_cassettes/denied-pull.yml
index 8535b4e..9941e70 100644
--- a/spec/vcr_cassettes/denied-pull.yml
+++ b/spec/vcr_cassettes/denied-pull.yml
@@ -40,7 +40,7 @@ http_interactions:
- '0.028027'
body:
encoding: UTF-8
- string: '{"status": false, "message":"404 Not found"}'
+ string: '{"message":"404 Not found"}'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:38 GMT
recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/denied-push-with-user.yml b/spec/vcr_cassettes/denied-push-with-user.yml
index 101a868..4694797 100644
--- a/spec/vcr_cassettes/denied-push-with-user.yml
+++ b/spec/vcr_cassettes/denied-push-with-user.yml
@@ -42,7 +42,7 @@ http_interactions:
- '0.019640'
body:
encoding: UTF-8
- string: '{"status": false}'
+ string: 'false'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:39 GMT
recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/denied-push.yml b/spec/vcr_cassettes/denied-push.yml
index 53ccc57..fc0a309 100644
--- a/spec/vcr_cassettes/denied-push.yml
+++ b/spec/vcr_cassettes/denied-push.yml
@@ -40,7 +40,7 @@ http_interactions:
- '0.015198'
body:
encoding: UTF-8
- string: '{"status": false, "message":"404 Not found"}'
+ string: '{"message":"404 Not found"}'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:38 GMT
recorded_with: VCR 2.4.0