Skip to content
代码片段 群组 项目
未验证 提交 37cdf991 编辑于 作者: Alexander Turinske's avatar Alexander Turinske 提交者: GitLab
浏览文件

Create project feature tests for policies list

- test appearance of policies in policy list
上级 6884d705
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "User sees policies list", :js, feature_category: :security_policy_management do
let_it_be(:owner) { create(:user) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :repository, namespace: owner.namespace) }
let_it_be(:policy_management_project) { create(:project, :repository, namespace: owner.namespace) }
let_it_be(:policy_configuration) do
create(
:security_orchestration_policy_configuration,
:namespace,
security_policy_management_project: policy_management_project,
namespace: group
)
end
let_it_be(:project_scan_execution_policy_pipeline) do
build(:scan_execution_policy, name: "Enforce SAST everyday for every project")
end
let_it_be(:policy_yaml) do
Gitlab::Config::Loader::Yaml.new(fixture_file('security_orchestration.yml', dir: 'ee')).load!
end
before_all do
group.add_owner(user)
policy_management_project.add_owner(user)
end
before do
allow_next_found_instance_of(Security::OrchestrationPolicyConfiguration) do |policy|
allow(policy).to receive(:policy_configuration_valid?).and_return(true)
allow(policy).to receive(:policy_hash).and_return(policy_yaml)
allow(policy).to receive(:policy_last_updated_at).and_return(Time.current)
end
sign_in(user)
stub_licensed_features(security_orchestration_policies: true)
end
it "shows the policies list with policies" do
visit(group_security_policies_path(group))
# Scan Execution Policy from ee/spec/fixtures/security_orchestration.yml
expect(page).to have_content 'Run DAST in every pipeline'
# Scan Result Policy from ee/spec/fixtures/security_orchestration.yml
expect(page).to have_content 'critical vulnerability CS approvals'
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "User sees policies list", :js, feature_category: :security_policy_management do
let_it_be(:owner) { create(:user) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, namespace: owner.namespace) }
let_it_be(:policy_management_project) { create(:project, :repository, namespace: owner.namespace) }
let_it_be(:policy_configuration) do
create(:security_orchestration_policy_configuration, security_policy_management_project: policy_management_project,
project: project)
end
let_it_be(:project_scan_execution_policy_pipeline) do
build(:scan_execution_policy, name: "Enforce SAST everyday for every project")
end
let_it_be(:policy_yaml) do
Gitlab::Config::Loader::Yaml.new(fixture_file('security_orchestration.yml', dir: 'ee')).load!
end
before_all do
project.add_owner(user)
policy_management_project.add_owner(user)
end
before do
allow_next_found_instance_of(Security::OrchestrationPolicyConfiguration) do |policy|
allow(policy).to receive(:policy_configuration_valid?).and_return(true)
allow(policy).to receive(:policy_hash).and_return(policy_yaml)
allow(policy).to receive(:policy_last_updated_at).and_return(Time.current)
end
sign_in(user)
stub_licensed_features(security_orchestration_policies: true)
end
it "shows the policies list with policies" do
visit(project_security_policies_path(project))
# Scan Execution Policy from ee/spec/fixtures/security_orchestration.yml
expect(page).to have_content 'Run DAST in every pipeline'
# Scan Result Policy from ee/spec/fixtures/security_orchestration.yml
expect(page).to have_content 'critical vulnerability CS approvals'
end
it "removes a policy project" do
visit(project_security_policies_path(project))
click_button 'Edit policy project'
click_button 'Unlink project'
click_button 'Save'
expect(page).not_to have_content 'Run DAST in every pipeline'
expect(page).not_to have_content 'critical vulnerability CS approvals'
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册