Project

General

Profile

« Previous | Next » 

Revision 59e7136a

Added by Shlomi Zadok over 7 years ago

Fixes #17015 - Adds Key pairs controller

View differences:

test/models/compute_resources/ec2_test.rb
assert_find_by_uuid_raises(ActiveRecord::RecordNotFound, cr)
end
it "raises RecordNotFound when the compute raises rackspace error" do
it "raises RecordNotFound when the compute raises EC2 error" do
cr = mock_cr_servers(Foreman::Model::EC2.new, servers_raising_exception(Fog::Compute::AWS::Error))
assert_find_by_uuid_raises(ActiveRecord::RecordNotFound, cr)
end
end
context "key pairs" do
setup do
@aws_key_pairs = []
3.times do |i|
@aws_key_pairs << AWSKeyPair.new("foreman-#{i}", "13:01:73:0#{i}")
end
end
test "#get_compute_key_pairs" do
cr = FactoryGirl.build(:ec2_cr)
key_pair = FactoryGirl.build(:key_pair)
cr.key_pair = key_pair
Foreman::Model::EC2.any_instance.stubs(:key_pairs).returns(@aws_key_pairs)
assert_kind_of(ComputeResourceKeyPair, cr.get_compute_key_pairs.first)
end
test "should be capable of key_pair" do
cr = FactoryGirl.create(:ec2_cr)
assert_includes(cr.capabilities, :key_pair)
end
end
end
# We can't use 'Fog::Compute::AWS::KeyPair' model
# This class mocks it.
class AWSKeyPair
attr_reader :name, :fingerprint, :private_key
def initialize(name, fingerprint, private_key = nil)
@name = name
@fingerprint = fingerprint
@private_key = private_key
end
end

Also available in: Unified diff