Commit b46ed688 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '357569-pass-identifier-name' into 'master'

Add `identifer` to response to pass as metric

See merge request gitlab-org/gitlab!84990
parents 29711a3f 03ba2c10
......@@ -16063,6 +16063,7 @@ Represents a URL related to a security training.
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="securitytrainingurlidentifier"></a>`identifier` | [`String`](#string) | Name of the vulnerability identifier. |
| <a id="securitytrainingurlname"></a>`name` | [`String`](#string) | Name of the training provider. |
| <a id="securitytrainingurlstatus"></a>`status` | [`TrainingUrlRequestStatus`](#trainingurlrequeststatus) | Status of the request to training provider. |
| <a id="securitytrainingurlurl"></a>`url` | [`String`](#string) | URL of the link for security training content. |
......@@ -14,13 +14,14 @@ module Security
@project = project
@provider = provider
@identifier_external_id = identifier_external_id.split('-').last
@identifier = identifier_external_id # we need this to hold the pre-parsed data
end
def execute
if response_url.nil?
{ name: provider.name, url: response_url, status: "pending" }
else
{ name: provider.name, url: response_url[:url], status: "completed" } if response_url[:url]
elsif response_url[:url]
{ name: provider.name, url: response_url[:url], status: "completed", identifier: @identifier }
end
end
......
......@@ -14,6 +14,9 @@ module Types
field :url, GraphQL::Types::String, null: true,
description: 'URL of the link for security training content.'
field :identifier, GraphQL::Types::String, null: true,
description: 'Name of the vulnerability identifier.'
end
end
end
......@@ -40,7 +40,7 @@ RSpec.describe Security::TrainingProviders::BaseUrlFinder do
end
it 'returns a url with status completed' do
expect(described_class.new(identifier.project, provider, identifier.external_id).execute).to eq({ name: provider.name, url: dummy_url, status: 'completed' })
expect(described_class.new(identifier.project, provider, identifier.external_id).execute).to eq({ name: provider.name, url: dummy_url, status: 'completed', identifier: identifier.external_id })
end
end
......
......@@ -49,7 +49,9 @@ RSpec.describe Security::TrainingUrlsFinder do
end
it 'returns training urls list with status completed' do
is_expected.to match_array([{ name: 'Kontra', url: 'http://test.host/test', status: 'completed' }])
is_expected.to match_array(
[{ name: 'Kontra', url: 'http://test.host/test', status: 'completed', identifier: identifier.external_id }]
)
end
end
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['SecurityTrainingUrl'] do
let(:fields) { %i[name url status] }
let(:fields) { %i[name url status identifier] }
it { expect(described_class).to have_graphql_fields(fields) }
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