diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
commit | 126b1dd75918c1b327568603a73e3930f0e88e30 (patch) | |
tree | 9f558dafa363f4f0118d504a50cd4461e2821cd1 /test/rubygems/test_gem_commands_cert_command.rb | |
parent | 6ae958679382361364aec4df7e5e309c5318afd3 (diff) | |
download | ruby-126b1dd75918c1b327568603a73e3930f0e88e30.tar.gz |
Merge rubygems master.
This is RC version of Rubygems 2.7.0.
https://github.com/rubygems/rubygems/commit/688fb7e83c13c3fe7c2bb03c49a2db4c82852aee
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_cert_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_cert_command.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index a9a78336aa..2d38a57bc4 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -130,6 +130,70 @@ Added '/CN=alternate/DC=example' assert_path_exists File.join(@tempdir, 'gem-public_cert.pem') end + def test_execute_build_bad_email_address + passphrase = 'Foo bar' + email = "nobody@" + + @cmd.handle_options %W[--build #{email}] + + @build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}" + + use_ui @build_ui do + + e = assert_raises Gem::CommandLineError do + @cmd.execute + end + + assert_equal "Invalid email address #{email}", + e.message + + refute_path_exists File.join(@tempdir, 'gem-private_key.pem') + refute_path_exists File.join(@tempdir, 'gem-public_cert.pem') + end + end + + def test_execute_build_expiration_days + passphrase = 'Foo bar' + + @cmd.handle_options %W[ + --build nobody@example.com + --days 26 + ] + + @build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}" + + use_ui @build_ui do + @cmd.execute + end + + output = @build_ui.output.squeeze("\n").split "\n" + + assert_equal "Passphrase for your Private Key: ", + output.shift + assert_equal "Please repeat the passphrase for your Private Key: ", + output.shift + assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}", + output.shift + assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}", + output.shift + + assert_equal "Don't forget to move the key file to somewhere private!", + output.shift + + assert_empty output + assert_empty @build_ui.error + + assert_path_exists File.join(@tempdir, 'gem-private_key.pem') + assert_path_exists File.join(@tempdir, 'gem-public_cert.pem') + + pem = File.read("#{@tempdir}/gem-public_cert.pem") + cert = OpenSSL::X509::Certificate.new(pem) + + test = (cert.not_after - cert.not_before).to_i / (24 * 60 * 60) + assert_equal(test, 26) + + end + def test_execute_build_bad_passphrase_confirmation passphrase = 'Foo bar' passphrase_confirmation = 'Fu bar' |