rubygems-update 2.7.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -0
- data/.travis.yml +22 -18
- data/CONTRIBUTING.md +141 -0
- data/History.txt +289 -19
- data/MAINTAINERS.txt +1 -0
- data/Manifest.txt +16 -11
- data/POLICIES.md +92 -0
- data/README.md +47 -26
- data/Rakefile +47 -207
- data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
- data/appveyor.yml +20 -45
- data/bin/gem +1 -2
- data/bin/update_rubygems +2 -3
- data/bundler/CHANGELOG.md +54 -0
- data/bundler/bundler.gemspec +7 -1
- data/bundler/lib/bundler.rb +26 -8
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli.rb +63 -21
- data/bundler/lib/bundler/cli/add.rb +15 -5
- data/bundler/lib/bundler/cli/binstubs.rb +8 -2
- data/bundler/lib/bundler/cli/doctor.rb +47 -1
- data/bundler/lib/bundler/cli/install.rb +8 -5
- data/bundler/lib/bundler/cli/list.rb +41 -5
- data/bundler/lib/bundler/cli/outdated.rb +7 -1
- data/bundler/lib/bundler/cli/pristine.rb +4 -0
- data/bundler/lib/bundler/cli/remove.rb +18 -0
- data/bundler/lib/bundler/definition.rb +15 -16
- data/bundler/lib/bundler/dependency.rb +2 -2
- data/bundler/lib/bundler/dsl.rb +19 -3
- data/bundler/lib/bundler/feature_flag.rb +7 -0
- data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
- data/bundler/lib/bundler/injector.rb +168 -9
- data/bundler/lib/bundler/installer.rb +29 -6
- data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
- data/bundler/lib/bundler/plugin.rb +10 -3
- data/bundler/lib/bundler/plugin/events.rb +61 -0
- data/bundler/lib/bundler/resolver.rb +2 -2
- data/bundler/lib/bundler/runtime.rb +8 -2
- data/bundler/lib/bundler/settings.rb +24 -3
- data/bundler/lib/bundler/settings/validator.rb +23 -0
- data/bundler/lib/bundler/shared_helpers.rb +19 -3
- data/bundler/lib/bundler/source.rb +9 -9
- data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/man/bundle-add.ronn +13 -2
- data/bundler/man/bundle-config.ronn +21 -0
- data/bundler/man/bundle-install.ronn +1 -1
- data/bundler/man/bundle-list.ronn +19 -1
- data/bundler/man/bundle-outdated.ronn +4 -0
- data/bundler/man/bundle-remove.ronn +23 -0
- data/bundler/man/bundle-update.ronn +1 -1
- data/lib/rubygems.rb +70 -96
- data/lib/rubygems/available_set.rb +1 -1
- data/lib/rubygems/basic_specification.rb +12 -12
- data/lib/rubygems/bundler_version_finder.rb +3 -3
- data/lib/rubygems/command.rb +22 -15
- data/lib/rubygems/command_manager.rb +20 -11
- data/lib/rubygems/commands/build_command.rb +27 -8
- data/lib/rubygems/commands/cert_command.rb +45 -24
- data/lib/rubygems/commands/check_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +14 -7
- data/lib/rubygems/commands/contents_command.rb +14 -15
- data/lib/rubygems/commands/dependency_command.rb +17 -17
- data/lib/rubygems/commands/environment_command.rb +20 -1
- data/lib/rubygems/commands/fetch_command.rb +2 -3
- data/lib/rubygems/commands/generate_index_command.rb +2 -3
- data/lib/rubygems/commands/help_command.rb +12 -13
- data/lib/rubygems/commands/info_command.rb +33 -0
- data/lib/rubygems/commands/install_command.rb +21 -17
- data/lib/rubygems/commands/list_command.rb +0 -1
- data/lib/rubygems/commands/lock_command.rb +3 -4
- data/lib/rubygems/commands/open_command.rb +16 -10
- data/lib/rubygems/commands/owner_command.rb +20 -11
- data/lib/rubygems/commands/pristine_command.rb +23 -16
- data/lib/rubygems/commands/push_command.rb +17 -8
- data/lib/rubygems/commands/query_command.rb +24 -24
- data/lib/rubygems/commands/rdoc_command.rb +3 -4
- data/lib/rubygems/commands/search_command.rb +0 -1
- data/lib/rubygems/commands/server_command.rb +1 -2
- data/lib/rubygems/commands/setup_command.rb +78 -38
- data/lib/rubygems/commands/signin_command.rb +2 -1
- data/lib/rubygems/commands/signout_command.rb +2 -2
- data/lib/rubygems/commands/sources_command.rb +11 -12
- data/lib/rubygems/commands/specification_command.rb +7 -7
- data/lib/rubygems/commands/uninstall_command.rb +41 -19
- data/lib/rubygems/commands/unpack_command.rb +16 -7
- data/lib/rubygems/commands/update_command.rb +28 -23
- data/lib/rubygems/commands/which_command.rb +4 -5
- data/lib/rubygems/commands/yank_command.rb +1 -2
- data/lib/rubygems/compatibility.rb +1 -21
- data/lib/rubygems/config_file.rb +36 -36
- data/lib/rubygems/core_ext/kernel_require.rb +6 -6
- data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
- data/lib/rubygems/defaults.rb +31 -12
- data/lib/rubygems/dependency.rb +14 -14
- data/lib/rubygems/dependency_installer.rb +29 -31
- data/lib/rubygems/dependency_list.rb +8 -9
- data/lib/rubygems/deprecate.rb +2 -3
- data/lib/rubygems/doctor.rb +5 -6
- data/lib/rubygems/errors.rb +3 -3
- data/lib/rubygems/exceptions.rb +11 -4
- data/lib/rubygems/ext.rb +0 -1
- data/lib/rubygems/ext/build_error.rb +0 -1
- data/lib/rubygems/ext/builder.rb +50 -23
- data/lib/rubygems/ext/cmake_builder.rb +2 -2
- data/lib/rubygems/ext/configure_builder.rb +2 -3
- data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
- data/lib/rubygems/ext/rake_builder.rb +16 -18
- data/lib/rubygems/gem_runner.rb +2 -2
- data/lib/rubygems/gemcutter_utilities.rb +40 -13
- data/lib/rubygems/indexer.rb +19 -12
- data/lib/rubygems/install_default_message.rb +0 -1
- data/lib/rubygems/install_message.rb +0 -1
- data/lib/rubygems/install_update_options.rb +2 -28
- data/lib/rubygems/installer.rb +95 -75
- data/lib/rubygems/installer_test_case.rb +0 -14
- data/lib/rubygems/local_remote_options.rb +5 -4
- data/lib/rubygems/mock_gem_ui.rb +3 -4
- data/lib/rubygems/name_tuple.rb +4 -4
- data/lib/rubygems/package.rb +90 -73
- data/lib/rubygems/package/digest_io.rb +3 -4
- data/lib/rubygems/package/file_source.rb +3 -4
- data/lib/rubygems/package/io_source.rb +1 -2
- data/lib/rubygems/package/old.rb +8 -16
- data/lib/rubygems/package/source.rb +0 -1
- data/lib/rubygems/package/tar_header.rb +2 -2
- data/lib/rubygems/package/tar_reader.rb +2 -4
- data/lib/rubygems/package/tar_reader/entry.rb +20 -4
- data/lib/rubygems/package/tar_test_case.rb +2 -8
- data/lib/rubygems/package/tar_writer.rb +13 -15
- data/lib/rubygems/package_task.rb +0 -1
- data/lib/rubygems/path_support.rb +16 -6
- data/lib/rubygems/platform.rb +4 -5
- data/lib/rubygems/psych_tree.rb +1 -1
- data/lib/rubygems/rdoc.rb +0 -311
- data/lib/rubygems/remote_fetcher.rb +34 -48
- data/lib/rubygems/request.rb +16 -15
- data/lib/rubygems/request/connection_pools.rb +24 -13
- data/lib/rubygems/request/http_pool.rb +3 -4
- data/lib/rubygems/request/https_pool.rb +1 -3
- data/lib/rubygems/request_set.rb +52 -25
- data/lib/rubygems/request_set/gem_dependency_api.rb +36 -40
- data/lib/rubygems/request_set/lockfile.rb +12 -12
- data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
- data/lib/rubygems/requirement.rb +16 -16
- data/lib/rubygems/resolver.rb +10 -15
- data/lib/rubygems/resolver/activation_request.rb +6 -6
- data/lib/rubygems/resolver/api_set.rb +5 -6
- data/lib/rubygems/resolver/api_specification.rb +2 -3
- data/lib/rubygems/resolver/best_set.rb +5 -6
- data/lib/rubygems/resolver/composed_set.rb +5 -6
- data/lib/rubygems/resolver/conflict.rb +5 -5
- data/lib/rubygems/resolver/current_set.rb +1 -2
- data/lib/rubygems/resolver/dependency_request.rb +4 -4
- data/lib/rubygems/resolver/git_set.rb +5 -6
- data/lib/rubygems/resolver/git_specification.rb +4 -5
- data/lib/rubygems/resolver/index_set.rb +5 -6
- data/lib/rubygems/resolver/index_specification.rb +3 -4
- data/lib/rubygems/resolver/installed_specification.rb +3 -4
- data/lib/rubygems/resolver/installer_set.rb +12 -12
- data/lib/rubygems/resolver/local_specification.rb +1 -2
- data/lib/rubygems/resolver/lock_set.rb +5 -6
- data/lib/rubygems/resolver/lock_specification.rb +7 -8
- data/lib/rubygems/resolver/requirement_list.rb +1 -1
- data/lib/rubygems/resolver/set.rb +2 -2
- data/lib/rubygems/resolver/source_set.rb +4 -5
- data/lib/rubygems/resolver/spec_specification.rb +1 -2
- data/lib/rubygems/resolver/specification.rb +10 -7
- data/lib/rubygems/resolver/stats.rb +1 -1
- data/lib/rubygems/resolver/vendor_set.rb +4 -5
- data/lib/rubygems/resolver/vendor_specification.rb +2 -3
- data/lib/rubygems/safe_yaml.rb +18 -10
- data/lib/rubygems/security.rb +21 -22
- data/lib/rubygems/security/policies.rb +1 -2
- data/lib/rubygems/security/policy.rb +25 -25
- data/lib/rubygems/security/signer.rb +72 -24
- data/lib/rubygems/security/trust_dir.rb +10 -10
- data/lib/rubygems/server.rb +21 -21
- data/lib/rubygems/source.rb +16 -25
- data/lib/rubygems/source/git.rb +9 -10
- data/lib/rubygems/source/installed.rb +3 -4
- data/lib/rubygems/source/local.rb +7 -7
- data/lib/rubygems/source/lock.rb +4 -4
- data/lib/rubygems/source/specific_file.rb +5 -5
- data/lib/rubygems/source/vendor.rb +2 -3
- data/lib/rubygems/source_list.rb +2 -2
- data/lib/rubygems/source_local.rb +0 -1
- data/lib/rubygems/spec_fetcher.rb +5 -6
- data/lib/rubygems/specification.rb +199 -536
- data/lib/rubygems/specification_policy.rb +407 -0
- data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/rubygems/stub_specification.rb +11 -15
- data/lib/rubygems/test_case.rb +141 -66
- data/lib/rubygems/test_utilities.rb +20 -35
- data/lib/rubygems/text.rb +6 -6
- data/lib/rubygems/uninstaller.rb +37 -26
- data/lib/rubygems/uri_formatter.rb +1 -2
- data/lib/rubygems/user_interaction.rb +38 -93
- data/lib/rubygems/util.rb +20 -14
- data/lib/rubygems/util/licenses.rb +27 -1
- data/lib/rubygems/util/list.rb +1 -1
- data/lib/rubygems/validator.rb +4 -5
- data/lib/rubygems/version.rb +15 -15
- data/lib/rubygems/version_option.rb +2 -3
- data/rubygems-update.gemspec +43 -0
- data/setup.rb +2 -8
- data/test/rubygems/rubygems_plugin.rb +0 -1
- data/test/rubygems/simple_gem.rb +1 -1
- data/test/rubygems/test_bundled_ca.rb +4 -7
- data/test/rubygems/test_config.rb +7 -2
- data/test/rubygems/test_gem.rb +161 -130
- data/test/rubygems/test_gem_command.rb +0 -1
- data/test/rubygems/test_gem_command_manager.rb +8 -3
- data/test/rubygems/test_gem_commands_build_command.rb +219 -15
- data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
- data/test/rubygems/test_gem_commands_check_command.rb +1 -1
- data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
- data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
- data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
- data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
- data/test/rubygems/test_gem_commands_help_command.rb +7 -4
- data/test/rubygems/test_gem_commands_info_command.rb +44 -0
- data/test/rubygems/test_gem_commands_install_command.rb +79 -12
- data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
- data/test/rubygems/test_gem_commands_open_command.rb +29 -0
- data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
- data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
- data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
- data/test/rubygems/test_gem_commands_push_command.rb +39 -0
- data/test/rubygems/test_gem_commands_query_command.rb +102 -100
- data/test/rubygems/test_gem_commands_search_command.rb +0 -1
- data/test/rubygems/test_gem_commands_server_command.rb +0 -1
- data/test/rubygems/test_gem_commands_setup_command.rb +39 -8
- data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
- data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
- data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
- data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +81 -7
- data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
- data/test/rubygems/test_gem_commands_update_command.rb +19 -2
- data/test/rubygems/test_gem_commands_which_command.rb +0 -1
- data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
- data/test/rubygems/test_gem_config_file.rb +4 -2
- data/test/rubygems/test_gem_dependency.rb +0 -1
- data/test/rubygems/test_gem_dependency_installer.rb +8 -5
- data/test/rubygems/test_gem_dependency_list.rb +6 -7
- data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
- data/test/rubygems/test_gem_doctor.rb +1 -2
- data/test/rubygems/test_gem_ext_builder.rb +10 -23
- data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
- data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
- data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
- data/test/rubygems/test_gem_gem_runner.rb +0 -1
- data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
- data/test/rubygems/test_gem_indexer.rb +1 -2
- data/test/rubygems/test_gem_install_update_options.rb +1 -20
- data/test/rubygems/test_gem_installer.rb +69 -203
- data/test/rubygems/test_gem_local_remote_options.rb +3 -3
- data/test/rubygems/test_gem_name_tuple.rb +0 -1
- data/test/rubygems/test_gem_package.rb +59 -50
- data/test/rubygems/test_gem_package_old.rb +0 -1
- data/test/rubygems/test_gem_package_tar_header.rb +1 -2
- data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +40 -7
- data/test/rubygems/test_gem_package_task.rb +2 -2
- data/test/rubygems/test_gem_path_support.rb +28 -11
- data/test/rubygems/test_gem_platform.rb +4 -5
- data/test/rubygems/test_gem_rdoc.rb +1 -2
- data/test/rubygems/test_gem_remote_fetcher.rb +111 -130
- data/test/rubygems/test_gem_request.rb +5 -5
- data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
- data/test/rubygems/test_gem_request_set.rb +5 -5
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +2 -7
- data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
- data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
- data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
- data/test/rubygems/test_gem_requirement.rb +18 -4
- data/test/rubygems/test_gem_resolver.rb +13 -17
- data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
- data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
- data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
- data/test/rubygems/test_gem_resolver_specification.rb +1 -2
- data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
- data/test/rubygems/test_gem_security.rb +1 -3
- data/test/rubygems/test_gem_security_policy.rb +4 -5
- data/test/rubygems/test_gem_security_signer.rb +4 -3
- data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
- data/test/rubygems/test_gem_server.rb +4 -4
- data/test/rubygems/test_gem_source.rb +0 -13
- data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
- data/test/rubygems/test_gem_source_git.rb +0 -1
- data/test/rubygems/test_gem_source_installed.rb +0 -1
- data/test/rubygems/test_gem_source_lock.rb +0 -1
- data/test/rubygems/test_gem_source_vendor.rb +0 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
- data/test/rubygems/test_gem_specification.rb +334 -198
- data/test/rubygems/test_gem_stream_ui.rb +13 -30
- data/test/rubygems/test_gem_stub_specification.rb +0 -2
- data/test/rubygems/test_gem_text.rb +4 -5
- data/test/rubygems/test_gem_uninstaller.rb +21 -1
- data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
- data/test/rubygems/test_gem_uri_formatter.rb +0 -1
- data/test/rubygems/test_gem_util.rb +6 -11
- data/test/rubygems/test_gem_validator.rb +0 -1
- data/test/rubygems/test_gem_version.rb +11 -11
- data/test/rubygems/test_gem_version_option.rb +0 -1
- data/test/rubygems/test_remote_fetch_error.rb +0 -1
- data/test/rubygems/test_require.rb +67 -52
- data/util/CL2notes +1 -2
- data/util/ci +15 -12
- data/util/create_certs.rb +6 -7
- data/util/create_encrypted_key.rb +0 -1
- data/util/patch_with_prs.rb +1 -1
- data/util/rubocop +8 -0
- data/util/update_bundled_ca_certificates.rb +15 -14
- data/util/update_changelog.rb +1 -1
- metadata +67 -59
- data/.autotest +0 -71
- data/.document +0 -5
- data/CONTRIBUTING.rdoc +0 -130
- data/CVE-2013-4287.txt +0 -35
- data/CVE-2013-4363.txt +0 -45
- data/CVE-2015-3900.txt +0 -40
- data/POLICIES.rdoc +0 -74
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
- data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -68,4 +68,33 @@ class TestGemCommandsOpenCommand < Gem::TestCase
|
|
68
68
|
assert_equal "", @ui.error
|
69
69
|
end
|
70
70
|
|
71
|
+
def test_default_gem
|
72
|
+
@cmd.options[:version] = "1.0"
|
73
|
+
@cmd.options[:args] = %w[foo]
|
74
|
+
|
75
|
+
version = @cmd.options[:version]
|
76
|
+
@cmd.define_singleton_method(:spec_for) do |name|
|
77
|
+
spec = Gem::Specification.find_all_by_name(name, version).first
|
78
|
+
|
79
|
+
spec.define_singleton_method(:default_gem?) do
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
return spec if spec
|
84
|
+
|
85
|
+
say "Unable to find gem '#{name}'"
|
86
|
+
end
|
87
|
+
|
88
|
+
gem("foo", "1.0")
|
89
|
+
|
90
|
+
assert_raises Gem::MockGemUi::TermError do
|
91
|
+
use_ui @ui do
|
92
|
+
@cmd.execute
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
assert_match %r|'foo' is a default gem and can't be opened\.| , @ui.output
|
97
|
+
assert_equal "", @ui.error
|
98
|
+
end
|
99
|
+
|
71
100
|
end
|
@@ -8,8 +8,10 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
|
|
8
8
|
super
|
9
9
|
|
10
10
|
ENV["RUBYGEMS_HOST"] = nil
|
11
|
-
@
|
12
|
-
Gem::
|
11
|
+
@stub_ui = Gem::MockGemUi.new
|
12
|
+
@stub_fetcher = Gem::FakeFetcher.new
|
13
|
+
Gem::RemoteFetcher.fetcher = @stub_fetcher
|
14
|
+
Gem.configuration = nil
|
13
15
|
Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
|
14
16
|
|
15
17
|
@cmd = Gem::Commands::OwnerCommand.new
|
@@ -27,20 +29,20 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
|
|
27
29
|
- id: 4
|
28
30
|
EOF
|
29
31
|
|
30
|
-
@
|
32
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
|
31
33
|
|
32
|
-
use_ui @
|
34
|
+
use_ui @stub_ui do
|
33
35
|
@cmd.show_owners("freewill")
|
34
36
|
end
|
35
37
|
|
36
|
-
assert_equal Net::HTTP::Get, @
|
37
|
-
assert_equal Gem.configuration.rubygems_api_key, @
|
38
|
+
assert_equal Net::HTTP::Get, @stub_fetcher.last_request.class
|
39
|
+
assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
|
38
40
|
|
39
|
-
assert_match %r{Owners for gem: freewill}, @
|
40
|
-
assert_match %r{- user1@example.com}, @
|
41
|
-
assert_match %r{- user2@example.com}, @
|
42
|
-
assert_match %r{- user3}, @
|
43
|
-
assert_match %r{- 4}, @
|
41
|
+
assert_match %r{Owners for gem: freewill}, @stub_ui.output
|
42
|
+
assert_match %r{- user1@example.com}, @stub_ui.output
|
43
|
+
assert_match %r{- user2@example.com}, @stub_ui.output
|
44
|
+
assert_match %r{- user3}, @stub_ui.output
|
45
|
+
assert_match %r{- 4}, @stub_ui.output
|
44
46
|
end
|
45
47
|
|
46
48
|
def test_show_owners_dont_load_objects
|
@@ -57,14 +59,13 @@ EOF
|
|
57
59
|
- id: 4
|
58
60
|
EOF
|
59
61
|
|
60
|
-
@
|
62
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
|
61
63
|
|
62
64
|
assert_raises Psych::DisallowedClass do
|
63
65
|
use_ui @ui do
|
64
66
|
@cmd.show_owners("freewill")
|
65
67
|
end
|
66
68
|
end
|
67
|
-
|
68
69
|
end
|
69
70
|
|
70
71
|
|
@@ -73,14 +74,14 @@ EOF
|
|
73
74
|
host = "http://rubygems.example"
|
74
75
|
ENV["RUBYGEMS_HOST"] = host
|
75
76
|
|
76
|
-
@
|
77
|
+
@stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
|
77
78
|
|
78
|
-
use_ui @
|
79
|
+
use_ui @stub_ui do
|
79
80
|
@cmd.show_owners("freewill")
|
80
81
|
end
|
81
82
|
|
82
|
-
assert_match %r{Owners for gem: freewill}, @
|
83
|
-
assert_match %r{- user1@example.com}, @
|
83
|
+
assert_match %r{Owners for gem: freewill}, @stub_ui.output
|
84
|
+
assert_match %r{- user1@example.com}, @stub_ui.output
|
84
85
|
end
|
85
86
|
|
86
87
|
def test_show_owners_setting_up_host
|
@@ -88,32 +89,32 @@ EOF
|
|
88
89
|
host = "http://rubygems.example"
|
89
90
|
@cmd.host = host
|
90
91
|
|
91
|
-
@
|
92
|
+
@stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
|
92
93
|
|
93
|
-
use_ui @
|
94
|
+
use_ui @stub_ui do
|
94
95
|
@cmd.show_owners("freewill")
|
95
96
|
end
|
96
97
|
|
97
|
-
assert_match %r{Owners for gem: freewill}, @
|
98
|
-
assert_match %r{- user1@example.com}, @
|
98
|
+
assert_match %r{Owners for gem: freewill}, @stub_ui.output
|
99
|
+
assert_match %r{- user1@example.com}, @stub_ui.output
|
99
100
|
end
|
100
101
|
|
101
102
|
def test_show_owners_denied
|
102
103
|
response = "You don't have permission to push to this gem"
|
103
|
-
@
|
104
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
|
104
105
|
|
105
106
|
assert_raises Gem::MockGemUi::TermError do
|
106
|
-
use_ui @
|
107
|
+
use_ui @stub_ui do
|
107
108
|
@cmd.show_owners("freewill")
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
|
-
assert_match response, @
|
112
|
+
assert_match response, @stub_ui.output
|
112
113
|
end
|
113
114
|
|
114
115
|
def test_show_owners_key
|
115
116
|
response = "- email: user1@example.com\n"
|
116
|
-
@
|
117
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
|
117
118
|
File.open Gem.configuration.credentials_path, 'a' do |f|
|
118
119
|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
|
119
120
|
end
|
@@ -122,56 +123,56 @@ EOF
|
|
122
123
|
@cmd.handle_options %w(-k other)
|
123
124
|
@cmd.show_owners('freewill')
|
124
125
|
|
125
|
-
assert_equal '701229f217cdf23b1344c7b4b54ca97', @
|
126
|
+
assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
|
126
127
|
end
|
127
128
|
|
128
129
|
def test_add_owners
|
129
130
|
response = "Owner added successfully."
|
130
|
-
@
|
131
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
|
131
132
|
|
132
|
-
use_ui @
|
133
|
+
use_ui @stub_ui do
|
133
134
|
@cmd.add_owners("freewill", ["user-new1@example.com"])
|
134
135
|
end
|
135
136
|
|
136
|
-
assert_equal Net::HTTP::Post, @
|
137
|
-
assert_equal Gem.configuration.rubygems_api_key, @
|
138
|
-
assert_equal "email=user-new1%40example.com", @
|
137
|
+
assert_equal Net::HTTP::Post, @stub_fetcher.last_request.class
|
138
|
+
assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
|
139
|
+
assert_equal "email=user-new1%40example.com", @stub_fetcher.last_request.body
|
139
140
|
|
140
|
-
assert_match response, @
|
141
|
+
assert_match response, @stub_ui.output
|
141
142
|
end
|
142
143
|
|
143
144
|
def test_add_owners_denied
|
144
145
|
response = "You don't have permission to push to this gem"
|
145
|
-
@
|
146
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
|
146
147
|
|
147
|
-
use_ui @
|
148
|
+
use_ui @stub_ui do
|
148
149
|
@cmd.add_owners("freewill", ["user-new1@example.com"])
|
149
150
|
end
|
150
151
|
|
151
|
-
assert_match response, @
|
152
|
+
assert_match response, @stub_ui.output
|
152
153
|
end
|
153
154
|
|
154
155
|
def test_add_owner_with_host_option_through_execute
|
155
156
|
host = "http://rubygems.example"
|
156
157
|
add_owner_response = "Owner added successfully."
|
157
158
|
show_owners_response = "- email: user1@example.com\n"
|
158
|
-
@
|
159
|
-
@
|
159
|
+
@stub_fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
|
160
|
+
@stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
|
160
161
|
|
161
162
|
@cmd.handle_options %W[--host #{host} --add user-new1@example.com freewill]
|
162
163
|
|
163
|
-
use_ui @
|
164
|
+
use_ui @stub_ui do
|
164
165
|
@cmd.execute
|
165
166
|
end
|
166
167
|
|
167
|
-
assert_match add_owner_response, @
|
168
|
-
assert_match %r{Owners for gem: freewill}, @
|
169
|
-
assert_match %r{- user1@example.com}, @
|
168
|
+
assert_match add_owner_response, @stub_ui.output
|
169
|
+
assert_match %r{Owners for gem: freewill}, @stub_ui.output
|
170
|
+
assert_match %r{- user1@example.com}, @stub_ui.output
|
170
171
|
end
|
171
172
|
|
172
173
|
def test_add_owners_key
|
173
174
|
response = "Owner added successfully."
|
174
|
-
@
|
175
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
|
175
176
|
File.open Gem.configuration.credentials_path, 'a' do |f|
|
176
177
|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
|
177
178
|
end
|
@@ -180,38 +181,38 @@ EOF
|
|
180
181
|
@cmd.handle_options %w(-k other)
|
181
182
|
@cmd.add_owners('freewill', ['user-new1@example.com'])
|
182
183
|
|
183
|
-
assert_equal '701229f217cdf23b1344c7b4b54ca97', @
|
184
|
+
assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
|
184
185
|
end
|
185
186
|
|
186
187
|
def test_remove_owners
|
187
188
|
response = "Owner removed successfully."
|
188
|
-
@
|
189
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
|
189
190
|
|
190
|
-
use_ui @
|
191
|
+
use_ui @stub_ui do
|
191
192
|
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
|
192
193
|
end
|
193
194
|
|
194
|
-
assert_equal Net::HTTP::Delete, @
|
195
|
-
assert_equal Gem.configuration.rubygems_api_key, @
|
196
|
-
assert_equal "email=user-remove1%40example.com", @
|
195
|
+
assert_equal Net::HTTP::Delete, @stub_fetcher.last_request.class
|
196
|
+
assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
|
197
|
+
assert_equal "email=user-remove1%40example.com", @stub_fetcher.last_request.body
|
197
198
|
|
198
|
-
assert_match response, @
|
199
|
+
assert_match response, @stub_ui.output
|
199
200
|
end
|
200
201
|
|
201
202
|
def test_remove_owners_denied
|
202
203
|
response = "You don't have permission to push to this gem"
|
203
|
-
@
|
204
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
|
204
205
|
|
205
|
-
use_ui @
|
206
|
+
use_ui @stub_ui do
|
206
207
|
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
|
207
208
|
end
|
208
209
|
|
209
|
-
assert_match response, @
|
210
|
+
assert_match response, @stub_ui.output
|
210
211
|
end
|
211
212
|
|
212
213
|
def test_remove_owners_key
|
213
214
|
response = "Owner removed successfully."
|
214
|
-
@
|
215
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
|
215
216
|
File.open Gem.configuration.credentials_path, 'a' do |f|
|
216
217
|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
|
217
218
|
end
|
@@ -220,18 +221,53 @@ EOF
|
|
220
221
|
@cmd.handle_options %w(-k other)
|
221
222
|
@cmd.remove_owners('freewill', ['user-remove1@example.com'])
|
222
223
|
|
223
|
-
assert_equal '701229f217cdf23b1344c7b4b54ca97', @
|
224
|
+
assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
|
224
225
|
end
|
225
226
|
|
226
227
|
def test_remove_owners_missing
|
227
228
|
response = 'Owner could not be found.'
|
228
|
-
@
|
229
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
|
229
230
|
|
230
|
-
use_ui @
|
231
|
+
use_ui @stub_ui do
|
231
232
|
@cmd.remove_owners("freewill", ["missing@example"])
|
232
233
|
end
|
233
234
|
|
234
|
-
assert_equal "Removing missing@example: #{response}\n", @
|
235
|
+
assert_equal "Removing missing@example: #{response}\n", @stub_ui.output
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_otp_verified_success
|
239
|
+
response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
|
240
|
+
response_success = "Owner added successfully."
|
241
|
+
|
242
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = proc do
|
243
|
+
@call_count ||= 0
|
244
|
+
(@call_count += 1).odd? ? [response_fail, 401, 'Unauthorized'] : [response_success, 200, 'OK']
|
245
|
+
end
|
246
|
+
|
247
|
+
@otp_ui = Gem::MockGemUi.new "111111\n"
|
248
|
+
use_ui @otp_ui do
|
249
|
+
@cmd.add_owners("freewill", ["user-new1@example.com"])
|
250
|
+
end
|
251
|
+
|
252
|
+
assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
|
253
|
+
assert_match 'Code: ', @otp_ui.output
|
254
|
+
assert_match response_success, @otp_ui.output
|
255
|
+
assert_equal '111111', @stub_fetcher.last_request['OTP']
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_otp_verified_failure
|
259
|
+
response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
|
260
|
+
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 401, 'Unauthorized']
|
261
|
+
|
262
|
+
@otp_ui = Gem::MockGemUi.new "111111\n"
|
263
|
+
use_ui @otp_ui do
|
264
|
+
@cmd.add_owners("freewill", ["user-new1@example.com"])
|
265
|
+
end
|
266
|
+
|
267
|
+
assert_match response, @otp_ui.output
|
268
|
+
assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
|
269
|
+
assert_match 'Code: ', @otp_ui.output
|
270
|
+
assert_equal '111111', @stub_fetcher.last_request['OTP']
|
235
271
|
end
|
236
272
|
|
237
273
|
end
|
@@ -253,6 +253,31 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|
253
253
|
assert_empty out, out.inspect
|
254
254
|
end
|
255
255
|
|
256
|
+
def test_skip_many_gems
|
257
|
+
a = util_spec 'a'
|
258
|
+
b = util_spec 'b'
|
259
|
+
c = util_spec 'c'
|
260
|
+
|
261
|
+
install_gem a
|
262
|
+
install_gem b
|
263
|
+
install_gem c
|
264
|
+
|
265
|
+
@cmd.options[:args] = %w[a b c]
|
266
|
+
@cmd.options[:skip] = ['a', 'c']
|
267
|
+
|
268
|
+
use_ui @ui do
|
269
|
+
@cmd.execute
|
270
|
+
end
|
271
|
+
|
272
|
+
out = @ui.output.split "\n"
|
273
|
+
|
274
|
+
assert_equal "Restoring gems to pristine condition...", out.shift
|
275
|
+
assert_equal "Skipped #{a.full_name}, it was given through options", out.shift
|
276
|
+
assert_equal "Restored #{b.full_name}", out.shift
|
277
|
+
assert_equal "Skipped #{c.full_name}, it was given through options", out.shift
|
278
|
+
assert_empty out, out.inspect
|
279
|
+
end
|
280
|
+
|
256
281
|
def test_execute_many_multi_repo
|
257
282
|
a = util_spec 'a'
|
258
283
|
install_gem a
|
@@ -408,6 +433,39 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|
408
433
|
refute File.exist? gem_lib
|
409
434
|
end
|
410
435
|
|
436
|
+
def test_execute_bindir
|
437
|
+
a = util_spec 'a' do |s|
|
438
|
+
s.name = "test_gem"
|
439
|
+
s.executables = %w[foo]
|
440
|
+
s.files = %w[bin/foo]
|
441
|
+
end
|
442
|
+
|
443
|
+
write_file File.join(@tempdir, 'bin', 'foo') do |fp|
|
444
|
+
fp.puts "#!/usr/bin/ruby"
|
445
|
+
end
|
446
|
+
|
447
|
+
write_file File.join(@tempdir, 'test_bin', 'foo') do |fp|
|
448
|
+
fp.puts "#!/usr/bin/ruby"
|
449
|
+
end
|
450
|
+
|
451
|
+
install_gem a
|
452
|
+
|
453
|
+
gem_exec = File.join @gemhome, 'bin', 'foo'
|
454
|
+
gem_bindir = File.join @tempdir, 'test_bin', 'foo'
|
455
|
+
|
456
|
+
FileUtils.rm gem_exec
|
457
|
+
FileUtils.rm gem_bindir
|
458
|
+
|
459
|
+
@cmd.handle_options ["--all", "--only-executables", "--bindir", "#{gem_bindir}"]
|
460
|
+
|
461
|
+
use_ui @ui do
|
462
|
+
@cmd.execute
|
463
|
+
end
|
464
|
+
|
465
|
+
refute File.exist? gem_exec
|
466
|
+
assert File.exist? gem_bindir
|
467
|
+
end
|
468
|
+
|
411
469
|
def test_execute_unknown_gem_at_remote_source
|
412
470
|
install_specs util_spec 'a'
|
413
471
|
|
@@ -437,38 +495,16 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|
437
495
|
@cmd.execute
|
438
496
|
end
|
439
497
|
|
440
|
-
assert_equal(
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
498
|
+
assert_equal(
|
499
|
+
[
|
500
|
+
"Restoring gems to pristine condition...",
|
501
|
+
"Skipped default-2.0.0.0, it is a default gem",
|
502
|
+
],
|
503
|
+
@ui.output.split("\n")
|
504
|
+
)
|
445
505
|
assert_empty(@ui.error)
|
446
506
|
end
|
447
507
|
|
448
|
-
def test_execute_bundled_gem_on_old_rubies
|
449
|
-
util_set_RUBY_VERSION '1.9.3', 551
|
450
|
-
|
451
|
-
spec = util_spec 'bigdecimal', '1.1.0' do |s|
|
452
|
-
s.summary = "This bigdecimal is bundled with Ruby"
|
453
|
-
end
|
454
|
-
install_specs spec
|
455
|
-
|
456
|
-
@cmd.options[:args] = %w[bigdecimal]
|
457
|
-
|
458
|
-
use_ui @ui do
|
459
|
-
@cmd.execute
|
460
|
-
end
|
461
|
-
|
462
|
-
assert_equal([
|
463
|
-
"Restoring gems to pristine condition...",
|
464
|
-
"Skipped bigdecimal-1.1.0, it is bundled with old Ruby"
|
465
|
-
], @ui.output.split("\n"))
|
466
|
-
|
467
|
-
assert_empty @ui.error
|
468
|
-
ensure
|
469
|
-
util_restore_RUBY_VERSION
|
470
|
-
end
|
471
|
-
|
472
508
|
def test_handle_options
|
473
509
|
@cmd.handle_options %w[]
|
474
510
|
|
@@ -488,4 +524,3 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|
488
524
|
end
|
489
525
|
|
490
526
|
end
|
491
|
-
|