debian-mirror-gitlab/spec/requests/jira_connect/public_keys_controller_spec.rb

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

57 lines
1.6 KiB
Ruby
Raw Normal View History

2022-11-25 23:54:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe JiraConnect::PublicKeysController, feature_category: :integrations do
2022-11-25 23:54:43 +05:30
describe 'GET /-/jira_connect/public_keys/:uuid' do
2023-03-04 22:38:38 +05:30
let(:uuid) { non_existing_record_id }
2023-04-23 21:23:45 +05:30
let(:public_key_storage_enabled_config) { true }
2023-03-04 22:38:38 +05:30
2022-11-25 23:54:43 +05:30
before do
2023-04-23 21:23:45 +05:30
allow(Gitlab.config.jira_connect).to receive(:enable_public_keys_storage)
.and_return(public_key_storage_enabled_config)
2022-11-25 23:54:43 +05:30
end
it 'renders 404' do
get jira_connect_public_key_path(id: uuid)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when public key exists' do
let_it_be(:public_key) { JiraConnect::PublicKey.create!(key: OpenSSL::PKey::RSA.generate(3072).public_key) }
let(:uuid) { public_key.uuid }
it 'renders 200' do
get jira_connect_public_key_path(id: uuid)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(public_key.key)
end
2023-04-23 21:23:45 +05:30
context 'when public key storage config disabled' do
let(:public_key_storage_enabled_config) { false }
2022-11-25 23:54:43 +05:30
it 'renders 404' do
get jira_connect_public_key_path(id: uuid)
expect(response).to have_gitlab_http_status(:not_found)
end
2023-04-23 21:23:45 +05:30
context 'when public key storage setting is enabled' do
before do
stub_application_setting(jira_connect_public_key_storage_enabled: true)
end
2022-11-25 23:54:43 +05:30
2023-04-23 21:23:45 +05:30
it 'renders 404' do
get jira_connect_public_key_path(id: uuid)
2022-11-25 23:54:43 +05:30
2023-04-23 21:23:45 +05:30
expect(response).to have_gitlab_http_status(:ok)
end
2022-11-25 23:54:43 +05:30
end
end
end
end
end