summaryrefslogtreecommitdiff
path: root/spec/gitlab_net_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/gitlab_net_spec.rb')
-rw-r--r--spec/gitlab_net_spec.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index be2f4ba..92b5f82 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -266,13 +266,21 @@ describe GitlabNet, vcr: true do
describe '#check_access' do
context 'ssh key with access nil, to project' do
- it 'should allow pull access for host' do
- VCR.use_cassette("allowed-pull") do
+ it 'should allow push access for host' do
+ VCR.use_cassette("allowed-push") do
access = gitlab_net.check_access('git-receive-pack', nil, project, key, changes, 'ssh')
+ expect(access).to be_instance_of(GitAccessStatus)
access.allowed?.should be_truthy
end
end
+ it 'should allow a custom action to be created' do
+ VCR.use_cassette("allowed-custom-action") do
+ access = gitlab_net.check_access('git-receive-pack', nil, project, key, changes, 'ssh')
+ expect(access).to be_instance_of(CustomActionStatus)
+ end
+ end
+
it 'adds the secret_token to the request' do
VCR.use_cassette("allowed-pull") do
Net::HTTP::Post.any_instance.should_receive(:set_form_data).with(hash_including(secret_token: secret))
@@ -280,12 +288,21 @@ describe GitlabNet, vcr: true do
end
end
- it 'should allow push access for host' do
- VCR.use_cassette("allowed-push") do
+ it 'should allow pull access for host' do
+ VCR.use_cassette("allowed-pull") do
access = gitlab_net.check_access('git-upload-pack', nil, project, key, changes, 'ssh')
+ expect(access).to be_instance_of(GitAccessStatus)
access.allowed?.should be_truthy
end
end
+
+ it 'should not allow pull access for host' do
+ VCR.use_cassette("not-allowed-pull") do
+ access = gitlab_net.check_access('git-upload-pack', nil, project, key, changes, 'ssh')
+ expect(access).to be_instance_of(GitAccessStatus)
+ access.allowed?.should be_falsey
+ end
+ end
end
context 'ssh access has been disabled' do