Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 02:58:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 02:58:45 +0300
commit1794d7d6a11019da7fe8bb56536f3fce69d1825d (patch)
tree4975bcf5629d6322feab02d1987676ef5fd5411d /spec/controllers
parent5825f3338e723e631964bf67d259e3365014a442 (diff)
Add latest changes from gitlab-org/security/gitlab@15-9-stable-ee
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/concerns/confirm_email_warning_spec.rb34
-rw-r--r--spec/controllers/projects/blob_controller_spec.rb33
-rw-r--r--spec/controllers/projects/refs_controller_spec.rb2
-rw-r--r--spec/controllers/projects/tree_controller_spec.rb37
-rw-r--r--spec/controllers/projects_controller_spec.rb63
5 files changed, 13 insertions, 156 deletions
diff --git a/spec/controllers/concerns/confirm_email_warning_spec.rb b/spec/controllers/concerns/confirm_email_warning_spec.rb
index b8a4b94aa66..334c156e1ae 100644
--- a/spec/controllers/concerns/confirm_email_warning_spec.rb
+++ b/spec/controllers/concerns/confirm_email_warning_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ConfirmEmailWarning, feature_category: :system_access do
+RSpec.describe ConfirmEmailWarning do
before do
stub_feature_flags(soft_email_confirmation: true)
end
@@ -82,38 +82,6 @@ RSpec.describe ConfirmEmailWarning, feature_category: :system_access do
it { is_expected.to set_confirm_warning_for(user.email) }
end
end
-
- context 'when user is being impersonated' do
- let(:impersonator) { create(:admin) }
-
- before do
- allow(controller).to receive(:session).and_return({ impersonator_id: impersonator.id })
-
- get :index
- end
-
- it { is_expected.to set_confirm_warning_for(user.email) }
-
- context 'when impersonated user email has html in their email' do
- let(:user) { create(:user, confirmed_at: nil, unconfirmed_email: "malicious@test.com<form><input/title='<script>alert(document.domain)</script>'>") }
-
- it { is_expected.to set_confirm_warning_for("malicious@test.com&lt;form&gt;&lt;input/title=&#39;&lt;script&gt;alert(document.domain)&lt;/script&gt;&#39;&gt;") }
- end
- end
-
- context 'when user is not being impersonated' do
- before do
- get :index
- end
-
- it { is_expected.to set_confirm_warning_for(user.email) }
-
- context 'when user email has html in their email' do
- let(:user) { create(:user, confirmed_at: nil, unconfirmed_email: "malicious@test.com<form><input/title='<script>alert(document.domain)</script>'>") }
-
- it { is_expected.to set_confirm_warning_for("malicious@test.com&lt;form&gt;&lt;input/title=&#39;&lt;script&gt;alert(document.domain)&lt;/script&gt;&#39;&gt;") }
- end
- end
end
end
end
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb
index ec92d92e2a9..887a5ba598f 100644
--- a/spec/controllers/projects/blob_controller_spec.rb
+++ b/spec/controllers/projects/blob_controller_spec.rb
@@ -2,16 +2,15 @@
require 'spec_helper'
-RSpec.describe Projects::BlobController, feature_category: :source_code_management do
+RSpec.describe Projects::BlobController do
include ProjectForksHelper
let(:project) { create(:project, :public, :repository, previous_default_branch: previous_default_branch) }
let(:previous_default_branch) { nil }
describe "GET show" do
- let(:params) { { namespace_id: project.namespace, project_id: project, id: id } }
- let(:request) do
- get(:show, params: params)
+ def request
+ get(:show, params: { namespace_id: project.namespace, project_id: project, id: id })
end
render_views
@@ -19,32 +18,8 @@ RSpec.describe Projects::BlobController, feature_category: :source_code_manageme
context 'with file path' do
before do
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
- project.repository.add_tag(project.creator, 'ambiguous_ref', RepoHelpers.sample_commit.id)
- project.repository.add_branch(project.creator, 'ambiguous_ref', RepoHelpers.another_sample_commit.id)
- request
- end
-
- context 'when the ref is ambiguous' do
- let(:ref) { 'ambiguous_ref' }
- let(:path) { 'README.md' }
- let(:id) { "#{ref}/#{path}" }
- let(:params) { { namespace_id: project.namespace, project_id: project, id: id, ref_type: ref_type } }
- context 'and explicitly requesting a branch' do
- let(:ref_type) { 'heads' }
-
- it 'redirects to blob#show with sha for the branch' do
- expect(response).to redirect_to(project_blob_path(project, "#{RepoHelpers.another_sample_commit.id}/#{path}"))
- end
- end
-
- context 'and explicitly requesting a tag' do
- let(:ref_type) { 'tags' }
-
- it 'responds with success' do
- expect(response).to be_ok
- end
- end
+ request
end
context "valid branch, valid file" do
diff --git a/spec/controllers/projects/refs_controller_spec.rb b/spec/controllers/projects/refs_controller_spec.rb
index 7a511ab676e..a0d119baf16 100644
--- a/spec/controllers/projects/refs_controller_spec.rb
+++ b/spec/controllers/projects/refs_controller_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Projects::RefsController, feature_category: :source_code_manageme
'tree' | nil | lazy { project_tree_path(project, id) }
'tree' | 'heads' | lazy { project_tree_path(project, id) }
'blob' | nil | lazy { project_blob_path(project, id) }
- 'blob' | 'heads' | lazy { project_blob_path(project, id, ref_type: 'heads') }
+ 'blob' | 'heads' | lazy { project_blob_path(project, id) }
'graph' | nil | lazy { project_network_path(project, id) }
'graph' | 'heads' | lazy { project_network_path(project, id, ref_type: 'heads') }
'graphs' | nil | lazy { project_graph_path(project, id) }
diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb
index 37149e1d3ca..9bc3065b6da 100644
--- a/spec/controllers/projects/tree_controller_spec.rb
+++ b/spec/controllers/projects/tree_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Projects::TreeController, feature_category: :source_code_management do
+RSpec.describe Projects::TreeController do
let(:project) { create(:project, :repository, previous_default_branch: previous_default_branch) }
let(:previous_default_branch) { nil }
let(:user) { create(:user) }
@@ -15,41 +15,18 @@ RSpec.describe Projects::TreeController, feature_category: :source_code_manageme
end
describe "GET show" do
- let(:params) do
- {
- namespace_id: project.namespace.to_param, project_id: project, id: id
- }
- end
-
# Make sure any errors accessing the tree in our views bubble up to this spec
render_views
before do
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
- project.repository.add_tag(project.creator, 'ambiguous_ref', RepoHelpers.sample_commit.id)
- project.repository.add_branch(project.creator, 'ambiguous_ref', RepoHelpers.another_sample_commit.id)
- get :show, params: params
- end
-
- context 'when the ref is ambiguous' do
- let(:id) { 'ambiguous_ref' }
- let(:params) { { namespace_id: project.namespace, project_id: project, id: id, ref_type: ref_type } }
-
- context 'and explicitly requesting a branch' do
- let(:ref_type) { 'heads' }
-
- it 'redirects to blob#show with sha for the branch' do
- expect(response).to redirect_to(project_tree_path(project, RepoHelpers.another_sample_commit.id))
- end
- end
-
- context 'and explicitly requesting a tag' do
- let(:ref_type) { 'tags' }
- it 'responds with success' do
- expect(response).to be_ok
- end
- end
+ get(:show,
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: id
+ })
end
context "valid branch, no path" do
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index c5ec6651ab3..51f8a3b1197 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -163,69 +163,6 @@ RSpec.describe ProjectsController, feature_category: :projects do
expect(assigns(:notification_setting).level).to eq("watch")
end
end
-
- context 'when there is a tag with the same name as the default branch' do
- let_it_be(:tagged_project) { create(:project, :public, :custom_repo, files: ['somefile']) }
- let(:tree_with_default_branch) do
- branch = tagged_project.repository.find_branch(tagged_project.default_branch)
- project_tree_path(tagged_project, branch.target)
- end
-
- before do
- tagged_project.repository.create_file(
- tagged_project.creator,
- 'file_for_tag',
- 'content for file',
- message: "Automatically created file",
- branch_name: 'branch-to-tag'
- )
-
- tagged_project.repository.add_tag(
- tagged_project.creator,
- tagged_project.default_branch, # tag name
- 'branch-to-tag' # target
- )
- end
-
- it 'redirects to tree view for the default branch' do
- get :show, params: { namespace_id: tagged_project.namespace, id: tagged_project }
- expect(response).to redirect_to(tree_with_default_branch)
- end
- end
-
- context 'when the default branch name can resolve to another ref' do
- let!(:project_with_default_branch) do
- create(:project, :public, :custom_repo, files: ['somefile']).tap do |p|
- p.repository.create_branch("refs/heads/refs/heads/#{other_ref}", 'master')
- p.change_head("refs/heads/#{other_ref}")
- end.reload
- end
-
- let(:other_ref) { 'branch-name' }
-
- context 'but there is no other ref' do
- it 'responds with ok' do
- get :show, params: { namespace_id: project_with_default_branch.namespace, id: project_with_default_branch }
- expect(response).to be_ok
- end
- end
-
- context 'and that other ref exists' do
- let(:tree_with_default_branch) do
- branch = project_with_default_branch.repository.find_branch(project_with_default_branch.default_branch)
- project_tree_path(project_with_default_branch, branch.target)
- end
-
- before do
- project_with_default_branch.repository.create_branch(other_ref, 'master')
- end
-
- it 'redirects to tree view for the default branch' do
- get :show, params: { namespace_id: project_with_default_branch.namespace, id: project_with_default_branch }
- expect(response).to redirect_to(tree_with_default_branch)
- end
- end
- end
end
describe "when project repository is disabled" do