debian-mirror-gitlab/spec/services/packages/debian/generate_distribution_key_service_spec.rb

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

24 lines
875 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Packages::Debian::GenerateDistributionKeyService do
let(:params) { {} }
2021-10-27 15:23:28 +05:30
subject { described_class.new(params: params) }
2021-06-08 01:23:25 +05:30
let(:response) { subject.execute }
2021-10-27 15:23:28 +05:30
it 'returns an Hash', :aggregate_failures do
expect(GPGME::Ctx).to receive(:new).with(armor: true, offline: true).and_call_original
expect(User).to receive(:random_password).with(no_args).and_call_original
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
expect(response).to be_a Hash
expect(response.keys).to contain_exactly(:private_key, :public_key, :fingerprint, :passphrase)
expect(response[:private_key]).to start_with('-----BEGIN PGP PRIVATE KEY BLOCK-----')
expect(response[:public_key]).to start_with('-----BEGIN PGP PUBLIC KEY BLOCK-----')
expect(response[:fingerprint].length).to eq(40)
expect(response[:passphrase].length).to be > 10
2021-06-08 01:23:25 +05:30
end
end