Commit 8236b12d authored by Alexis Reigel's avatar Alexis Reigel

gpg signature model for gpg verification caching

parent 2f956fae
class GpgSignature < ActiveRecord::Base
belongs_to :project
belongs_to :gpg_key
validates :commit_sha, presence: true
validates :project, presence: true
end
class CreateGpgSignatures < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
create_table :gpg_signatures do |t|
t.string :commit_sha
t.references :project, index: true, foreign_key: true
t.references :gpg_key, index: true, foreign_key: true
t.string :gpg_key_primary_keyid
t.boolean :valid_signature
t.timestamps_with_timezone null: false
end
add_concurrent_index :gpg_signatures, :commit_sha
add_concurrent_index :gpg_signatures, :gpg_key_primary_keyid
end
def down
remove_concurrent_index :gpg_signatures, :commit_sha if index_exists?(:gpg_signatures, :commit_sha)
remove_concurrent_index :gpg_signatures, :gpg_key_primary_keyid if index_exists?(:gpg_signatures, :gpg_key_primary_keyid)
drop_table :gpg_signatures
end
end
......@@ -552,6 +552,21 @@ ActiveRecord::Schema.define(version: 20170725145659) do
add_index "gpg_keys", ["primary_keyid"], name: "index_gpg_keys_on_primary_keyid", using: :btree
add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree
create_table "gpg_signatures", force: :cascade do |t|
t.string "commit_sha"
t.integer "project_id"
t.integer "gpg_key_id"
t.string "gpg_key_primary_keyid"
t.boolean "valid_signature"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "gpg_signatures", ["commit_sha"], name: "index_gpg_signatures_on_commit_sha", using: :btree
add_index "gpg_signatures", ["gpg_key_id"], name: "index_gpg_signatures_on_gpg_key_id", using: :btree
add_index "gpg_signatures", ["gpg_key_primary_keyid"], name: "index_gpg_signatures_on_gpg_key_primary_keyid", using: :btree
add_index "gpg_signatures", ["project_id"], name: "index_gpg_signatures_on_project_id", using: :btree
create_table "identities", force: :cascade do |t|
t.string "extern_uid"
t.string "provider"
......@@ -1615,6 +1630,8 @@ ActiveRecord::Schema.define(version: 20170725145659) do
add_foreign_key "events", "projects", name: "fk_0434b48643", on_delete: :cascade
add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade
add_foreign_key "gpg_keys", "users"
add_foreign_key "gpg_signatures", "gpg_keys"
add_foreign_key "gpg_signatures", "projects"
add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade
add_foreign_key "issue_assignees", "users", name: "fk_5e0c8d9154", on_delete: :cascade
add_foreign_key "issue_metrics", "issues", on_delete: :cascade
......
require 'rails_helper'
RSpec.describe GpgSignature do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:gpg_key) }
end
describe 'validation' do
subject { described_class.new }
it { is_expected.to validate_presence_of(:commit_sha) }
it { is_expected.to validate_presence_of(:project) }
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