Commit 64b00a0b authored by Alexander Turinske's avatar Alexander Turinske

Remove assign policy project mutation

- it is no longer needed as `createSecurityPolicyProject` assigns
  the new project already
- create additional tests
parent 476b71f3
import assignPolicyProject from 'ee/threat_monitoring/graphql/mutations/assign_policy_project.mutation.graphql';
import createPolicyProject from 'ee/threat_monitoring/graphql/mutations/create_policy_project.mutation.graphql';
import createScanExecutionPolicy from 'ee/threat_monitoring/graphql/mutations/create_scan_execution_policy.mutation.graphql';
import { gqClient } from 'ee/threat_monitoring/utils';
......@@ -23,7 +22,7 @@ const checkForErrors = ({ errors }) => {
const assignSecurityPolicyProject = async (projectPath) => {
const {
data: {
securityPolicyProjectCreate: { project, errors: createErrors },
securityPolicyProjectCreate: { project, errors },
},
} = await gqClient.mutate({
mutation: createPolicyProject,
......@@ -32,21 +31,7 @@ const assignSecurityPolicyProject = async (projectPath) => {
},
});
checkForErrors({ errors: createErrors });
const {
data: {
securityPolicyProjectAssign: { errors: assignErrors },
},
} = await gqClient.mutate({
mutation: assignPolicyProject,
variables: {
projectPath,
id: project.id,
},
});
return { ...project, errors: assignErrors };
return { ...project, errors };
};
/**
......
mutation assignPolicyProject($projectPath: ID!, $id: ProjectID!) {
securityPolicyProjectAssign(input: { projectPath: $projectPath, securityPolicyProjectId: $id }) {
errors
}
}
import { savePolicy } from 'ee/threat_monitoring/components/policy_editor/scan_execution_policy/lib/utils';
import { DEFAULT_ASSIGNED_POLICY_PROJECT } from 'ee/threat_monitoring/constants';
import assignPolicyProject from 'ee/threat_monitoring/graphql/mutations/assign_policy_project.mutation.graphql';
import createPolicyProject from 'ee/threat_monitoring/graphql/mutations/create_policy_project.mutation.graphql';
import createScanExecutionPolicy from 'ee/threat_monitoring/graphql/mutations/create_scan_execution_policy.mutation.graphql';
import { gqClient } from 'ee/threat_monitoring/utils';
......@@ -31,12 +30,6 @@ const mockApolloResponses = (shouldReject) => {
},
},
});
} else if (mutation === assignPolicyProject) {
return Promise.resolve({
data: {
securityPolicyProjectAssign: { errors: [] },
},
});
} else if (mutation === createScanExecutionPolicy) {
return Promise.resolve({
data: {
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Security::PoliciesHelper do
describe '#assigned_policy_project' do
let(:project) { create(:project) }
context 'when a project does have a security policy project' do
let(:policy_management_project) { create(:project) }
let!(:policy_configuration) { create(:security_orchestration_policy_configuration, security_policy_management_project: policy_management_project, project: project) }
subject { helper.assigned_policy_project(project) }
it {
is_expected.to include({
id: policy_management_project.to_global_id.to_s,
name: policy_management_project.name,
full_path: policy_management_project.full_path,
branch: policy_management_project.default_branch_or_main
})
}
end
context 'when a project does not have a security policy project' do
subject { helper.assigned_policy_project(project) }
it {
is_expected.to be_nil
}
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment