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
|
|
|
|
post :create, params: { key: build(:key, expires_at: expires_at).attributes }
|
|
|
|
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
|
|
|
|
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
|