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. ...@@ -16063,6 +16063,7 @@ Represents a URL related to a security training.
| Name | Type | Description | | 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="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="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. | | <a id="securitytrainingurlurl"></a>`url` | [`String`](#string) | URL of the link for security training content. |
...@@ -14,13 +14,14 @@ module Security ...@@ -14,13 +14,14 @@ module Security
@project = project @project = project
@provider = provider @provider = provider
@identifier_external_id = identifier_external_id.split('-').last @identifier_external_id = identifier_external_id.split('-').last
@identifier = identifier_external_id # we need this to hold the pre-parsed data
end end
def execute def execute
if response_url.nil? if response_url.nil?
{ name: provider.name, url: response_url, status: "pending" } { name: provider.name, url: response_url, status: "pending" }
else elsif response_url[:url]
{ name: provider.name, url: response_url[:url], status: "completed" } if response_url[:url] { name: provider.name, url: response_url[:url], status: "completed", identifier: @identifier }
end end
end end
......
...@@ -14,6 +14,9 @@ module Types ...@@ -14,6 +14,9 @@ module Types
field :url, GraphQL::Types::String, null: true, field :url, GraphQL::Types::String, null: true,
description: 'URL of the link for security training content.' 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 end
end end
...@@ -40,7 +40,7 @@ RSpec.describe Security::TrainingProviders::BaseUrlFinder do ...@@ -40,7 +40,7 @@ RSpec.describe Security::TrainingProviders::BaseUrlFinder do
end end
it 'returns a url with status completed' do 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
end end
......
...@@ -49,7 +49,9 @@ RSpec.describe Security::TrainingUrlsFinder do ...@@ -49,7 +49,9 @@ RSpec.describe Security::TrainingUrlsFinder do
end end
it 'returns training urls list with status completed' do 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
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe GitlabSchema.types['SecurityTrainingUrl'] do 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) } it { expect(described_class).to have_graphql_fields(fields) }
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