Commit 5962ebf6 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '235745-fix-dast-site-profile-update-mutation' into 'master'

Fix client-side mutation for updating DAST site profiles

See merge request gitlab-org/gitlab!39344
parents 68dc4110 1d7f2563
mutation dastSiteProfileUpdate(
$id: ID!
$id: DastSiteProfileID!
$fullPath: ID!
$profileName: String!
$targetUrl: String
) {
project(fullPath: $fullPath) {
dastSiteProfileUpdate(input: { id: $id, profileName: $profileName, targetUrl: $targetUrl }) {
id
errors
}
dastSiteProfileUpdate(
input: { id: $id, fullPath: $fullPath, profileName: $profileName, targetUrl: $targetUrl }
) {
id
errors
}
}
......@@ -5,4 +5,4 @@
.js-dast-site-profile-form{ data: { full_path: @project.path_with_namespace,
profiles_library_path: project_profiles_path(@project),
site_profile: { id: @site_profile.id, name: @site_profile.name, target_url: @site_profile.dast_site.url }.to_json } }
site_profile: { id: @site_profile.to_global_id.to_s, name: @site_profile.name, target_url: @site_profile.dast_site.url }.to_json } }
......@@ -7,18 +7,25 @@ RSpec.describe Projects::DastSiteProfilesController, type: :request do
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
stub_feature_flags(security_on_demand_scans_feature_flag: true)
stub_licensed_features(security_on_demand_scans: true)
with_feature_available
end
context 'user authorized' do
before do
project.add_developer(user)
login_as(user)
with_user_authorized
end
it 'can access page' do
......@@ -45,9 +52,7 @@ RSpec.describe Projects::DastSiteProfilesController, type: :request do
context 'feature not available' do
before do
project.add_developer(user)
login_as(user)
with_user_authorized
end
context 'feature flag is disabled' do
......@@ -79,8 +84,10 @@ RSpec.describe Projects::DastSiteProfilesController, type: :request do
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_project_dast_site_profile_path(project, dast_site_profile) }
let(:path) { edit_path }
end
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'
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
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