diff --git a/docs/packagist b/docs/packagist index 44c17b01a..094ad912d 100644 --- a/docs/packagist +++ b/docs/packagist @@ -8,9 +8,8 @@ Install Notes - The token which you can find on the Packagist profile page Optional steps: - Enter the username who the API token belongs to (defaults to the repository owner) - - Enter the host of your Packagist installation (defaults to http://packagist.org), the protocol-prefix is optional and defaults to "http://". + - Enter the host of your Packagist installation (defaults to https://packagist.org), the protocol-prefix is optional and defaults to "http://". 3. Check the "Active" checkbox and click "Update Settings". -For more details about Packagist, visit http://packagist.org/ - +For more details about Packagist, visit https://packagist.org/ diff --git a/lib/services/packagist.rb b/lib/services/packagist.rb index 9652fbc0f..9e85e9291 100644 --- a/lib/services/packagist.rb +++ b/lib/services/packagist.rb @@ -5,7 +5,6 @@ class Service::Packagist < Service white_list :domain, :user def receive_push - http.ssl[:verify] = false http_post packagist_url, :payload => generate_json(payload), :username => user, :apiToken => token end @@ -37,14 +36,13 @@ def domain def full_domain if data['domain'].to_s == '' - 'http://packagist.org' + 'https://packagist.org' else data['domain'] - end.lstrip.sub(/[\/\s]+$/,'') + end.lstrip.sub(/[\/\s]+\z/,'').sub(/\Ahttp:\/\/packagist.org/, 'https://packagist.org') end def domain_parts @domain_parts ||= full_domain.split('://') end end - diff --git a/test/packagist_test.rb b/test/packagist_test.rb index 3d5a9aa22..d0fb779be 100644 --- a/test/packagist_test.rb +++ b/test/packagist_test.rb @@ -62,7 +62,7 @@ def test_handles_blank_strings_without_errors assert_equal 'mojombo', svc.user assert_equal '5gieo7lwcd8gww800scs', svc.token assert_equal 'packagist.org', svc.domain - assert_equal 'http', svc.scheme + assert_equal 'https', svc.scheme end def test_detects_http_url @@ -117,6 +117,15 @@ def test_defaults_to_packagist_domain assert_equal "packagist.org", svc.domain end + def test_packagist_forced_to_tls + data = { + 'domain' => 'http://packagist.org' + } + svc = service(data, payload) + assert_equal 'packagist.org', svc.domain + assert_equal 'https', svc.scheme + end + def service(*args) super Service::Packagist, *args end @@ -182,4 +191,3 @@ def payload2 } end end -