Commit 318caa9a authored by Alan (Maciej) Paruszewski's avatar Alan (Maciej) Paruszewski Committed by Shinya Maeda

Return ID for newly created vulnerability issue links

parent 72002e21
---
title: Return ID of newly created vulnerability issue link in API
merge_request: 35947
author:
type: added
...@@ -4,6 +4,7 @@ module EE ...@@ -4,6 +4,7 @@ module EE
module API module API
module Entities module Entities
class VulnerabilityIssueLink < Grape::Entity class VulnerabilityIssueLink < Grape::Entity
expose :id
expose :vulnerability, using: ::EE::API::Entities::Vulnerability expose :vulnerability, using: ::EE::API::Entities::Vulnerability
expose :issue, using: ::API::Entities::IssueBasic expose :issue, using: ::API::Entities::IssueBasic
expose :link_type expose :link_type
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"id",
"issue", "issue",
"vulnerability", "vulnerability",
"link_type" "link_type"
], ],
"properties": { "properties": {
"id": { "type": "integer" },
"issue": { "issue": {
"oneOf": [ "oneOf": [
{ "$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/issue.json" } { "$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/issue.json" }
......
...@@ -75,6 +75,7 @@ RSpec.describe API::VulnerabilityIssueLinks do ...@@ -75,6 +75,7 @@ RSpec.describe API::VulnerabilityIssueLinks do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/vulnerability_issue_link', dir: 'ee') expect(response).to match_response_schema('public_api/v4/vulnerability_issue_link', dir: 'ee')
expect(json_response['id']).to eq Vulnerabilities::IssueLink.last.id
expect(json_response['issue']['id']).to eq issue.id expect(json_response['issue']['id']).to eq issue.id
expect(json_response['vulnerability']['id']).to eq vulnerability.id expect(json_response['vulnerability']['id']).to eq vulnerability.id
end end
...@@ -166,6 +167,7 @@ RSpec.describe API::VulnerabilityIssueLinks do ...@@ -166,6 +167,7 @@ RSpec.describe API::VulnerabilityIssueLinks do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/vulnerability_issue_link', dir: 'ee') expect(response).to match_response_schema('public_api/v4/vulnerability_issue_link', dir: 'ee')
expect(json_response['id']).to eq issue_link_id
expect(json_response['issue']['id']).to eq vulnerability_issue_link.issue.id expect(json_response['issue']['id']).to eq vulnerability_issue_link.issue.id
expect(json_response['vulnerability']['id']).to eq vulnerability_id expect(json_response['vulnerability']['id']).to eq vulnerability_id
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