Commit 562d3ab8 authored by Subashis  Chakraborty's avatar Subashis Chakraborty Committed by Patrick Bair

Add security training providers

- Migration for adding two providers
- Add related specs

Changelog: added
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81104
parent 9d638a97
# frozen_string_literal: true
class AddSecurityTrainingProviders < Gitlab::Database::Migration[1.0]
KONTRA_DATA = {
name: 'Kontra',
description: "Kontra Application Security provides interactive developer security education that
enables engineers to quickly learn security best practices
and fix issues in their code by analysing real-world software security vulnerabilities.",
url: "https://application.security/api/webhook/gitlab/exercises/search"
}
SCW_DATA = {
name: 'Secure Code Warrior',
description: "Resolve vulnerabilities faster and confidently with highly relevant and bite-sized secure coding learning.",
url: "https://integration-api.securecodewarrior.com/api/v1/trial"
}
module Security
class TrainingProvider < ActiveRecord::Base
self.table_name = 'security_training_providers'
end
end
def up
current_time = Time.current
timestamps = { created_at: current_time, updated_at: current_time }
Security::TrainingProvider.reset_column_information
# upsert providers
Security::TrainingProvider.upsert_all([KONTRA_DATA.merge(timestamps), SCW_DATA.merge(timestamps)])
end
def down
Security::TrainingProvider.reset_column_information
Security::TrainingProvider.find_by(name: KONTRA_DATA[:name])&.destroy
Security::TrainingProvider.find_by(name: SCW_DATA[:name])&.destroy
end
end
8a0e80b6df1d942e5ec23641c935103cddd96c044e2a960b88bb38284cf4d070
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe AddSecurityTrainingProviders, :migration do
include MigrationHelpers::WorkItemTypesHelper
let_it_be(:security_training_providers) { table(:security_training_providers) }
it 'creates default data' do
# Need to delete all as security training providers are seeded before entire test suite
security_training_providers.delete_all
reversible_migration do |migration|
migration.before -> {
expect(security_training_providers.count).to eq(0)
}
migration.after -> {
expect(security_training_providers.count).to eq(2)
}
end
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