Commit 839439b8 authored by Victor Zagorodny's avatar Victor Zagorodny

Add VulnerabilityEntity w/ JSON schema tests

parent 1b5ba11b
# frozen_string_literal: true
class VulnerabilityEntity < Grape::Entity
expose :id
expose :title
expose :description
expose :state
expose :severity
expose :confidence
expose :project, using: ::ProjectEntity
expose :author_id
expose :updated_by_id
expose :last_edited_by_id
expose :closed_by_id
expose :start_date
expose :due_date
expose :created_at
expose :updated_at
expose :last_edited_at
expose :closed_at
end
{
"type": "object",
"required": ["title", "state", "confidence", "severity", "project", "author_id"],
"properties": {
"title": {
"type": "string"
},
"description": { "type": ["string", "null"] },
"state": { "type": "string", "enum": ["opened", "closed"] },
"severity": {
"type": "string",
"enum": ["undefined", "info", "unknown", "low", "medium", "high", "critical"]
},
"confidence": {
"type": "string",
"enum": [
"undefined",
"ignore",
"unknown",
"experimental",
"low",
"medium",
"high",
"confirmed"
]
},
"project": {
"required": ["id", "name", "full_path", "full_name"],
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"full_path": {
"type": "string"
},
"full_name": {
"type": "string"
}
},
"author_id": { "type": "integer" },
"updated_by_id": { "type": ["integer", "null"] },
"last_edited_by_id": { "type": ["integer", "null"] },
"closed_by_id": { "type": ["integer", "null"] },
"start_date": { "type": ["date", "null"] },
"due_date": { "type": ["date", "null"] },
"created_at": { "type": "date" },
"updated_at": { "type": "date" },
"last_edited_at": { "type": "date" },
"closed_at": { "type": "date" }
}
}
# frozen_string_literal: true
require 'spec_helper'
describe VulnerabilityEntity do
let(:vulnerability) do
create(:vulnerability)
end
let(:entity) do
described_class.represent(vulnerability)
end
subject { entity.to_json }
it { is_expected.to match_schema('vulnerability', dir: 'ee') }
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