Commit b898ff1d authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'json-cop-autocorrects-ee' into 'master'

Gitlab/Json autocorrects in /ee

See merge request gitlab-org/gitlab!30625
parents 8b21eacf 5a367ce2
......@@ -75,7 +75,7 @@ module EE
respond_to do |format|
format.html do
seat_link_json = JSON.pretty_generate(data)
seat_link_json = ::Gitlab::Json.pretty_generate(data)
render html: ::Gitlab::Highlight.highlight('payload.json', seat_link_json, language: 'json')
end
......
......@@ -17,7 +17,7 @@ module EE
def rollout_status_instances
data = File.read(Rails.root.join('spec', 'fixtures', 'rollout_status_instances.json'))
JSON.parse(data)
Gitlab::Json.parse(data)
end
def rollout_status_deployments
......
......@@ -228,7 +228,7 @@ module Vulnerabilities
def metadata
strong_memoize(:metadata) do
JSON.parse(raw_metadata)
Gitlab::Json.parse(raw_metadata)
rescue JSON::ParserError
{}
end
......
......@@ -10,7 +10,7 @@ module DependencyProxy
response = Gitlab::HTTP.get(auth_url)
if response.success?
success(token: JSON.parse(response.body)['token'])
success(token: Gitlab::Json.parse(response.body)['token'])
else
error('Expected 200 response code for an access token', response.code)
end
......
......@@ -19,7 +19,7 @@ class FetchSubscriptionPlansService
query: { plan: @plan },
headers: { 'Accept' => 'application/json' })
JSON.parse(response.body).map { |plan| Hashie::Mash.new(plan) }
Gitlab::Json.parse(response.body).map { |plan| Hashie::Mash.new(plan) }
rescue => e
Rails.logger.info "Unable to connect to GitLab Customers App #{e}" # rubocop:disable Gitlab/RailsLogger
......
......@@ -30,7 +30,7 @@ module Geo
def sync_tag(tag)
file = nil
manifest = client.repository_raw_manifest(name, tag)
manifest_parsed = JSON.parse(manifest)
manifest_parsed = Gitlab::Json.parse(manifest)
list_blobs(manifest_parsed).each do |digest|
next if container_repository.blob_exists?(digest)
......
......@@ -16,8 +16,7 @@ class Gitlab::Seeder::Packages
name = "@#{@project.root_namespace.path}/npm_package_#{SecureRandom.hex}"
version = "1.12.#{i}"
params = JSON.parse(
read_fixture_file('npm', 'payload.json')
params = Gitlab::Json.parse(read_fixture_file('npm', 'payload.json')
.gsub('@root/npm-test', name)
.gsub('1.0.1', version))
.with_indifferent_access
......
......@@ -10,7 +10,7 @@ module Gitlab
PARSERS = { '1' => V1, '2' => V2 }.freeze
def parse!(json_data, report)
json = JSON.parse(json_data, symbolize_names: true, object_class: Hash)
json = Gitlab::Json.parse(json_data, symbolize_names: true, object_class: Hash)
return unless json.is_a?(Hash)
report.version = json[:version].presence || DEFAULT_VERSION
......
......@@ -24,7 +24,7 @@ module Gitlab
protected
def parse_report(json_data)
JSON.parse!(json_data)
Gitlab::Json.parse!(json_data)
end
# map remediations to relevant vulnerabilities
......
......@@ -10,7 +10,7 @@ module Gitlab
end
def parse!(json_data, report)
report_data = JSON.parse(json_data)
report_data = Gitlab::Json.parse(json_data)
report_data.fetch('dependency_files', []).each do |file|
file['dependencies'].each do |dependency|
report.add_dependency(formatter.format(dependency,
......
......@@ -16,7 +16,7 @@ module Gitlab
private
def parse_report_json(blob)
JSON.parse!(blob)
Gitlab::Json.parse!(blob)
rescue JSON::ParserError
{}
end
......
......@@ -70,7 +70,7 @@ module Gitlab
)
message = decoded.first
data = JSON.parse(message['data']) if message
data = Gitlab::Json.parse(message['data']) if message
data&.deep_symbolize_keys!
data
rescue JWT::ImmatureSignature, JWT::ExpiredSignature
......
......@@ -22,7 +22,7 @@ module Gitlab
private
def parse(json)
build_catalogue(JSON.parse(json, symbolize_names: true))
build_catalogue(Gitlab::Json.parse(json, symbolize_names: true))
end
def record_failure(tags = {})
......
......@@ -74,7 +74,7 @@ describe Projects::PipelinesController do
let!(:mit_license) { create(:software_license, :mit) }
let!(:software_license_policy) { create(:software_license_policy, software_license: mit_license, project: project) }
let(:payload) { JSON.parse(licenses_with_json.body) }
let(:payload) { Gitlab::Json.parse(licenses_with_json.body) }
context 'with a license scanning artifact' do
before do
......
......@@ -48,7 +48,7 @@ describe Projects::ServiceDeskController do
get :show, params: { namespace_id: project.namespace.to_param, project_id: project }, format: :json
response_hash = JSON.parse(response.body)
response_hash = Gitlab::Json.parse(response.body)
expect(response_hash['template_file_missing']).to eq(false)
end
end
......
......@@ -4,7 +4,7 @@ FactoryBot.define do
factory :spdx_catalogue, class: '::Gitlab::SPDX::Catalogue' do
initialize_with do
content = IO.read(Rails.root.join('spec', 'fixtures', 'spdx.json'))
::Gitlab::SPDX::Catalogue.new(JSON.parse(content, symbolize_names: true))
::Gitlab::SPDX::Catalogue.new(Gitlab::Json.parse(content, symbolize_names: true))
end
end
end
......@@ -12,7 +12,7 @@ FactoryBot.define do
after(:build) do |finding, evaluator|
if evaluator.summary
raw_metadata = JSON.parse(finding.raw_metadata)
raw_metadata = Gitlab::Json.parse(finding.raw_metadata)
raw_metadata.delete("solution")
raw_metadata["remediations"] = [
{
......@@ -93,7 +93,7 @@ FactoryBot.define do
trait :with_remediation do
after(:build) do |finding|
raw_metadata = JSON.parse(finding.raw_metadata)
raw_metadata = Gitlab::Json.parse(finding.raw_metadata)
raw_metadata.delete(:solution)
raw_metadata[:remediations] = [
{
......
......@@ -12,7 +12,7 @@ describe 'Billing plan pages', :feature do
let(:silver_plan) { create(:silver_plan) }
let(:gold_plan) { create(:gold_plan) }
let(:plans_data) do
JSON.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
Gitlab::Json.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
data.deep_symbolize_keys
end
end
......
......@@ -29,7 +29,7 @@ describe 'EE > Projects > Licenses > Maintainer views policies', :js do
let_it_be(:mit) { create(:software_license, :mit) }
let_it_be(:mit_policy) { create(:software_license_policy, :denied, software_license: mit, project: project) }
let_it_be(:pipeline) { create(:ee_ci_pipeline, project: project, builds: [create(:ee_ci_build, :license_scan_v2, :success)]) }
let(:report) { JSON.parse(fixture_file('security_reports/gl-license-scanning-report-v2.json', dir: 'ee')) }
let(:report) { Gitlab::Json.parse(fixture_file('security_reports/gl-license-scanning-report-v2.json', dir: 'ee')) }
let(:known_licenses) { report['licenses'].find_all { |license| license['url'].present? } }
it 'displays licenses detected in the most recent scan report' do
......
......@@ -9,7 +9,7 @@ describe 'Show trial banner', :js do
let!(:group) { create(:group) }
let!(:gold_plan) { create(:gold_plan) }
let(:plans_data) do
JSON.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
Gitlab::Json.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
data.deep_symbolize_keys
end
end
......
......@@ -299,7 +299,7 @@ describe Security::PipelineVulnerabilitiesFinder do
end
def read_fixture(fixture)
JSON.parse(File.read(fixture.file.path))
Gitlab::Json.parse(File.read(fixture.file.path))
end
end
end
......
......@@ -47,7 +47,7 @@ describe StatusPage::IncidentCommentsFinder do
describe 'award emoji' do
let(:digest_path) { Rails.root.join(*%w[fixtures emojis digests.json]) }
let(:digest_json) { JSON.parse(File.read(digest_path)) }
let(:digest_json) { Gitlab::Json.parse(File.read(digest_path)) }
it 'ensures that emoji exists' do
expect(digest_json).to include(visible_emoji)
......
......@@ -84,7 +84,7 @@ describe GitlabSchema.types['Vulnerability'] do
it "is the JSON metadata for the vulnerability's location" do
vulnerabilities = subject.dig('data', 'project', 'vulnerabilities', 'nodes')
expect(JSON.parse(vulnerabilities.first['location'])).to eq(location)
expect(Gitlab::Json.parse(vulnerabilities.first['location'])).to eq(location)
end
end
end
......@@ -74,7 +74,7 @@ describe VulnerabilitiesHelper do
describe 'when pipeline exists' do
let(:pipeline) { create(:ci_pipeline) }
let(:pipelineData) { JSON.parse(subject[:pipeline_json]) }
let(:pipelineData) { Gitlab::Json.parse(subject[:pipeline_json]) }
include_examples 'vulnerability properties'
......
......@@ -41,7 +41,7 @@ describe EE::API::Helpers do
get 'user'
expect(JSON.parse(last_response.body)).to eq({ 'id' => user.id })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'id' => user.id })
end
it 'does not handle sticking if no user could be found' do
......@@ -52,7 +52,7 @@ describe EE::API::Helpers do
get 'user'
expect(JSON.parse(last_response.body)).to eq({ 'found' => false })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'found' => false })
end
it 'returns the user if one could be found' do
......@@ -60,7 +60,7 @@ describe EE::API::Helpers do
get 'user'
expect(JSON.parse(last_response.body)).to eq({ 'id' => user.id })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'id' => user.id })
end
end
......@@ -71,7 +71,7 @@ describe EE::API::Helpers do
header 'Authorization', 'test'
get 'protected', params: { current_user: 'test' }
expect(JSON.parse(last_response.body)).to eq({ 'message' => 'Gitlab::Geo::InvalidDecryptionKeyError' })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'message' => 'Gitlab::Geo::InvalidDecryptionKeyError' })
end
it 'rescues from ::Gitlab::Geo::InvalidSignatureTimeError' do
......@@ -80,7 +80,7 @@ describe EE::API::Helpers do
header 'Authorization', 'test'
get 'protected', params: { current_user: 'test' }
expect(JSON.parse(last_response.body)).to eq({ 'message' => 'Gitlab::Geo::InvalidSignatureTimeError' })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'message' => 'Gitlab::Geo::InvalidSignatureTimeError' })
end
it 'returns unauthorized response when scope is not valid' do
......@@ -89,7 +89,7 @@ describe EE::API::Helpers do
header 'Authorization', 'test'
get 'protected', params: { current_user: 'test' }
expect(JSON.parse(last_response.body)).to eq({ 'message' => '401 Unauthorized' })
expect(Gitlab::Json.parse(last_response.body)).to eq({ 'message' => '401 Unauthorized' })
end
end
......
......@@ -180,7 +180,7 @@ describe Gitlab::ImportExport::Group::TreeSaver do
def read_association(group, association)
path = exported_path_for(File.join("#{group.id}", "#{association}.ndjson"))
File.foreach(path).map {|line| JSON.parse(line) }
File.foreach(path).map {|line| Gitlab::Json.parse(line) }
end
def expect_successful_save(group_tree_saver)
......
......@@ -130,14 +130,14 @@ describe Gitlab::Ci::Parsers::LicenseCompliance::LicenseScanning do
context 'when the report version is not recognized' do
it do
expect do
subject.parse!(JSON.pretty_generate({ version: 'x' }), report)
subject.parse!(Gitlab::Json.pretty_generate({ version: 'x' }), report)
end.to raise_error(KeyError)
end
end
context 'when the report version is missing' do
before do
subject.parse!(JSON.pretty_generate({}), report)
subject.parse!(Gitlab::Json.pretty_generate({}), report)
end
it { expect(report.version).to eq('1.0') }
......@@ -146,7 +146,7 @@ describe Gitlab::Ci::Parsers::LicenseCompliance::LicenseScanning do
context 'when the report version is nil' do
before do
subject.parse!(JSON.pretty_generate({ version: nil }), report)
subject.parse!(Gitlab::Json.pretty_generate({ version: nil }), report)
end
it { expect(report.version).to eq('1.0') }
......@@ -155,7 +155,7 @@ describe Gitlab::Ci::Parsers::LicenseCompliance::LicenseScanning do
context 'when the report version is blank' do
before do
subject.parse!(JSON.pretty_generate({ version: '' }), report)
subject.parse!(Gitlab::Json.pretty_generate({ version: '' }), report)
end
it { expect(report.version).to eq('1.0') }
......@@ -163,7 +163,7 @@ describe Gitlab::Ci::Parsers::LicenseCompliance::LicenseScanning do
end
context 'when the report is structured as an array' do
let(:invalid_json) { JSON.pretty_generate([]) }
let(:invalid_json) { Gitlab::Json.pretty_generate([]) }
before do
subject.parse!(invalid_json, report)
......
......@@ -48,7 +48,7 @@ describe Gitlab::Ci::Parsers::Security::ContainerScanning do
end
it "adds report image's name to raw_metadata" do
expect(JSON.parse(report.occurrences.first.raw_metadata).dig('location', 'image')).to eq(image)
expect(Gitlab::Json.parse(report.occurrences.first.raw_metadata).dig('location', 'image')).to eq(image)
end
end
end
......
......@@ -50,7 +50,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyScanning do
end
context "when parsing a vulnerability with a missing location" do
let(:report_hash) { JSON.parse(fixture_file('security_reports/master/gl-sast-report.json', dir: 'ee'), symbolize_names: true) }
let(:report_hash) { Gitlab::Json.parse(fixture_file('security_reports/master/gl-sast-report.json', dir: 'ee'), symbolize_names: true) }
before do
report_hash[:vulnerabilities][0][:location] = nil
......@@ -60,7 +60,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyScanning do
end
context "when parsing a vulnerability with a missing cve" do
let(:report_hash) { JSON.parse(fixture_file('security_reports/master/gl-sast-report.json', dir: 'ee'), symbolize_names: true) }
let(:report_hash) { Gitlab::Json.parse(fixture_file('security_reports/master/gl-sast-report.json', dir: 'ee'), symbolize_names: true) }
before do
report_hash[:vulnerabilities][0][:cve] = nil
......@@ -80,7 +80,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyScanning do
it "generates occurrence with expected remediation" do
occurrence = report.occurrences.last
raw_metadata = JSON.parse!(occurrence.raw_metadata)
raw_metadata = Gitlab::Json.parse!(occurrence.raw_metadata)
expect(occurrence.name).to eq("Authentication bypass via incorrect DOM traversal and canonicalization in saml2-js")
expect(raw_metadata["remediations"].first["summary"]).to eq("Upgrade saml2-js")
......
......@@ -6,7 +6,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::Dast do
let(:formatter) { described_class.new(parsed_report) }
let(:parsed_report) do
JSON.parse!(
Gitlab::Json.parse!(
File.read(
Rails.root.join('ee/spec/fixtures/security_reports/deprecated/gl-dast-report-no-common-fields.json')
)
......
......@@ -8,7 +8,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do
let(:sha) { '4242424242424242' }
let(:parsed_report) do
JSON.parse!(
Gitlab::Json.parse!(
File.read(
Rails.root.join('ee/spec/fixtures/security_reports/dependency_list/gl-dependency-scanning-report.json')
)
......
......@@ -7,7 +7,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DeprecatedContainerScanning
describe '#format' do
let(:raw_report) do
JSON.parse!(
Gitlab::Json.parse!(
File.read(
Rails.root.join('ee/spec/fixtures/security_reports/deprecated/gl-container-scanning-report.json')
)
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
describe Gitlab::Ci::Parsers::Security::Formatters::DeprecatedFormattedContainerScanningVulnerability do
let(:raw_report) do
JSON.parse!(
Gitlab::Json.parse!(
File.read(
Rails.root.join('ee/spec/fixtures/security_reports/deprecated/gl-container-scanning-report.json')
)
......
......@@ -49,7 +49,7 @@ describe Gitlab::Ci::Parsers::Security::Sast do
context "when parsing an empty report" do
let(:report) { Gitlab::Ci::Reports::Security::Report.new('sast', commit_sha, created_at) }
let(:blob) { JSON.generate({}) }
let(:blob) { Gitlab::Json.generate({}) }
it { expect(parser.parse!(blob, report)).to be_empty }
end
......
......@@ -53,7 +53,7 @@ describe Gitlab::Database::LoadBalancing::SrvResolver do
def dns_response_packet_from_fixture(fixture_name)
fixture = File.read(Rails.root + "ee/spec/fixtures/dns/#{fixture_name}.json")
encoded_payload = JSON.parse(fixture)['payload']
encoded_payload = Gitlab::Json.parse(fixture)['payload']
payload = Base64.decode64(encoded_payload)
Net::DNS::Packet.parse(payload)
......
......@@ -34,7 +34,7 @@ describe Gitlab::Geo::Oauth::Session, :geo do
end
it 'returns hashed user data' do
parsed_json = JSON.parse(user_json)
parsed_json = Gitlab::Json.parse(user_json)
expect(subject.authenticate(access_token.token)).to eq(parsed_json)
end
......
......@@ -11,7 +11,7 @@ describe Gitlab::SPDX::CatalogueGateway do
context "when the licenses.json endpoint is healthy" do
let(:spdx_json) { IO.read(Rails.root.join("spec", "fixtures", "spdx.json")) }
let(:catalogue_hash) { JSON.parse(spdx_json, symbolize_names: true) }
let(:catalogue_hash) { Gitlab::Json.parse(spdx_json, symbolize_names: true) }
before do
stub_full_request(url, method: :get).to_return(status: 200, body: spdx_json)
......
......@@ -6,7 +6,7 @@ RSpec.describe Gitlab::SPDX::Catalogue do
subject { described_class.new(catalogue_hash) }
let(:spdx_json) { IO.read(Rails.root.join("spec", "fixtures", "spdx.json")) }
let(:catalogue_hash) { JSON.parse(spdx_json, symbolize_names: true) }
let(:catalogue_hash) { Gitlab::Json.parse(spdx_json, symbolize_names: true) }
describe "#version" do
let(:version) { SecureRandom.uuid }
......
......@@ -30,7 +30,7 @@ describe EpicPresenter do
end
it 'has correct ancestors' do
metadata = JSON.parse(presenter.show_data[:meta])
metadata = Gitlab::Json.parse(presenter.show_data[:meta])
ancestor_url = metadata['ancestors'].first['url']
expect(ancestor_url).to eq "/groups/#{parent_epic.group.full_path}/-/epics/#{parent_epic.iid}"
......
......@@ -37,7 +37,7 @@ describe Projects::Security::ConfigurationPresenter do
end
it 'reports that all security jobs are configured' do
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: true),
security_scan(:sast, configured: true),
security_scan(:container_scanning, configured: true),
......@@ -57,7 +57,7 @@ describe Projects::Security::ConfigurationPresenter do
end
it 'reports all security jobs as unconfigured' do
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: false),
security_scan(:sast, configured: false),
security_scan(:container_scanning, configured: false),
......@@ -83,7 +83,7 @@ describe Projects::Security::ConfigurationPresenter do
end
it 'uses the latest default branch pipeline to determine whether a security job is configured' do
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: true),
security_scan(:sast, configured: true),
security_scan(:container_scanning, configured: false),
......@@ -97,7 +97,7 @@ describe Projects::Security::ConfigurationPresenter do
create(:ci_build, :sast, pipeline: pipeline)
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: false),
security_scan(:sast, configured: true),
security_scan(:container_scanning, configured: false),
......@@ -117,7 +117,7 @@ describe Projects::Security::ConfigurationPresenter do
subject
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: false),
security_scan(:sast, configured: true),
security_scan(:container_scanning, configured: false),
......@@ -129,7 +129,7 @@ describe Projects::Security::ConfigurationPresenter do
it 'detect new license compliance job' do
create(:ci_build, :license_scanning, pipeline: pipeline)
expect(JSON.parse(subject[:features])).to contain_exactly(
expect(Gitlab::Json.parse(subject[:features])).to contain_exactly(
security_scan(:dast, configured: true),
security_scan(:sast, configured: true),
security_scan(:container_scanning, configured: false),
......
......@@ -158,7 +158,7 @@ describe API::FeatureFlagScopes do
expect(response).to match_response_schema('public_api/v4/feature_flag_scope', dir: 'ee')
expect(json_response['environment_scope']).to eq(params[:environment_scope])
expect(json_response['active']).to eq(params[:active])
expect(json_response['strategies']).to eq(JSON.parse(params[:strategies]))
expect(json_response['strategies']).to eq(Gitlab::Json.parse(params[:strategies]))
end
context 'when the scope already exists' do
......@@ -258,7 +258,7 @@ describe API::FeatureFlagScopes do
expect(response).to match_response_schema('public_api/v4/feature_flag_scope', dir: 'ee')
expect(json_response['id']).to eq(scope.id)
expect(json_response['active']).to eq(params[:active])
expect(json_response['strategies']).to eq(JSON.parse(params[:strategies]))
expect(json_response['strategies']).to eq(Gitlab::Json.parse(params[:strategies]))
end
context 'when there are no corresponding feature flag scopes' do
......
......@@ -354,7 +354,7 @@ describe API::FeatureFlags do
feature_flag.scopes.ordered.each_with_index do |scope, index|
expect(scope.environment_scope).to eq(params[:scopes][index][:environment_scope])
expect(scope.active).to eq(params[:scopes][index][:active])
expect(scope.strategies).to eq(JSON.parse(params[:scopes][index][:strategies]))
expect(scope.strategies).to eq(Gitlab::Json.parse(params[:scopes][index][:strategies]))
end
end
end
......@@ -480,7 +480,7 @@ describe API::FeatureFlags do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/feature_flag', dir: 'ee')
expect(feature_flag.name).to eq(params[:name])
expect(scope.strategies).to eq([JSON.parse(params[:strategy])])
expect(scope.strategies).to eq([Gitlab::Json.parse(params[:strategy])])
expect(feature_flag.version).to eq('legacy_flag')
end
......@@ -507,7 +507,7 @@ describe API::FeatureFlags do
scope = feature_flag.scopes.find_by_environment_scope(params[:environment_scope])
expect(response).to have_gitlab_http_status(:ok)
expect(scope.strategies).to eq([JSON.parse(params[:strategy])])
expect(scope.strategies).to eq([Gitlab::Json.parse(params[:strategy])])
end
it_behaves_like 'check user permission'
......@@ -525,11 +525,11 @@ describe API::FeatureFlags do
scope = feature_flag.scopes.find_by_environment_scope(params[:environment_scope])
expect(response).to have_gitlab_http_status(:ok)
expect(scope.strategies).to eq([defined_strategy.deep_stringify_keys, JSON.parse(params[:strategy])])
expect(scope.strategies).to eq([defined_strategy.deep_stringify_keys, Gitlab::Json.parse(params[:strategy])])
end
context 'when the specified strategy exists already' do
let(:defined_strategy) { JSON.parse(params[:strategy]) }
let(:defined_strategy) { Gitlab::Json.parse(params[:strategy]) }
it 'does not add a duplicate strategy' do
subject
......
......@@ -149,6 +149,6 @@ describe 'get board lists' do
end
def grab_list_data(response_body)
JSON.parse(response_body)['data'][board_parent_type]['boards']['edges'][0]['node']['lists']['edges']
Gitlab::Json.parse(response_body)['data'][board_parent_type]['boards']['edges'][0]['node']['lists']['edges']
end
end
......@@ -188,7 +188,7 @@ describe 'Query.project(fullPath).issue(iid).designCollection.version(sha)' do
post_graphql(cursored_query, current_user: current_user)
new_data = JSON.parse(response.body).fetch('data')
new_data = Gitlab::Json.parse(response.body).fetch('data')
expect(response_values(new_data)).to match_array(ids.drop(2))
end
......
......@@ -105,7 +105,7 @@ describe 'Getting versions related to an issue' do
post_graphql(cursored_query, current_user: current_user)
new_data = JSON.parse(response.body).fetch('data')
new_data = Gitlab::Json.parse(response.body).fetch('data')
expect(response_values(new_data)).to match_array(ids.drop(2))
end
......
......@@ -114,7 +114,7 @@ describe 'Getting designs related to an issue' do
post_graphql(cursored_query, current_user: current_user)
new_data = JSON.parse(response.body).fetch('data')
new_data = Gitlab::Json.parse(response.body).fetch('data')
expect(response_ids(new_data)).to match_array(ids.drop(2))
end
......
......@@ -107,7 +107,7 @@ describe 'getting a requirement list for a project' do
cursored_query = query("sort: #{sort_by}, after: \"#{end_cursor}\"")
post_graphql(cursored_query, current_user: current_user)
JSON.parse(response.body)['data']['project']['requirements']['edges']
Gitlab::Json.parse(response.body)['data']['project']['requirements']['edges']
end
before do
......
......@@ -395,8 +395,7 @@ describe API::NpmPackages do
end
def upload_params(package_name:, package_version: '1.0.1', file: 'npm/payload.json')
JSON.parse(
fixture_file(file, dir: 'ee')
Gitlab::Json.parse(fixture_file(file, dir: 'ee')
.gsub('@root/npm-test', package_name)
.gsub('1.0.1', package_version))
end
......
......@@ -31,7 +31,7 @@ describe Geo::ContainerRepositorySync, :geo do
})
.to_return(
status: 200,
body: JSON.dump(tags: %w(obsolete)),
body: Gitlab::Json.dump(tags: %w(obsolete)),
headers: { 'Content-Type' => 'application/json' })
stub_request(:get, "http://primary.registry.gitlab/v2/group/test/my_image/tags/list")
......@@ -39,7 +39,7 @@ describe Geo::ContainerRepositorySync, :geo do
headers: { 'Authorization' => 'bearer pull-token' })
.to_return(
status: 200,
body: JSON.dump(tags: %w(tag-to-sync)),
body: Gitlab::Json.dump(tags: %w(tag-to-sync)),
headers: { 'Content-Type' => 'application/json' })
stub_request(:head, "http://primary.registry.gitlab/v2/group/test/my_image/manifests/tag-to-sync")
......
......@@ -10,7 +10,7 @@ describe Packages::CreateDependencyService do
context 'when packages are published' do
let(:json_file) { 'npm/payload.json' }
let(:params) do
JSON.parse(fixture_file(json_file, dir: 'ee')
Gitlab::Json.parse(fixture_file(json_file, dir: 'ee')
.gsub('@root/npm-test', package_name)
.gsub('1.0.1', version))
.with_indifferent_access
......
......@@ -8,11 +8,9 @@ describe Packages::Npm::CreatePackageService do
let(:version) { '1.0.1' }
let(:params) do
JSON.parse(
fixture_file('npm/payload.json', dir: 'ee')
Gitlab::Json.parse(fixture_file('npm/payload.json', dir: 'ee')
.gsub('@root/npm-test', package_name)
.gsub('1.0.1', version)
).with_indifferent_access
.gsub('1.0.1', version)).with_indifferent_access
.merge!(override)
end
let(:override) { {} }
......
......@@ -29,7 +29,7 @@ describe Subscriptions::CreateService do
end
let_it_be(:client) { Gitlab::SubscriptionPortal::Client }
let_it_be(:create_service_params) { JSON.parse(fixture_file('create_service_params.json', dir: 'ee')).deep_symbolize_keys }
let_it_be(:create_service_params) { Gitlab::Json.parse(fixture_file('create_service_params.json', dir: 'ee')).deep_symbolize_keys }
describe '#execute' do
context 'when failing to create a customer' do
......
......@@ -105,7 +105,7 @@ RSpec.shared_examples 'cluster metrics' do
let(:prometheus_body) { '{"status":"success"}' }
it 'returns prometheus response' do
prometheus_json_body = JSON.parse(prometheus_body)
prometheus_json_body = Gitlab::Json.parse(prometheus_body)
get :prometheus_proxy, params: prometheus_proxy_params
......
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