Commit 759f6a3f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '247935-update-dast-profiles-routes' into 'master'

Remove old DAST profiles routes

See merge request gitlab-org/gitlab!42123
parents be019e51 95de1ade
...@@ -14,8 +14,8 @@ import { ...@@ -14,8 +14,8 @@ import {
GlSprintf, GlSprintf,
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import dastScannerProfilesQuery from 'ee/dast_profiles/graphql/dast_scanner_profiles.query.graphql'; import dastScannerProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_scanner_profiles.query.graphql';
import dastSiteProfilesQuery from 'ee/dast_profiles/graphql/dast_site_profiles.query.graphql'; import dastSiteProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_site_profiles.query.graphql';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
......
import dastScannerProfilesQuery from 'ee/dast_profiles/graphql/dast_scanner_profiles.query.graphql'; import dastScannerProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_scanner_profiles.query.graphql';
import dastSiteProfilesQuery from 'ee/dast_profiles/graphql/dast_site_profiles.query.graphql'; import dastSiteProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_site_profiles.query.graphql';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
export const ERROR_RUN_SCAN = 'ERROR_RUN_SCAN'; export const ERROR_RUN_SCAN = 'ERROR_RUN_SCAN';
......
import initDastProfiles from 'ee/dast_profiles/dast_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastProfiles);
import initDastScannerProfileForm from 'ee/dast_scanner_profiles/dast_scanner_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastScannerProfileForm);
import initDastScannerProfileForm from 'ee/dast_scanner_profiles/dast_scanner_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastScannerProfileForm);
import initDastSiteProfileForm from 'ee/dast_site_profiles_form';
document.addEventListener('DOMContentLoaded', initDastSiteProfileForm);
import initDastSiteProfileForm from 'ee/dast_site_profiles_form';
document.addEventListener('DOMContentLoaded', initDastSiteProfileForm);
import initDastProfiles from 'ee/dast_profiles/dast_profiles_bundle'; import initDastProfiles from 'ee/security_configuration/dast_profiles/dast_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastProfiles); document.addEventListener('DOMContentLoaded', initDastProfiles);
import initDastScannerProfileForm from 'ee/dast_scanner_profiles/dast_scanner_profiles_bundle'; import initDastScannerProfileForm from 'ee/security_configuration/dast_scanner_profiles/dast_scanner_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastScannerProfileForm); document.addEventListener('DOMContentLoaded', initDastScannerProfileForm);
import initDastScannerProfileForm from 'ee/dast_scanner_profiles/dast_scanner_profiles_bundle'; import initDastScannerProfileForm from 'ee/security_configuration/dast_scanner_profiles/dast_scanner_profiles_bundle';
document.addEventListener('DOMContentLoaded', initDastScannerProfileForm); document.addEventListener('DOMContentLoaded', initDastScannerProfileForm);
import initDastSiteProfileForm from 'ee/dast_site_profiles_form'; import initDastSiteProfileForm from 'ee/security_configuration/dast_site_profiles_form';
document.addEventListener('DOMContentLoaded', initDastSiteProfileForm); document.addEventListener('DOMContentLoaded', initDastSiteProfileForm);
import initDastSiteProfileForm from 'ee/dast_site_profiles_form'; import initDastSiteProfileForm from 'ee/security_configuration/dast_site_profiles_form';
document.addEventListener('DOMContentLoaded', initDastSiteProfileForm); document.addEventListener('DOMContentLoaded', initDastSiteProfileForm);
import dastSiteProfilesQuery from 'ee/dast_profiles/graphql/dast_site_profiles.query.graphql'; import dastSiteProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_site_profiles.query.graphql';
import dastSiteProfilesDelete from 'ee/dast_profiles/graphql/dast_site_profiles_delete.mutation.graphql'; import dastSiteProfilesDelete from 'ee/security_configuration/dast_profiles/graphql/dast_site_profiles_delete.mutation.graphql';
import dastScannerProfilesQuery from 'ee/dast_profiles/graphql/dast_scanner_profiles.query.graphql'; import dastScannerProfilesQuery from 'ee/security_configuration/dast_profiles/graphql/dast_scanner_profiles.query.graphql';
import dastScannerProfilesDelete from 'ee/dast_profiles/graphql/dast_scanner_profiles_delete.mutation.graphql'; import dastScannerProfilesDelete from 'ee/security_configuration/dast_profiles/graphql/dast_scanner_profiles_delete.mutation.graphql';
import { dastProfilesDeleteResponse } from 'ee/dast_profiles/graphql/cache_utils'; import { dastProfilesDeleteResponse } from 'ee/security_configuration/dast_profiles/graphql/cache_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
const hasNoFeatureFlagOrIsEnabled = glFeatures => ([, { featureFlag }]) => { const hasNoFeatureFlagOrIsEnabled = glFeatures => ([, { featureFlag }]) => {
......
# frozen_string_literal: true
module Projects
class DastProfilesController < Projects::ApplicationController
before_action :authorize_read_on_demand_scans!
before_action do
push_frontend_feature_flag(:security_on_demand_scans_scanner_profiles, project, default_enabled: true)
end
def show
end
end
end
# frozen_string_literal: true
module Projects
class DastScannerProfilesController < Projects::ApplicationController
before_action :authorize_read_on_demand_scans!
def new
end
def edit
@scanner_profile = @project
.dast_scanner_profiles
.find(params[:id])
end
end
end
# frozen_string_literal: true
module Projects
class DastSiteProfilesController < Projects::ApplicationController
before_action do
authorize_read_on_demand_scans!
push_frontend_feature_flag(:security_on_demand_scans_site_validation, @project)
end
def new
end
def edit
@site_profile = DastSiteProfilesFinder.new(project_id: @project.id, id: params[:id]).execute.first! # rubocop: disable CodeReuse/ActiveRecord
end
end
end
- add_to_breadcrumbs s_('OnDemandScans|On-demand Scans'), project_on_demand_scans_path(@project)
- breadcrumb_title s_('DastProfiles|Manage profiles')
- page_title s_('DastProfiles|Manage profiles')
.js-dast-profiles{ data: { new_dast_site_profile_path: new_project_dast_site_profile_path(@project),
new_dast_scanner_profile_path: new_project_dast_scanner_profile_path(@project),
project_full_path: @project.path_with_namespace } }
- add_to_breadcrumbs s_('OnDemandScans|On-demand Scans'), project_on_demand_scans_path(@project)
- add_to_breadcrumbs s_('DastProfiles|Manage profiles'), project_profiles_path(@project, anchor: 'scanner-profiles')
- breadcrumb_title s_('DastProfiles|Edit scanner profile')
- page_title s_('DastProfiles|Edit scanner profile')
.js-dast-scanner-profile-form{ data: { project_full_path: @project.path_with_namespace,
profiles_library_path: project_profiles_path(@project, anchor: 'scanner-profiles'),
scanner_profile: { id: @scanner_profile.to_global_id.to_s, name: @scanner_profile.name, spider_timeout: @scanner_profile.spider_timeout, target_timeout: @scanner_profile.target_timeout }.to_json } }
- add_to_breadcrumbs s_('OnDemandScans|On-demand Scans'), project_on_demand_scans_path(@project)
- add_to_breadcrumbs s_('DastProfiles|Manage profiles'), project_profiles_path(@project, anchor: 'scanner-profiles')
- breadcrumb_title s_('DastProfiles|New scanner profile')
- page_title s_('DastProfiles|New scanner profile')
.js-dast-scanner-profile-form{ data: { project_full_path: @project.path_with_namespace,
profiles_library_path: project_profiles_path(@project, anchor: 'scanner-profiles') } }
- add_to_breadcrumbs s_('OnDemandScans|On-demand Scans'), project_on_demand_scans_path(@project)
- add_to_breadcrumbs s_('DastProfiles|Manage profiles'), project_profiles_path(@project, anchor: 'site-profiles')
- breadcrumb_title s_('DastProfiles|Edit site profile')
- page_title s_('DastProfiles|Edit site profile')
.js-dast-site-profile-form{ data: { full_path: @project.path_with_namespace,
profiles_library_path: project_profiles_path(@project, anchor: 'site-profiles'),
site_profile: { id: @site_profile.to_global_id.to_s, name: @site_profile.name, target_url: @site_profile.dast_site.url }.to_json } }
- add_to_breadcrumbs s_('OnDemandScans|On-demand Scans'), project_on_demand_scans_path(@project)
- add_to_breadcrumbs s_('DastProfiles|Manage profiles'), project_profiles_path(@project, anchor: 'site-profiles')
- breadcrumb_title s_('DastProfiles|New site profile')
- page_title s_('DastProfiles|New site profile')
.js-dast-site-profile-form{ data: { full_path: @project.path_with_namespace,
profiles_library_path: project_profiles_path(@project, anchor: 'site-profiles') } }
...@@ -59,7 +59,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -59,7 +59,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :configuration, only: [:show], controller: :configuration do resource :configuration, only: [:show], controller: :configuration do
post :auto_fix, on: :collection post :auto_fix, on: :collection
resource :sast, only: [:show, :create], controller: :sast_configuration resource :sast, only: [:show, :create], controller: :sast_configuration
resource :dast_profiles, only: [:show], controller: :dast_profiles do resource :dast_profiles, only: [:show] do
resources :dast_site_profiles, only: [:new, :edit] resources :dast_site_profiles, only: [:new, :edit]
resources :dast_scanner_profiles, only: [:new, :edit] resources :dast_scanner_profiles, only: [:new, :edit]
end end
...@@ -96,11 +96,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -96,11 +96,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
scope :on_demand_scans do scope :on_demand_scans do
root 'on_demand_scans#index', as: 'on_demand_scans' root 'on_demand_scans#index', as: 'on_demand_scans'
scope :profiles do
root 'dast_profiles#show', as: 'profiles'
resources :dast_site_profiles, only: [:new, :edit]
resources :dast_scanner_profiles, only: [:new, :edit]
end
end end
namespace :integrations do namespace :integrations do
......
...@@ -9,7 +9,7 @@ const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-sca ...@@ -9,7 +9,7 @@ const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-sca
const projectPath = 'group/project'; const projectPath = 'group/project';
const defaultBranch = 'master'; const defaultBranch = 'master';
const emptyStateSvgPath = `${TEST_HOST}/assets/illustrations/alert-management-empty-state.svg`; const emptyStateSvgPath = `${TEST_HOST}/assets/illustrations/alert-management-empty-state.svg`;
const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/on_demand_scans/profiles`; const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/security/configuration/dast_profiles`;
describe('OnDemandScansApp', () => { describe('OnDemandScansApp', () => {
let wrapper; let wrapper;
......
...@@ -9,10 +9,10 @@ import { redirectTo } from '~/lib/utils/url_utility'; ...@@ -9,10 +9,10 @@ import { redirectTo } from '~/lib/utils/url_utility';
const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-scans`; const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-scans`;
const projectPath = 'group/project'; const projectPath = 'group/project';
const defaultBranch = 'master'; const defaultBranch = 'master';
const scannerProfilesLibraryPath = '/on_demand_scans/profiles#scanner-profiles'; const scannerProfilesLibraryPath = '/security/configuration/dast_profiles#scanner-profiles';
const siteProfilesLibraryPath = '/on_demand_scans/profiles#site-profiles'; const siteProfilesLibraryPath = '/security/configuration/dast_profiles#site-profiles';
const newScannerProfilePath = '/on_demand_scans/profiles/dast_scanner_profile/new'; const newScannerProfilePath = '/security/configuration/dast_profiles/dast_scanner_profile/new';
const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/on_demand_scans/profiles`; const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/security/configuration/dast_profiles`;
const defaultProps = { const defaultProps = {
helpPagePath, helpPagePath,
......
...@@ -2,7 +2,7 @@ import { merge } from 'lodash'; ...@@ -2,7 +2,7 @@ import { merge } from 'lodash';
import { mount, shallowMount, createWrapper } from '@vue/test-utils'; import { mount, shallowMount, createWrapper } from '@vue/test-utils';
import { within } from '@testing-library/dom'; import { within } from '@testing-library/dom';
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import DastProfilesList from 'ee/dast_profiles/components/dast_profiles_list.vue'; import DastProfilesList from 'ee/security_configuration/dast_profiles/components/dast_profiles_list.vue';
const TEST_ERROR_MESSAGE = 'something went wrong'; const TEST_ERROR_MESSAGE = 'something went wrong';
......
...@@ -3,7 +3,7 @@ import { within } from '@testing-library/dom'; ...@@ -3,7 +3,7 @@ import { within } from '@testing-library/dom';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { GlDropdown, GlTabs } from '@gitlab/ui'; import { GlDropdown, GlTabs } from '@gitlab/ui';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
import DastProfiles from 'ee/dast_profiles/components/dast_profiles.vue'; import DastProfiles from 'ee/security_configuration/dast_profiles/components/dast_profiles.vue';
const TEST_NEW_DAST_SCANNER_PROFILE_PATH = '/-/on_demand_scans/scanner_profiles/new'; const TEST_NEW_DAST_SCANNER_PROFILE_PATH = '/-/on_demand_scans/scanner_profiles/new';
const TEST_NEW_DAST_SITE_PROFILE_PATH = '/-/on_demand_scans/site_profiles/new'; const TEST_NEW_DAST_SITE_PROFILE_PATH = '/-/on_demand_scans/site_profiles/new';
......
...@@ -2,7 +2,7 @@ import { ...@@ -2,7 +2,7 @@ import {
appendToPreviousResult, appendToPreviousResult,
removeProfile, removeProfile,
dastProfilesDeleteResponse, dastProfilesDeleteResponse,
} from 'ee/dast_profiles/graphql/cache_utils'; } from 'ee/security_configuration/dast_profiles/graphql/cache_utils';
describe('EE - DastProfiles GraphQL CacheUtils', () => { describe('EE - DastProfiles GraphQL CacheUtils', () => {
describe('appendToPreviousResult', () => { describe('appendToPreviousResult', () => {
......
...@@ -3,9 +3,9 @@ import { within } from '@testing-library/dom'; ...@@ -3,9 +3,9 @@ import { within } from '@testing-library/dom';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { GlAlert, GlForm, GlModal } from '@gitlab/ui'; import { GlAlert, GlForm, GlModal } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import DastScannerProfileForm from 'ee/dast_scanner_profiles/components/dast_scanner_profile_form.vue'; import DastScannerProfileForm from 'ee/security_configuration/dast_scanner_profiles/components/dast_scanner_profile_form.vue';
import dastScannerProfileCreateMutation from 'ee/dast_scanner_profiles/graphql/dast_scanner_profile_create.mutation.graphql'; import dastScannerProfileCreateMutation from 'ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_create.mutation.graphql';
import dastScannerProfileUpdateMutation from 'ee/dast_scanner_profiles/graphql/dast_scanner_profile_update.mutation.graphql'; import dastScannerProfileUpdateMutation from 'ee/security_configuration/dast_scanner_profiles/graphql/dast_scanner_profile_update.mutation.graphql';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({ jest.mock('~/lib/utils/url_utility', () => ({
...@@ -13,7 +13,7 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -13,7 +13,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
})); }));
const projectFullPath = 'group/project'; const projectFullPath = 'group/project';
const profilesLibraryPath = `${TEST_HOST}/${projectFullPath}/-/on_demand_scans/profiles`; const profilesLibraryPath = `${TEST_HOST}/${projectFullPath}/-/security/configuration/dast_profiles`;
const profileName = 'My DAST scanner profile'; const profileName = 'My DAST scanner profile';
const spiderTimeout = 12; const spiderTimeout = 12;
const targetTimeout = 20; const targetTimeout = 20;
......
...@@ -6,13 +6,13 @@ import { createMockClient } from 'mock-apollo-client'; ...@@ -6,13 +6,13 @@ import { createMockClient } from 'mock-apollo-client';
import { GlForm, GlModal } from '@gitlab/ui'; import { GlForm, GlModal } from '@gitlab/ui';
import waitForPromises from 'jest/helpers/wait_for_promises'; import waitForPromises from 'jest/helpers/wait_for_promises';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import DastSiteProfileForm from 'ee/dast_site_profiles_form/components/dast_site_profile_form.vue'; import DastSiteProfileForm from 'ee/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue';
import DastSiteValidation from 'ee/dast_site_profiles_form/components/dast_site_validation.vue'; import DastSiteValidation from 'ee/security_configuration/dast_site_profiles_form/components/dast_site_validation.vue';
import dastSiteValidationQuery from 'ee/dast_site_profiles_form/graphql/dast_site_validation.query.graphql'; import dastSiteValidationQuery from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_validation.query.graphql';
import dastSiteProfileCreateMutation from 'ee/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql'; import dastSiteProfileCreateMutation from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql';
import dastSiteProfileUpdateMutation from 'ee/dast_site_profiles_form/graphql/dast_site_profile_update.mutation.graphql'; import dastSiteProfileUpdateMutation from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_update.mutation.graphql';
import dastSiteTokenCreateMutation from 'ee/dast_site_profiles_form/graphql/dast_site_token_create.mutation.graphql'; import dastSiteTokenCreateMutation from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_token_create.mutation.graphql';
import * as responses from 'ee_jest/dast_site_profiles_form/mock_data/apollo_mock'; import * as responses from 'ee_jest/security_configuration/dast_site_profiles_form/mock_data/apollo_mock';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({ jest.mock('~/lib/utils/url_utility', () => ({
...@@ -24,7 +24,7 @@ const localVue = createLocalVue(); ...@@ -24,7 +24,7 @@ const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
const fullPath = 'group/project'; const fullPath = 'group/project';
const profilesLibraryPath = `${TEST_HOST}/${fullPath}/-/on_demand_scans/profiles`; const profilesLibraryPath = `${TEST_HOST}/${fullPath}/-/security/configuration/dast_profiles`;
const profileName = 'My DAST site profile'; const profileName = 'My DAST site profile';
const targetUrl = 'http://example.com'; const targetUrl = 'http://example.com';
const tokenId = '3455'; const tokenId = '3455';
......
...@@ -5,10 +5,10 @@ import { createLocalVue, mount, shallowMount } from '@vue/test-utils'; ...@@ -5,10 +5,10 @@ import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
import { createMockClient } from 'mock-apollo-client'; import { createMockClient } from 'mock-apollo-client';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import waitForPromises from 'jest/helpers/wait_for_promises'; import waitForPromises from 'jest/helpers/wait_for_promises';
import DastSiteValidation from 'ee/dast_site_profiles_form/components/dast_site_validation.vue'; import DastSiteValidation from 'ee/security_configuration/dast_site_profiles_form/components/dast_site_validation.vue';
import dastSiteValidationCreateMutation from 'ee/dast_site_profiles_form/graphql/dast_site_validation_create.mutation.graphql'; import dastSiteValidationCreateMutation from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_validation_create.mutation.graphql';
import dastSiteValidationQuery from 'ee/dast_site_profiles_form/graphql/dast_site_validation.query.graphql'; import dastSiteValidationQuery from 'ee/security_configuration/dast_site_profiles_form/graphql/dast_site_validation.query.graphql';
import * as responses from 'ee_jest/dast_site_profiles_form/mock_data/apollo_mock'; import * as responses from 'ee_jest/security_configuration/dast_site_profiles_form/mock_data/apollo_mock';
import download from '~/lib/utils/downloader'; import download from '~/lib/utils/downloader';
jest.mock('~/lib/utils/downloader'); jest.mock('~/lib/utils/downloader');
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::DastProfilesController, type: :request do
let(:project) { create(:project) }
let(:user) { create(:user) }
describe 'GET #index' do
context 'feature available' do
before do
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: true)
end
context 'user authorized' do
before do
project.add_developer(user)
login_as(user)
end
it 'can access page' do
get project_profiles_path(project)
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'user not authorized' do
before do
project.add_guest(user)
login_as(user)
end
it 'sees a 404 error' do
get project_profiles_path(project)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'feature not available' do
before do
project.add_developer(user)
login_as(user)
end
context 'feature flag is disabled' do
it 'sees a 404 error' do
stub_feature_flags(security_on_demand_scans_feature_flag: false)
stub_licensed_features(security_on_demand_scans: true)
get project_profiles_path(project)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'license doesnt\'t support the feature' do
it 'sees a 404 error' do
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: false)
get project_profiles_path(project)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::DastScannerProfilesController, type: :request do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile, project: project) }
shared_context 'on-demand scans feature available' do
before do
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: true)
end
end
shared_context 'user authorized' do
before(:all) do
project.add_developer(user)
end
before do
login_as(user)
end
end
shared_examples 'a GET request' do
context 'feature available' do
include_context 'on-demand scans feature available'
context 'user authorized' do
include_context 'user authorized'
it 'can access page' do
get path
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'user not authorized' do
before do
project.add_guest(user)
login_as(user)
end
it 'sees a 404 error' do
get path
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'feature not available' do
using RSpec::Parameterized::TableSyntax
include_context 'user authorized'
where(:feature_flag_enabled, :license_support) do
false | true
true | false
end
with_them do
it 'sees a 404 error' do
stub_feature_flags(security_on_demand_scans_feature_flag: feature_flag_enabled)
stub_licensed_features(security_on_demand_scans: license_support)
get path
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
describe 'GET #new' do
it_behaves_like 'a GET request' do
let(:path) { new_project_dast_scanner_profile_path(project) }
end
end
describe 'GET #edit' do
include_context 'user authorized'
include_context 'on-demand scans feature available'
let(:edit_path) { edit_project_dast_scanner_profile_path(project, dast_scanner_profile) }
it_behaves_like 'a GET request' do
let(:path) { edit_path }
end
it 'sets scanner_profile' do
get edit_path
expect(assigns(:scanner_profile)).to eq(dast_scanner_profile)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::DastSiteProfilesController, type: :request do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:dast_site_profile) { create(:dast_site_profile, project: project) }
def with_feature_available
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: true)
end
def with_user_authorized
project.add_developer(user)
login_as(user)
end
shared_examples 'a GET request' do
context 'feature available' do
before do
with_feature_available
end
context 'user authorized' do
before do
with_user_authorized
end
it 'can access page' do
get path
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'user not authorized' do
before do
project.add_guest(user)
login_as(user)
end
it 'sees a 404 error' do
get path
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'feature not available' do
before do
with_user_authorized
end
context 'feature flag is disabled' do
it 'sees a 404 error' do
stub_feature_flags(security_on_demand_scans_feature_flag: false)
stub_licensed_features(security_on_demand_scans: true)
get path
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'license doesnt\'t support the feature' do
it 'sees a 404 error' do
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: false)
get path
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
describe 'GET #new' do
it_behaves_like 'a GET request' do
let(:path) { new_project_dast_site_profile_path(project) }
end
end
describe 'GET #edit' do
let(:edit_path) { edit_project_dast_site_profile_path(project, dast_site_profile) }
it_behaves_like 'a GET request' do
let(:path) { edit_path }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "projects/dast_profiles/show", type: :view do
before do
@project = create(:project)
render
end
it 'renders Vue app root' do
expect(rendered).to have_selector('.js-dast-profiles')
end
it 'passes new dast site profile path' do
expect(rendered).to include '/on_demand_scans/profiles/dast_site_profiles/new'
end
it 'passes new dast scanner profile path' do
expect(rendered).to include '/on_demand_scans/profiles/dast_scanner_profiles/new'
end
it 'passes project\'s full path' do
expect(rendered).to include @project.path_with_namespace
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "projects/dast_scanner_profiles/edit", type: :view do
let_it_be(:scanner_profile) { create(:dast_scanner_profile) }
let_it_be(:scanner_profile_gid) { ::URI::GID.parse("gid://gitlab/DastScannerProfile/#{scanner_profile.id}") }
before do
assign(:project, scanner_profile.project)
assign(:scanner_profile, scanner_profile)
assign(:scanner_profile_gid, scanner_profile_gid)
render
end
it 'renders Vue app root' do
expect(rendered).to have_selector('.js-dast-scanner-profile-form')
end
it 'passes project\'s full path' do
expect(rendered).to include scanner_profile.project.path_with_namespace
end
it 'passes DAST profiles library URL' do
expect(rendered).to include '/on_demand_scans/profiles'
end
it 'passes DAST scanner profile\'s data' do
expect(rendered).to include scanner_profile_gid.to_s
expect(rendered).to include scanner_profile.name
expect(rendered).to include scanner_profile.spider_timeout.to_s
expect(rendered).to include scanner_profile.target_timeout.to_s
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "projects/dast_scanner_profiles/new", type: :view do
before do
@project = create(:project)
render
end
it 'renders Vue app root' do
expect(rendered).to have_selector('.js-dast-scanner-profile-form')
end
it 'passes project\'s full path' do
expect(rendered).to include @project.path_with_namespace
end
it 'passes DAST profiles library URL' do
expect(rendered).to include '/on_demand_scans/profiles#scanner-profiles'
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "projects/dast_site_profiles/edit", type: :view do
let_it_be(:site_profile) { create(:dast_site_profile) }
let_it_be(:site_profile_gid) { ::URI::GID.parse("gid://gitlab/DastSiteProfile/#{site_profile.id}") }
before do
assign(:project, site_profile.project)
assign(:site_profile, site_profile)
assign(:site_profile_gid, site_profile_gid)
render
end
it 'renders Vue app root' do
expect(rendered).to have_selector('.js-dast-site-profile-form')
end
it 'passes project\'s full path' do
expect(rendered).to include site_profile.project.path_with_namespace
end
it 'passes DAST profiles library URL' do
expect(rendered).to include '/on_demand_scans/profiles#site-profiles'
end
it 'passes DAST site profile\'s data' do
expect(rendered).to include site_profile_gid.to_s
expect(rendered).to include site_profile.name
expect(rendered).to include site_profile.dast_site.url
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "projects/dast_site_profiles/new", type: :view do
before do
@project = create(:project)
render
end
it 'renders Vue app root' do
expect(rendered).to have_selector('.js-dast-site-profile-form')
end
it 'passes project\'s full path' do
expect(rendered).to include @project.path_with_namespace
end
it 'passes DAST profiles library URL' do
expect(rendered).to include '/on_demand_scans/profiles#site-profiles'
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