debian-mirror-gitlab/spec/features/security/project/private_access_spec.rb

385 lines
15 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
describe "Private Project Access", feature: true do
2015-09-11 14:41:01 +05:30
include AccessMatchers
2016-06-02 11:05:42 +05:30
let(:project) { create(:project, :private) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
let(:owner) { project.owner }
let(:master) { create(:user) }
let(:developer) { create(:user) }
let(:reporter) { create(:user) }
let(:guest) { create(:user) }
2014-09-02 18:07:02 +05:30
before do
project.team << [master, :master]
2016-06-02 11:05:42 +05:30
project.team << [developer, :developer]
2014-09-02 18:07:02 +05:30
project.team << [reporter, :reporter]
2016-06-02 11:05:42 +05:30
project.team << [guest, :guest]
2014-09-02 18:07:02 +05:30
end
describe "Project should be private" do
2015-04-26 12:48:37 +05:30
describe '#private?' do
2016-06-02 11:05:42 +05:30
subject { project.private? }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_truthy }
end
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for guest }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/tree/master" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_tree_path(project.namespace, project, project.repository.root_ref) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/commits/master" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_commits_path(project.namespace, project, project.repository.root_ref, limit: 1) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/commit/:sha" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_commit_path(project.namespace, project, project.repository.commit) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/compare" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_compare_index_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
describe "GET /:project_path/project_members" do
subject { namespace_project_project_members_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for :admin }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for guest }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/blob" do
2016-06-02 11:05:42 +05:30
let(:commit) { project.repository.commit }
subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore'))}
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/edit" do
2015-04-26 12:48:37 +05:30
subject { edit_namespace_project_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/deploy_keys" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_deploy_keys_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/issues" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_issues_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for guest }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
describe "GET /:project_path/issues/:id/edit" do
let(:issue) { create(:issue, project: project) }
subject { edit_namespace_project_issue_path(project.namespace, project, issue) }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-09-11 14:41:01 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-09-11 14:41:01 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-09-11 14:41:01 +05:30
it { is_expected.to be_denied_for :visitor }
end
2014-09-02 18:07:02 +05:30
describe "GET /:project_path/snippets" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_snippets_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for guest }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/merge_requests" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_merge_requests_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for guest }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/branches" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_branches_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
before do
# Speed increase
2015-04-26 12:48:37 +05:30
allow_any_instance_of(Project).to receive(:branches).and_return([])
2014-09-02 18:07:02 +05:30
end
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/tags" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_tags_path(project.namespace, project) }
2014-09-02 18:07:02 +05:30
before do
# Speed increase
2015-04-26 12:48:37 +05:30
allow_any_instance_of(Project).to receive(:tags).and_return([])
2014-09-02 18:07:02 +05:30
end
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
describe "GET /:project_path/hooks" do
2015-04-26 12:48:37 +05:30
subject { namespace_project_hooks_path(project.namespace, project) }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_allowed_for master }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for developer }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
2016-06-02 11:05:42 +05:30
it { is_expected.to be_denied_for :external }
2015-04-26 12:48:37 +05:30
it { is_expected.to be_denied_for :visitor }
2014-09-02 18:07:02 +05:30
end
2016-08-24 12:49:21 +05:30
describe "GET /:project_path/pipelines" do
subject { namespace_project_pipelines_path(project.namespace, project) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/pipelines/:id" do
let(:pipeline) { create(:ci_pipeline, project: project) }
subject { namespace_project_pipeline_path(project.namespace, project, pipeline) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/builds" do
subject { namespace_project_builds_path(project.namespace, project) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/builds/:id" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
subject { namespace_project_build_path(project.namespace, project, build.id) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/environments" do
subject { namespace_project_environments_path(project.namespace, project) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/environments/:id" do
let(:environment) { create(:environment, project: project) }
subject { namespace_project_environment_path(project.namespace, project, environment) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/environments/new" do
subject { new_namespace_project_environment_path(project.namespace, project) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/container_registry" do
before do
stub_container_registry_tags('latest')
stub_container_registry_config(enabled: true)
end
subject { namespace_project_container_registry_index_path(project.namespace, project) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for developer }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :external }
it { is_expected.to be_denied_for :visitor }
end
2014-09-02 18:07:02 +05:30
end