debian-mirror-gitlab/spec/controllers/profiles/keys_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Profiles::KeysController do
2016-06-02 11:05:42 +05:30
let(:user) { create(:user) }
2020-04-08 14:13:33 +05:30
describe 'POST #create' do
before do
sign_in(user)
end
it 'creates a new key' do
expires_at = 3.days.from_now
expect do
2023-03-04 22:38:38 +05:30
post :create, params: { key: build(:key, usage_type: :signing, expires_at: expires_at).attributes }
2020-04-08 14:13:33 +05:30
end.to change { Key.count }.by(1)
2022-06-21 17:19:12 +05:30
key = Key.last
expect(key.expires_at).to be_like_time(expires_at)
expect(key.fingerprint_md5).to be_present
expect(key.fingerprint_sha256).to be_present
2023-03-04 22:38:38 +05:30
expect(key.usage_type).to eq('signing')
2022-06-21 17:19:12 +05:30
end
context 'with FIPS mode', :fips_mode do
it 'creates a new key without MD5 fingerprint' do
expires_at = 3.days.from_now
expect do
post :create, params: { key: build(:rsa_key_4096, expires_at: expires_at).attributes }
end.to change { Key.count }.by(1)
key = Key.last
expect(key.expires_at).to be_like_time(expires_at)
expect(key.fingerprint_md5).to be_nil
expect(key.fingerprint_sha256).to be_present
end
2020-04-08 14:13:33 +05:30
end
end
2014-09-02 18:07:02 +05:30
end