Skip to content
Snippets Groups Projects
Commit c503429e authored by Rubén Dávila's avatar Rubén Dávila
Browse files

Add migration to disable the usage of DSA keys

Additionally the current application setting is also updated to disable
the usage of DSA keys.
parent 160cc6cd
No related branches found
No related tags found
No related merge requests found
---
title: Add migration to disable the usage of DSA keys
merge_request: 19299
author:
type: other
class ChangeDefaultValueForDsaKeyRestriction < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
change_column :application_settings, :dsa_key_restriction, :integer, null: false,
default: -1
execute("UPDATE application_settings SET dsa_key_restriction = -1")
end
def down
change_column :application_settings, :dsa_key_restriction, :integer, null: false,
default: 0
end
end
Loading
Loading
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
 
ActiveRecord::Schema.define(version: 20180529093006) do
ActiveRecord::Schema.define(version: 20180531220618) do
 
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Loading
Loading
@@ -110,7 +110,7 @@ ActiveRecord::Schema.define(version: 20180529093006) do
t.text "shared_runners_text_html"
t.text "after_sign_up_text_html"
t.integer "rsa_key_restriction", default: 0, null: false
t.integer "dsa_key_restriction", default: 0, null: false
t.integer "dsa_key_restriction", default: -1, null: false
t.integer "ecdsa_key_restriction", default: 0, null: false
t.integer "ed25519_key_restriction", default: 0, null: false
t.boolean "housekeeping_enabled", default: true, null: false
Loading
Loading
require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180531220618_change_default_value_for_dsa_key_restriction.rb')
describe ChangeDefaultValueForDsaKeyRestriction, :migration do
let(:application_settings) { table(:application_settings) }
before do
application_settings.create!
end
it 'changes the default value for dsa_key_restriction' do
expect(application_settings.first.dsa_key_restriction).to eq(0)
migrate!
application_settings.reset_column_information
new_setting = application_settings.create!
expect(application_settings.count).to eq(2)
expect(new_setting.dsa_key_restriction).to eq(-1)
end
it 'changes the existing setting' do
setting = application_settings.last
expect(setting.dsa_key_restriction).to eq(0)
migrate!
expect(application_settings.count).to eq(1)
expect(setting.reload.dsa_key_restriction).to eq(-1)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment