[CodeSign] Improve cert finding by only checking codesign identities.

Also move the logic out into a separate util module.

Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-399.
This commit is contained in:
Eloy Durán
2014-02-27 13:56:58 +01:00
parent 9183b059fc
commit 0b2a392f98
12 changed files with 218 additions and 10 deletions

View File

@@ -0,0 +1,49 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'motion/project/xcode_config'
require 'tempfile'
module Motion; module Project
describe XcodeConfig do
describe "concerning codesign certificates" do
before do
Util::CodeSign.stubs(:identity_names).with(false).returns([
'iPhone Developer: Eloy Duran (K5B8YH2WD5)',
'Mac Developer Self-Signed for Eloy Durán',
'Mac Developer: Eloy Duran (K5B8YH2WD5)',
])
App.stubs(:warn)
@config = XcodeConfig.new(Dir.tmpdir, :development)
end
it "selects an identity meant for codesigning iPhone apps" do
@config.codesign_certificate('iPhone').should == 'iPhone Developer: Eloy Duran (K5B8YH2WD5)'
end
it "selects an identity meant for codesigning Mac apps" do
@config.codesign_certificate('Mac').should == 'Mac Developer Self-Signed for Eloy Durán'
end
it "warns when there are multiple matching identities" do
App.expects(:warn)
@config.codesign_certificate('Mac')
end
it "fails when there no identities could be found" do
App.expects(:fail)
@config.codesign_certificate('Android')
end
it "limits identities to valid ones in release mode" do
Util::CodeSign.stubs(:identity_names).with(true).returns([
'iPhone Developer: Eloy Duran (K5B8YH2WD5)',
'Mac Developer: Eloy Duran (K5B8YH2WD5)',
])
@config.instance_variable_set(:@build_mode, :release)
@config.codesign_certificate('Mac').should == 'Mac Developer: Eloy Duran (K5B8YH2WD5)'
end
end
end
end; end